1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* time.c (find_time_t): 24:00 should be the beginning of the next

day even if the leap second, 23:59:60, exists.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28588 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
akr 2010-07-09 11:33:46 +00:00
parent 4eec1b31b9
commit 00f97ed41a
3 changed files with 24 additions and 1 deletions

View file

@ -1,3 +1,8 @@
Fri Jul 9 20:30:26 2010 Tanaka Akira <akr@fsij.org>
* time.c (find_time_t): 24:00 should be the beginning of the next
day even if the leap second, 23:59:60, exists.
Fri Jul 9 01:08:46 2010 Aaron Patterson <aaron@tenderlovemaking.com>
* ext/psych/lib/psych/visitors/emitter.rb (initialize): line_width is

View file

@ -147,6 +147,23 @@ class TestTimeTZ < Test::Unit::TestCase
}
end
def test_right_utc
with_tz(tz="right/UTC") {
assert_time_constructor(tz, "2008-12-31 23:59:59 UTC", :utc, [2008,12,31,23,59,59])
assert_time_constructor(tz, "2008-12-31 23:59:60 UTC", :utc, [2008,12,31,23,59,60])
assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2008,12,31,24,0,0])
assert_time_constructor(tz, "2009-01-01 00:00:00 UTC", :utc, [2009,1,1,0,0,0])
}
end
def test_right_america_los_angeles
with_tz(tz="right/America/Los_Angeles") {
assert_time_constructor(tz, "2008-12-31 15:59:59 -0800", :local, [2008,12,31,15,59,59])
assert_time_constructor(tz, "2008-12-31 15:59:60 -0800", :local, [2008,12,31,15,59,60])
assert_time_constructor(tz, "2008-12-31 16:00:00 -0800", :local, [2008,12,31,16,0,0])
}
end
MON2NUM = {
"Jan" => 1, "Feb" => 2, "Mar" => 3, "Apr" => 4, "May" => 5, "Jun" => 6,
"Jul" => 7, "Aug" => 8, "Sep" => 9, "Oct" => 10, "Nov" => 11, "Dec" => 12

3
time.c
View file

@ -2928,6 +2928,7 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp)
return NULL;
}
}
/* Given argument has no corresponding time_t. Let's outerpolation. */
/*
* `Seconds Since the Epoch' in SUSv3:
@ -2950,7 +2951,7 @@ find_time_t(struct tm *tptr, int utc_p, time_t *tp)
tm_lo.tm_yday) * 86400 +
(tptr->tm_hour - tm_lo.tm_hour) * 3600 +
(tptr->tm_min - tm_lo.tm_min) * 60 +
(tptr->tm_sec - tm_lo.tm_sec);
(tptr->tm_sec - (tm_lo.tm_sec == 60 ? 59 : tm_lo.tm_sec));
return NULL;