Live data from Hacker News

The 1 Hour per Year Bug, but only in Pacific time

tomeraberba.ch

41–50 of 65 posts

Re: The 1 Hour per Year Bug, but only in Pacific time

#41
post #4

The article claims that the daylight savings transition happens at 11pm in pacific time. However, my understanding is that this transition should happen at 2 am for all us time zones. Where is 11pm coming from?

Maybe a cross-timezone interaction? 23:00 pacific is 02:00 eastern (most days)

Right, the transition to daylight savings at 2AM in the Eastern time zone occurs at 11PM in the Pacific time zone; there is one less hour's difference between the time zones until the Pacific time zone also springs forward three hours later.

Re: The 1 Hour per Year Bug, but only in Pacific time

#42
My favorite DST bug was a system that was supposed to run every few seconds taking a nap for an hour. It was an event loop thingy that had a few different types of tasks it might do. When it finished one of those tasks it'd record (in time-zone-local time) the time it completed it. When the event loop ran, it'd check that timestamp against now to see whether the task needed doing.

In comes the DST rollback. At 1:59 AM Pacific Daylight time the task ran. At 2:00 AM Pacific Daylight time the time changes to 1:00 AM Pacific Standard time. For the next hour it just sees "ooh 1:01 AM is not more than 1 minutes after 1:59 AM, I'm going to sleep. 1:02 AM is not more than 1 minute after 1:59 AM..." and ends up falling behind for that hour until it magically fixes itself at 2:01 AM Pacific Standard Time

Re: The 1 Hour per Year Bug, but only in Pacific time

#43
post #32

Clocks roll back at 2am Pacific time just like everywhere else - so the author's explanation seems unsatisfying although I've encountered this type of bug before.

Yeah, as soon as they said 11PM I realized, ` they're using EST as the timezone? ` which would just do it at that time for everyone using the doc? I don't work with raw date objects in JavaScript very much, is that illogical behavior from it's Date object?

It’s totally feasible; if the server is using JS and is located in ET the parsed Date tends to be converted internally to local zone (very frustrating).

The Temporal spec[1] should alleviate a lot of the JS induced pain. Knowing how to correctly store and manipulate time data, however is a completely separate issue that even really experienced engineers can easily mess up, even with solid STD lib support.

1: https://tc39.es/proposal-temporal/docs/

Re: The 1 Hour per Year Bug, but only in Pacific time

#44

Earlier quoted context omitted.

The absolute worst are ones like “last month”, “last week” or “earlier this week” - almost absolutely useless! Especially for logs of things that happened at work, I extremely frequently want to know the day and date something happened, but that style obscures that sometimes to the point where you can’t even tell which week it was!

I also hate "1 year ago" when it was actually 23 months ago

this is what I hate about youtube, when you look at the title and says 1 year ago and its just 1 month away for 2 years lol

Re: The 1 Hour per Year Bug, but only in Pacific time

#45

Earlier quoted context omitted.

I also hate "1 year ago" when it was actually 23 months ago

this is what I hate about youtube, when you look at the title and says 1 year ago and its just 1 month away for 2 years lol

Exactly what I was going to post... In the earlier days of YT, I don't think that was how it worked, but that could just be my faulty memory.

Re: The 1 Hour per Year Bug, but only in Pacific time

#46

Clocks roll back at 2am Pacific time just like everywhere else - so the author's explanation seems unsatisfying although I've encountered this type of bug before.

Yeah, I was waiting for the author to mention the unstated premise that the software was using Eastern time as the default.

Re: The 1 Hour per Year Bug, but only in Pacific time

#47
post #17
post #13

Earlier quoted context omitted.

No, it isn't. That approach works fine for things like logging where are your timestamps are in the past, but the moment you have to deal with future timestamps it leads to some truly horrible issues when some political leader decides to change the definition of the timezone. Suddenly all your future epoch-based datetimes are representing the wrong wall clock time...

Timekeeping is always epoch based. When the definition changes you update the display code. There’s no way to write code today that accounts for future changes in local time.

That's the same kind of mentality that kept Google Calendar from being able to schedule a monthly meeting on the last day of the month. If you scheduled it on the 31st, the tool would happily accept that 5 months each year wouldn't have your monthly meeting.

Suppose I have an 8am alarm to wake up in the morning. I want that to happen once per day in my current local timezone. If I change locations, the epoch I'm being alarmed at should change. If I travel quickly enough to experience multiple 8ams, I only want one of them (the first one). If laws change to give me multiple 8ams in a single locale, it's ambiguous which one I want. How your alarm app handles that varies, but you should do _something_ (flag the situation in the app, pick one (if one of them is about the same epoch as the previous alarm, maybe pick that one), ...).

For calendars you have probably a different set of choices. If all participants are in the same time zone, you probably want the meeting to move as regulations change the definition of 8am. If they're in different time zones which all practice daylight savings and the meeting doesn't conflict with any of the 1-2am haunted hours then the meeting should probably move with daylight savings, reference the local time as it was defined when the meeting was created, and not move as some dictator redefines a time zone (becoming a cross between a display issue and actually considering local time). If you don't know anything as a calendar app about the participants, there will be edge cases where you make bad decisions, so you either accept that or flag the ambiguity when appropriate.

And so on.

If we can convince everyone to switch to some kind of atomic time without leap seconds I'd be tickled pink. That's not the world we live in though.

Re: The 1 Hour per Year Bug, but only in Pacific time

#48
post #3

> Normally I would have dismissed that as a coincidence, but daylight saving time also ended at 11:00pm (PT) on November 7! Huh? Unless I'm mistaken, Daylight Saving ended at 2am local time on Nov 7, 2021. Was the bug that Day Saving is internally set based on Eastern Time (i.e. 2am ET / 11pm PT)?

Sounds like the library that is converting their internal eastern time representation of the datetime to local time is determining the daylight savings time before converting.

Or it is just assuming a standard offset, not taking into account the 6 hours a year where eastern and western time isn't 3 hours apart

Re: The 1 Hour per Year Bug, but only in Pacific time

#49

Clocks roll back at 2am Pacific time just like everywhere else - so the author's explanation seems unsatisfying although I've encountered this type of bug before.

I thought the same, but I was not sure, so I searched for the answer, and surely the NIST page "Daylight Saving Time Rules" [1] would be definitive? Unfortunately, its statement of the rule [2] seems ambiguous, in that it uses '2 a.m.' without qualifying it as local time (though the example does.) Is there a rule saying that times expressed as a.m. (or p.m., I suppose) are always local time (in whatever context they appear, which could also be a cause of ambiguity) unless explicitly qualified otherwise?

[1] https://www.nist.gov/pml/time-and-frequency-division/popular...

[2] At present, daylight saving time in the United States begins at 2:00 a.m. on the second Sunday of March (at 2 a.m. the local time time skips ahead to 3 a.m. so there is one less hour in that day) [and] ends at 2:00 a.m. on the first Sunday of November (at 2 a.m. the local time becomes 1 a.m. and that hour is repeated, so there is an extra hour in that day.)

Re: The 1 Hour per Year Bug, but only in Pacific time

#50
post #3

> Normally I would have dismissed that as a coincidence, but daylight saving time also ended at 11:00pm (PT) on November 7! Huh? Unless I'm mistaken, Daylight Saving ended at 2am local time on Nov 7, 2021. Was the bug that Day Saving is internally set based on Eastern Time (i.e. 2am ET / 11pm PT)?

This is my understanding as well. and and Wikipedia backs me up on it [ https://en.wikipedia.org/wiki/Pacific_Time_Zone#Daylight_tim... ]. Some of the software I've written _explicitly_ disables scheduling mobile notifications during the transition periods so I was also very confused by that. Your ET speculation makes sense to me. I'll bet that whatever server/containers being used for the backend were running in the…

Normalizing to a zoned date (vs. an epoch representation) during a transition period is problematic. During the transition periods (unique to each daylight time zone) the temporal distance between timezones changes (increases or decreases by 1) temporarily.
Post reply on HN