From: Paul Harris Date: 2009-05-19T18:58:21+09:00 Subject: [ruby-core:23501] [Bug #1490] DateTime::civil fails with second=59 and fractional second > 0 Bug #1490: DateTime::civil fails with second=59 and fractional second > 0 http://redmine.ruby-lang.org/issues/show/1490 Author: Paul Harris Status: Open, Priority: High ruby -v: ruby 1.8.6 (2007-03-13 patchlevel 0) [i386-mswin32] eg, DateTime::civil(2009,5,5,10,11,59+Rational(1,10**3)) this should give 2009-05-05 10:11:59.001 but instead it throws 'invalid date' the code in ruby 1.8 date.rb: def self.valid_time? (h, min, s) h += 24 if h < 0 min += 60 if min < 0 s += 60 if s < 0 return unless ((0..23) === h && (0..59) === min && (0..59) === s) || (24 == h && 0 == min && 0 == s) time_to_day_fraction(h, min, s) end should have seconds test changed to s >= 0 && s < 60) || and thus, should read: def self.valid_time? (h, min, s) h += 24 if h < 0 min += 60 if min < 0 s += 60 if s < 0 return unless ((0..23) === h && (0..59) === min && s >= 0 && s < 60) || (24 == h && 0 == min && 0 == s) time_to_day_fraction(h, min, s) end ---------------------------------------- http://redmine.ruby-lang.org