Project

General

Profile

Bug #14241 » time-strptime-wnum.patch

jeremyevans0 (Jeremy Evans), 06/21/2019 05:47 PM

View differences:

lib/time.rb
else
year = d[:year]
year = yield(year) if year && block_given?
t = make_time(date, year, d[:yday], d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
yday = d[:yday]
if (d[:wnum0] || d[:wnum1]) && !yday && !(d[:mon] && d[:mday])
yday = Date.strptime(date, format).yday
end
t = make_time(date, year, yday, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
end
t
end
test/test_time.rb
assert_equal(15, t.hour)
end
def test_strptime_wu
assert_equal(Time.local(2019, 1, 30), Time.strptime("3 4 2019", "%w %W %Y"))
assert_equal(Time.local(2019, 2, 7), Time.strptime("4 5 2019", "%u %U %Y"))
assert_equal(Time.local(2019, 1, 28), Time.strptime("4 2019", "%W %Y"))
assert_equal(Time.local(2019, 2, 3), Time.strptime("5 2019", "%U %Y"))
end
def test_nsec
assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
end
(1-1/2)