Live data from Hacker News

Falsehoods programmers believe about time and time zones

creativedeletion.com

51–60 of 83 posts

Re: Falsehoods programmers believe about time and time zones

#51

This is why we should ignore time zones as much as possible. UTC is almost OK, except for the shitshow idiocy of leap seconds. There's no reason for all of us to suffer just so astronomers can use civil time.

UTC can also fail if your users need to see or enter times that are not in UTC. E.g. for a meeting or a train schedule or an appointment etc. See this http://www.creativedeletion.com/2015/03/19/persisting_future...

Re: Falsehoods programmers believe about time and time zones

#53

Earlier quoted context omitted.

Daylight Savings Time should die in the fires of hell.

I couldn't agree more - to boot, DST going away solves like half of the edge cases with one quick fix.

Except that removing DST won't, if you ever need to calculate a time/date for any time before its (future, hypothetical) removable. That could actually create more bugs.

Re: Falsehoods programmers believe about time and time zones

#54
Some big ones that are missing:

* Time zone (/DST) changes are always announced well in advance. * Time zone (/DST) changes are always announced in advance.

Yeah, so US announcing DST changes in 2005 that would take effect in 2007 is unusually long compared to most DST changes. A lot of Middle Eastern countries change DST based on the start of Ramadan, which doesn't officially start until someone actually observes the phase of the moon. While you could calculate this from well-known astronomical principles, there ends up being several different ways to handle corner cases which leads to several Islamic calendars in practice. This means that changes can end up being very last minute--a few years ago, the Olsen database wasn't updated for Egypt's DST changes until after they took effect, and there appears to have been a case or two in history where the actual official declaration of the change was, in effect, retroactive.

* 12 AM/12 PM are unambiguous. * Days, weeks, months, and years all start on consistent patterns.

Well, everything is largely consistent in modern civil time reckoning based on the Gregorian calendar, but it's very definitely not the case if you look back as recently as a few decades ago or think about other times. Julian dates start at noon. Particularly in medieval times, the start of the year might be December 25 or March 25--and the time people switched to January 1 as the consistent start year wasn't necessarily the same as the switch from Julian to Gregorian calendars.

Re: Falsehoods programmers believe about time and time zones

#55
post #39

I'll add one: "But surely each place only has one DST each year…" Nope. Troll Station in Antarctica has four different settings through the year. Personally since there are only 40 people there I think they should just suck it up and pick two. They are probably causing a lot of software bugs. I know they cost me a couple hours. Edit: Oh crum, I see Morocco suspends DST during Ramadan, so they have four settings too……

Not only that, but some countries change the switchover dates from time to time as well.

Re: Falsehoods programmers believe about time and time zones

#56
Time zones and DST are fun. When I worked at a healthcare software company, many hospitals chose to have their yearly upgrades done in the fall during the DST transition, because 1) it's confusing to see or even display documentation for events that happened at 2:30AM and the other 2:30AM and 2) it avoids any bugs that might crop up from the doubled hour.

Re: Falsehoods programmers believe about time and time zones

#57
post #49

Dealing with timezones and daylight savings time has consumed hundreds of hours of my development time. This seriously should be a standard service of the operating system, not the programming language library. Just look at all the code to deal with it in D (written by Jonathan Davis): https://github.com/dlang/phobos/blob/master/std/datetime.d

Operating systems kind of suck at it. Which is why for Elixir I made Tzdata ( https://github.com/lau/tzdata ) not rely on any timezone information from the operating systems. A feature I would like from operating systems is to tell me the true time during leap seconds. E.g. 23:59:59, 23:59:60, 00:00:00 Instead of repeating 23:59:59 or just pretending the leap second never happens.

> A feature I would like from operating systems is to tell me the true time during leap seconds. E.g. 23:59:59, 23:59:60, 00:00:00 Instead of repeating 23:59:59 or just pretending the leap second never happens.

In past discussions of leap seconds, it came out that the POSIX standard specifies that no such second as 23:59:60 can exist (by specifying that "one day" consists of exactly 86400 seconds). As I understand things, this is why the erroneous behavior you mention is done.

It is not clear to me why, for the sake of complying with a standard we know to be wrong, we report false information and otherwise do things that we also know are wrong. The obvious approach would seem to be to either change the standard or just ignore it.

Re: Falsehoods programmers believe about time and time zones

#58
post #16

My bete noir isn't in the list: GMT is only the UK timezone for about half the year. During the Summer, GMT continues to exist, but the UK time is BST.

But, as the Wikipedia page says "the term GMT should not be used for precise purposes" as it has been superseded by various other standards (e.g. UTC, UT1) I've encountered English people who made a fuss about the loss of "God's Magnificent Time", but for better or worse GMT is no longer the official name.

Be that as it may, UK legislation uses GMT and not UTC. It is therefore the appropriate time to be using in software for UK citizens.

Re: Falsehoods programmers believe about time and time zones

#60
post #31

Earlier quoted context omitted.

It's about consistency. 23:59:60 is introducing a special case to the seconds field which you have to account for. 24:00:00 only adds a second to the day where it naturally should go. I don't redefine what a minute is, a minute is always 60 seconds. You are confusing two separate ideas, displaying a time and finding the difference between two times. Lexically you wouldn't say that minute is 1 second long, you would s…

But then you have a second that doesn't belong to a minute.

...so what that doesn't matter? Imagine you are an evil genius who has built a rocket to extend earth's orbit by an hour each day. How would you now represent time for a day once we live in that new orbit? Most people would just add an hour so the days end at 24:59:59. What if the rocket didn't extend time by an hour but instead by 59 minutes and 59 seconds. What would you do then? We can repeat this until we get down to one second. Wouldn't it make sense to end up at 24:00:00 instead of 23:59:60 in that situation?
Post reply on HN