Project

General

Profile

Bug #12147

Time::local returns incorrect ending of US DST

Added by rmitchell (Ryan Mitchell) over 1 year ago. Updated over 1 year ago.

Status:
Rejected
Priority:
Normal
Target version:
-
ruby -v:
ruby 2.3.0p0 (2015-12-25 revision 53290) [x86_64-darwin14]
[ruby-core:74189]

Description

In 2016, US Daylight Saving Time ends at 2:00 AM on November 6. In the America/Los_Angeles timezone, this means going from an offset from UTC of -0700 to an offset of -0800. So 1:00 AM on that date is still in DST, with an offset from UTC of -0700. But Time::local begins returning the new offset at 1:00 AM instead of 2:00 AM. The offset of times at midnight and at 2:00 AM are returned correctly:

2.3.0 :020 > Time.local(2016, 11, 6, 0)
 => 2016-11-06 00:00:00 -0700
2.3.0 :021 > Time.local(2016, 11, 6, 1)
 => 2016-11-06 01:00:00 -0800
2.3.0 :022 > Time.local(2016, 11, 6, 2)
 => 2016-11-06 02:00:00 -0800

This behaves correctly in Ruby 2.2.0 and it looks possibly related to https://bugs.ruby-lang.org/issues/10698.

History

#1 [ruby-core:74197] Updated by rmitchell (Ryan Mitchell) over 1 year ago

Edit: a coworker pointed out to me that because on Nov 6th 2016 there are actually two instances of 1:00 AM, Time::local has no way of knowing which one you're referring to - it has to choose one arbitrarily, and returning the second one isn't incorrect, even if the behavior I'd expect is that it would return the first one. So this isn't a bug per se and I'm happy to have it closed.

#2 [ruby-core:74208] Updated by avit (Andrew Vit) over 1 year ago

Right, if you need the first instance (Daylight Savings Time, not Standard Time) of 01:00 you have to do one of these:

Time.local(2016, 11, 6, 1) - 3600
Time.at(1478419200) # unixtime for the above

(By the way, is there a proper name for "that extra hour"?)

#3 [ruby-core:74211] Updated by duerst (Martin Dürst) over 1 year ago

  • Status changed from Open to Closed

Ryan Mitchell wrote:

So this isn't a bug per se and I'm happy to have it closed.

#4 [ruby-core:74220] Updated by usa (Usaku NAKAMURA) over 1 year ago

  • Status changed from Closed to Rejected

Also available in: Atom PDF