Project

General

Profile

Bug #14241 ยป time-strptime-wnum.patch

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

View differences:

lib/time.rb
457 457
      else
458 458
        year = d[:year]
459 459
        year = yield(year) if year && block_given?
460
        t = make_time(date, year, d[:yday], d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
460
        yday = d[:yday]
461
        if (d[:wnum0] || d[:wnum1]) && !yday && !(d[:mon] && d[:mday])
462
          yday = Date.strptime(date, format).yday
463
        end
464
        t = make_time(date, year, yday, d[:mon], d[:mday], d[:hour], d[:min], d[:sec], d[:sec_fraction], d[:zone], now)
461 465
      end
462 466
      t
463 467
    end
test/test_time.rb
528 528
    assert_equal(15, t.hour)
529 529
  end
530 530

  
531
  def test_strptime_wu
532
    assert_equal(Time.local(2019, 1, 30), Time.strptime("3 4 2019", "%w %W %Y"))
533
    assert_equal(Time.local(2019, 2, 7), Time.strptime("4 5 2019", "%u %U %Y"))
534
    assert_equal(Time.local(2019, 1, 28), Time.strptime("4 2019", "%W %Y"))
535
    assert_equal(Time.local(2019, 2, 3), Time.strptime("5 2019", "%U %Y"))
536
  end
537

  
531 538
  def test_nsec
532 539
    assert_equal(123456789, Time.parse("2000-01-01T00:00:00.123456789+00:00").tv_nsec)
533 540
  end
534
-