Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Failing DateTime.strptime for weird dates near epoch #2149

@headius

Description

@headius

This test from MRI 2.2 fails on our DateTime.strptime implementation:

  def test_sz
    d = DateTime.strptime('0 -0200', '%s %z')
    assert_equal([1969, 12, 31, 22, 0, 0], [d.year, d.mon, d.mday, d.hour, d.min, d.sec])
    assert_equal(Rational(-2, 24), d.offset)
    d = DateTime.strptime('9 +0200', '%s %z')
    assert_equal([1970, 1, 1, 2, 0, 9], [d.year, d.mon, d.mday, d.hour, d.min, d.sec])
    assert_equal(Rational(2, 24), d.offset)

    d = DateTime.strptime('0 -0200', '%Q %z')
    assert_equal([1969, 12, 31, 22, 0, 0], [d.year, d.mon, d.mday, d.hour, d.min, d.sec])
    assert_equal(Rational(-2, 24), d.offset)
    d = DateTime.strptime('9000 +0200', '%Q %z')
    assert_equal([1970, 1, 1, 2, 0, 9], [d.year, d.mon, d.mday, d.hour, d.min, d.sec])
    assert_equal(Rational(2, 24), d.offset)

  end

Failure:

TestDateStrptime#test_sz [/Users/headius/projects/jruby/test/mri/date/test_date_strptime.rb:497]:
<[1969, 12, 31, 22, 0, 0]> expected but was
<[1970, 1, 1, 0, 0, 0]>.

Can run using `jruby test/mri/runner.rb date/test_date_strptime.rb

I will exclude this test for now.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions