summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--test/ruby/test_time_tz.rb17
-rw-r--r--time.c3
3 files changed, 24 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 4a1e1debb9..cfeffc7772 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 4942d32028..e6b632f2dd 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -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
diff --git a/time.c b/time.c
index 04145f63ea..d2a90d4aa2 100644
--- a/time.c
+++ b/time.c
@@ -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;