зеркало из https://github.com/github/ruby.git
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
This commit is contained in:
Родитель
85e749080e
Коммит
a03411b63e
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Nov 5 23:46:03 2016 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
|
* time.c (vtm_add_offset): Fix yday on last day of year.
|
||||||
|
[ruby-core:72878] [Bug #11994] Fixed by Andrew White.
|
||||||
|
|
||||||
Sat Nov 5 23:30:41 2016 Shugo Maeda <shugo@ruby-lang.org>
|
Sat Nov 5 23:30:41 2016 Shugo Maeda <shugo@ruby-lang.org>
|
||||||
|
|
||||||
* lib/net/http.rb (Net::HTTP.post): new convenience method to send
|
* lib/net/http.rb (Net::HTTP.post): new convenience method to send
|
||||||
|
|
|
@ -1072,4 +1072,21 @@ class TestTime < Test::Unit::TestCase
|
||||||
assert_equal now2, now3
|
assert_equal now2, now3
|
||||||
assert_equal now2.zone, now3.zone
|
assert_equal now2.zone, now3.zone
|
||||||
end
|
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
|
end
|
||||||
|
|
2
time.c
2
time.c
|
@ -1889,7 +1889,7 @@ vtm_add_offset(struct vtm *vtm, VALUE off)
|
||||||
vtm->mday = 31;
|
vtm->mday = 31;
|
||||||
vtm->mon = 12; /* December */
|
vtm->mon = 12; /* December */
|
||||||
vtm->year = sub(vtm->year, INT2FIX(1));
|
vtm->year = sub(vtm->year, INT2FIX(1));
|
||||||
vtm->yday = leap_year_v_p(vtm->year) ? 365 : 364;
|
vtm->yday = leap_year_v_p(vtm->year) ? 366 : 365;
|
||||||
}
|
}
|
||||||
else if (vtm->mday == 1) {
|
else if (vtm->mday == 1) {
|
||||||
const int *days_in_month = leap_year_v_p(vtm->year) ?
|
const int *days_in_month = leap_year_v_p(vtm->year) ?
|
||||||
|
|
Загрузка…
Ссылка в новой задаче