Project

General

Profile

Bug #7445 » 0001-time-fix-strptime.patch

felipec (Felipe Contreras), 10/06/2013 10:17 AM

View differences:

lib/time.rb
d = Date._strptime(date, format)
raise ArgumentError, "invalid strptime format - `#{format}'" unless d
if seconds = d[:seconds]
Time.at(seconds)
offset = d[:offset] || 0
Time.at(seconds).localtime(offset)
else
year = d[:year]
year = yield(year) if year && block_given?
test/test_time.rb
def test_strptime
assert_equal(Time.utc(2005, 8, 28, 06, 54, 20), Time.strptime("28/Aug/2005:06:54:20 +0000", "%d/%b/%Y:%T %z"))
assert_equal(Time.at(1).localtime, Time.strptime("1", "%s"))
assert_equal(0, Time.strptime('0', '%s').utc_offset)
assert_equal(3600, Time.strptime('0 +0100', '%s %z').utc_offset)
end
def test_nsec
(2-2/2)