diff options
author | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-04 20:56:28 +0000 |
---|---|---|
committer | tadf <tadf@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-05-04 20:56:28 +0000 |
commit | a72f9f34767f9f2a6e8b7e22251949e65d2fe39d (patch) | |
tree | 1cb8dad1e0e7cf166c76ee50402a5f7dae35a2cc /test | |
parent | d9087ffebca0e5637246d4b8dce35c65d28f40a1 (diff) | |
download | ruby-a72f9f34767f9f2a6e8b7e22251949e65d2fe39d.tar.gz |
* ext/date/date_core.c (rt_rewrite_frags): a new feature (not a
bug fix) of strptime. applies offset even if the given date is
not local time (%s and %Q). This is an exceptional feature and
I do NOT recommend to use this at all. Thank you git community.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/date/test_date_strptime.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/test/date/test_date_strptime.rb b/test/date/test_date_strptime.rb index 40d4e22a72..5270bc3c1c 100644 --- a/test/date/test_date_strptime.rb +++ b/test/date/test_date_strptime.rb @@ -493,4 +493,21 @@ class TestDateStrptime < Test::Unit::TestCase assert_equal(s0, s) end + 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 + end |