From: Tanaka Akira Date: 2013-09-10T17:09:11+09:00 Subject: [ruby-core:57104] Re: [ruby-trunk - Bug #8885][Open] Incorrect time is created for time including leap seconds 2013/9/10 sawa (Tsuyoshi Sawada) : > Bug #8885: Incorrect time is created for time including leap seconds > https://bugs.ruby-lang.org/issues/8885 > ruby -v: 2.0 > `Time.new` creates incorrect time when the time includes a leap second. > > Time.new(2012, 6, 30, 23, 59, 60) > # => 2012-07-01 00:00:00 +0900 # Wrong. Should be 2012-06-30 23:59:60 +0900 > > Time.new(2012, 6, 30, 23, 59, 60) == Time.new(2012, 7, 1, 0, 0, 0) > # => true # Wrong. Should be `false`. At first, please confirm your enviroment (OS and configuration) supports leap seconds. Ruby supports leap seconds only if your environment supports leap seconds. What is your OS? The command line, ruby -v, shows the ruby version including your OS. But you didn't fill the entry of the form as the result of the command line. ("2.0" is not a proper result of ruby -v.) Example: % ruby -v ruby 2.1.0dev (2013-08-16 trunk 42586) [x86_64-linux] What is the value of TZ environment variable? Some (Unix) environment sees TZ environment variable to determine to support leap seconds or not. (The value prefixed with "right/" may indicate leap seconds support.) What the result of the following command? % ruby -e '3.times {|i| p Time.at(78796799+i) }' The command shows Time class behavior around the first leap second, 1972-06-30T23:59:60Z. Environment which supports leap seconds: % TZ=right/UTC ruby -e '3.times {|i| p Time.at(78796799+i) }' 1972-06-30 23:59:59 +0000 1972-06-30 23:59:60 +0000 1972-07-01 00:00:00 +0000 Environment which doesn't support leap seconds: % TZ=UTC ruby -e '3.times {|i| p Time.at(78796799+i) }' 1972-06-30 23:59:59 +0000 1972-07-01 00:00:00 +0000 1972-07-01 00:00:01 +0000 -- Tanaka Akira