aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:59:51 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-11-05 14:59:51 +0000
commit7b040a0fef77ddb7d0e40b3cc019903056eb371d (patch)
treeb3523facbe421065031ca588a53dfa43b0681276 /test
parent1cc3de7fc7dc002560278fd20e51e77bbe1bc873 (diff)
downloadruby-7b040a0fef77ddb7d0e40b3cc019903056eb371d.tar.gz
fix vtm_add_offset yday on last day of year.
* time.c (vtm_add_offset): Fix yday on last day of year. [ruby-core:72878] [Bug #11994] Fixed by Andrew White. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56599 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_time.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index 5a2ad42491..60bed87c9c 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -1072,4 +1072,21 @@ class TestTime < Test::Unit::TestCase
assert_equal now2, now3
assert_equal now2.zone, now3.zone
end
+
+ def test_strftime_yearday_on_last_day_of_year
+ t = Time.utc(2015, 12, 31, 0, 0, 0)
+ assert_equal("365", t.strftime("%j"))
+ t = Time.utc(2016, 12, 31, 0, 0, 0)
+ assert_equal("366", t.strftime("%j"))
+
+ t = Time.utc(2015, 12, 30, 20, 0, 0).getlocal("+05:00")
+ assert_equal("365", t.strftime("%j"))
+ t = Time.utc(2016, 12, 30, 20, 0, 0).getlocal("+05:00")
+ assert_equal("366", t.strftime("%j"))
+
+ t = Time.utc(2016, 1, 1, 1, 0, 0).getlocal("-05:00")
+ assert_equal("365", t.strftime("%j"))
+ t = Time.utc(2017, 1, 1, 1, 0, 0).getlocal("-05:00")
+ assert_equal("366", t.strftime("%j"))
+ end
end