Falsehoods programmers believe about time
infiniteundo.com
infiniteundo.com
First I dug into the Java source, which it turned out called out to a C library. I believe the C library linked out to a Fortran library. It was a lot more complicated than a simple scale and calendar - there were corrections for special and general relativity. Converting times actually required propagating orbits and estimating some non-closed-form quantities. In the end is was more work than it was worth, so we just did an approximation ("only" good to a few milliseconds - fine for our case).
So I guess item number 100 on this list should be "time is experienced the same way by all observers" and maybe 101 "simultaneity depends on the reference frame" :)
Falsehoods programmers believe about time zones - https://news.ycombinator.com/item?id=24870376 - Oct 2020 (16 comments)
Falsehoods programmers believe about time (2017) - https://news.ycombinator.com/item?id=24453712 - Sept 2020 (8 comments)
Falsehoods programmers believe about Unix time - https://news.ycombinator.com/item?id=19922062 - May 2019 (268 comments)
Falsehoods Programmers Believe About Time (2012) - https://news.ycombinator.com/item?id=12675527 - Oct 2016 (154 comments)
Falsehoods programmers believe about time and time zones - https://news.ycombinator.com/item?id=11515125 - April 2016 (80 comments)
Falsehoods Programmers believe about Time - https://news.ycombinator.com/item?id=4128208 - June 2012 (213 comments)
https://gist.github.com/timvisee/fcda9bbdff88d45cc9061606b4b...
(For some reason people think we know these things)
FALSE: Dang is a cosmic entity of Lovecraftian proportions who exists outside of and beyond our pitiful human conceptions of "time" and "space." Dang is eternal, dang is everywhere, dang is everything.
But this one jumped out at me: "Any 24-hour period will always begin and end in the same day". It would be a lot more plausible if "always" were replaced with "never". Add 24 hours to a time, and it will (almost) always be the next day.
More often than not I’m pushed back in with “that doesn’t happen” or “don’t spend time on that”. “We’re never open past 9, don’t worry about a day” but then they acquire a system in a different time zone and … boom. Things are broken.
Some of my favorite things lie in the fractal fringe categories between those, such as, "the things you didn't realize you believed (by your actions) until someone pointed them out to you" and "the things you didn't realize you should believe (in any sense) until someone pointed them out to you, at which point they seemed blindingly obvious and you can't believe you missed it".
Never experienced this myself, it’s trivial in all the languages I can think of. Sometimes you have multiply or divide by 1000 if JavaScript is involved.
I always prefer Unix epoch time. What was the language and stack causing the mess so I know to avoid it?
Then, there would be only three problems, which decompose nicely:
1. Trying to keep the system time accurate, and accounting for the possibility it isn't. 2. Having up-to-date time zone information 3. Converting TT to/from a date/time in some particular format in a particular timezone.
(1) is fundamentally unavoidable. (3) is complicated but well-defined. (2) should be handled by the system. All that's left is calculations on time values, which if they're in TT (i.e. actual time) are very well behaved.
Ultimately this is the fault of the standards bodies. POSIX defines time in terms of UTC. NTP tries to keep the system clock synced with UTC. Postgres "timestamp with timezone" stores UTC. Zone files state offsets in terms of UTC, and even worse, transition times are stated with reference to a timezone (see tzfile(5) and RFC 8536), which is completely insane.
This could change. Existing standards can't but new standards could be introduced to succeed the old ones and exist side-by-side. Maybe, instead of proposing changing UTC because they find leap seconds inconvenient, an organization like Facebook could actually do something useful and push for them.
10 AM
11 AM
12 PM <- AM/PM and calendar cycle is here.
01 PM <- n%12 cycle is here, an hour later.
02 PM
03 PM
I see large software systems for things like airlines and trains sometimes make this mistake, for instance a 1 hour trip on a ticket that says "11:30AM - 12:30AM" which is actually negative 11 hours.
I have a collection of photos somewhere of every time I've caught it. If I could change anything about time that probably nobody would care about, it would be to align those two cycles.
The fact that I catch it every couple months on widely deployed systems I interpret as the signal that basically nobody notices/cares about it as everyone knows a -11 hour train ride isn't how time works.
Midnight appointment are interesting since the system doesn’t have “no appointment time” so they use 00:00 and 00:01 for a real midnight appointment and if you’re really, really tired…
I know, I can look it up, and I have several times. But the knowledge doesn't stick...
Translation: After midpoint, before midpoint.
Also the difference in the cycles comes from analog clocks.
I can explain all of this but it's still confusing and stupid to have to deal with it in 2022
As a non-native am/pm user: it's confusing. Even with that rule.
pm is between midday (inclusive) and midnight (exclusive) and am the rest, between midnight (inclusive) and midday (exclusive).
The ambiguity of midday and midnight is really the cherry on top of this masterpiece of confusion.
There is probably some part of me too offended by this system to want to remember it...
I'd say that the best solution would be to just rename 12 to 0, which is what it already should have been IMO, regardless of am/pm.
I've noticed some digital watches use 0:00AM instead of 12:00AM, but I've never seen this used for 0:00PM.
I got one for OP, too: UTC is not a timezone in the first place [1].
> UTC is not a time zone, but a time standard that is the basis for civil time and time zones worldwide. This means that no country or territory officially uses UTC as a local time.
The difference is subtle, but a standard is not subject to government whims while a timezone is.
1. https://www.timeanddate.com/time/gmt-utc-time.html#:~:text=U....
Updating standards almost never happens, unless with a name/identifier change. The whole point of standardized measures is their immutability.
I work on a sometimes offline educational product for children. Kids for some reason love to mess with their system clocks.
The hoops we've tried jumping through to get a reasonable time frame of events from iPads that were offline for any period of time is hilarious.
We gave up, and if the time of events is unreasonable, we just shift the entire set waiting to be synced so the first one is sync time. It's not perfect, it's not even really good, but it's gotten the least complaints.
There are plenty of mobile games that will time-gate in-game rewards (e.g. wait x hours to unlock y). Often, messing with the system clock skips these delays. You're welcome.
They are cheating at games!
His iPad was like 2 centuries ahead because moving the system time would give him extra lives. He couldn't practically move it back because then he'd have to wait another 2 centuries to get lives again. So his iPad was 2 centuries ahead until he completed Candy Crush.
Okay, of course a week can begin in an year and end in the next, but how exactly would a month not begin and end in the same year?
I'd highly recommend watching the whole video, by the way. It's really good.
My year starts on April 1st.
I do not want my year to start on January 1st, else I will need to work through all holidays for year-end closing.
I think they mean that if someone says "remind me in a month" On December 3rd, the reminder would be next year.
I've never met a developer who believed that, but I've met plenty who would forget about the edge-case and write a buggy time-library. As is the case for most of these.
Presidential proclamations are signed and dated in two calendars, "the year of our Lord", and "the year of the Independence of the United States of America":
IN WITNESS WHEREOF, I have hereunto set my hand this twenty-fifth day of October, in the year of our Lord two thousand twenty-one, and of the Independence of the United States of America the two hundred and forty-sixth.
The former uses January 1st as the start of each new year; the latter, July 4th.
In England, Lady Day (March 25th) was the turnover of a new year, for about 6 centuries.
No programmer has ever cared about Lady Day when writing a program. And if they did, by definition, they would understand it's significance.
It's not crazy to think that a user may, say, want to create a database of historical records, like when people were born, married or buried. Now I want to find out the age people were when married... suddenly, the existence of Lady Day and the time and place the dates were recorded become very important.
It could also be a reference to the start of the calendar, but that isn't bound to happen again.... Well, unless it does.
Then, on the other hand (because Time is funky that way) your time may not be the same as my time, since we could be in different time zones.
Would love to hear some horror stories you've encountered. It might help me keep an eye out for it.
If you actually need to worry about calendars and user input, you have my sympathy.
Every abstraction at some level is leaky. Even the atom is a leaky abstraction, and maybe even matter itself is a leaky abstraction at some level.
What matters is how well the abstraction matches your use case, and where the leaks are.
Just having a list of how a particular abstraction leaks without any context is not super helpful, IMO other than conveying a sense of complexity (and perhaps a sense of looking down on those unwashed masses who believe these "falsehoods"),
Don't make assumptions. You aren't smart. Keep it simple and don't get clever.
Sure, you might run into some quirk at some point in your career but they will end up being just another weird war story.
I worked directly with NTP. The nitty-gritty details and the leap second smears and all of that, for an absolutely huge network and I find this list patronizing, smug and worthless. It's some sort of intellectual masturbation or just another instance of https://news.ycombinator.com/item?id=32335165.
- `pytz.timezone(timezone_name)` will give you the current offset for that timezone - well, it will at least be some consistent offset - surely, every timezone has the same reference starting point?
What `pytz.timezone(name)` actually does is initialize a timezone object at the point in time of the first entry in the tz database for that zone. For example, New York had an offset of 4:56:02 prior to 1883 November 18, 12:03:58 [1]. That is the "starting point" for America/New_York and US/Eastern (which I think is an alias of New_York before a certain date). Which is why you get
>>> pytz.timezone('America/New_York')
<DstTzInfo 'America/New_York' LMT-1 day, 19:04:00 STD>
Ish. Not sure where those 2 seconds went. But that explains why you see that strange 19:04 (-3:56) offset. The real way to use it is >>> pytz.timezone('America/New_York').localize(your_specific_datetime)
Timezones without a reference time are deceptive.[1] https://en.wikipedia.org/wiki/Tz_database#Example_zone_and_r...
At a previous job, I spent over a year working on a library for timezones built on top of Boost. The handling of historical timezones was a particular pain in the ass.
https://harelang.org/blog/2022-04-17-chronology-in-hare/
To stress test our implementation (and to flex on other languages), we're implementing Martian time in it as well.
https://harelang.org/blog/2022-08-01-martian-time-in-hare/
// Hare's first commit.
let hare = mbc::new(chrono::MTC, 0, 0218,10,19, 09,20,53,344357297)!;
fmt::println(mbc::bsformat(buf, mbc::STELLAR, &hare)!)!;
// 0218 Perseus 19, Fri 09:20 MTC
My current litmus test goal for it is to get strftime to print out 23:23:60.Twice in my career I’ve had to implement code to handle concepts like “August 2022”, or “1pm”, where it was important to track the level of precision offered by the source material for later comparisons. “1pm” is not the same as “1:00:00.000”, nor is “August 2022” the same as “20220801T00:00:00.000Z”.
* Something is a falsehood because it's not true in every context
* Something is a falsehood because it's not true in many contexts
* Something is a falsehood because it's not true in any context but the one the programmer cares about
(and the correct context is often “whatever deals with the company's bullshit problem with the least effort”)
Also, the offsets between the timezones change. Eastern Daylight Time falls back from 2:00 to 1:00 Eastern Standard Time, which coincides with 1:00 for Central Daylight Time. So Eastern Time and Central Time are the same for one hour interval. Of course in the Spring you have the opposite problem - Central Time will be 2 hours behind Eastern Time for a one hour interval. So much for your interval time calculations! Also, the U.S. has changed the transition dates for the time change.
I'm so glad to be working on a system where I no longer have to worry about this crap!
The worst part was I had an appointment at 02:00, somewhere where they won’t let you in if you show up too early, in the other time zone and hadn’t had to deal with daylight savings time for a good long while having lived in Arizona where they don’t deal with such silliness. Trying to figure out what time to leave to time my arrival was very difficult.
Oh god, I'm simultaneously delighted at the idea of not having to deal with DST and terrified of writing software that might have to keep track of whether or not the user was in Arizona during a DST transition.
And for even more fun the Navajo Nation does do time zone changes.
That's why in the utility business it's common to use the language of standard time, daylight saving time, and prevailing time. For the Eastern timezone they write it as EST, EDT, EPT respectively. The important point is EST and EDT never vary - they'e fixed offset from UTC (UTC-05:00 and UTC-04:00, respectively). EPT is the squirrelly one - sometimes it matches EST and other times it matches EDT. At least when processing a time interval you know whether you have to take clock movement into account.
I also worked on event planning software with plenty of timezone fun with events having a timezone, the planner a potentially different timezone and it also handled flights for speakers etc who could be coming from any number of other timezones. That was mostly straight forward with decent libraries, but it certainly taught me that you need to think in (and store) timezones and not just offsets.
Reminds me of the old SAT hints: Beware of statements and questions with "always", "never", "must", and "cannot".
Then we can elect some druids or whatever to arbitrarily, at the start of each year, define which dates the seasonal borders will land on. Events which are truly dependent on weather can be defined in terms of "Days after the season starts."
Or we could define a 5.5+-.5 day holiday between the beginning and end of a given year. Those days will be declared to not belong to any year. We will turn off all our computers for those days, and pretend they didn't happen. If you are born within them, you get a special hat or something.
Maybe you and I have the privilege to turn off computers for almost a week without a negative effect, but not the majority of the world, everything uses a computer to operate and coordinate.
Think about food production, aviation, shipping, sailing... And much more at both small and big scales.
Wait. In fact, if you weren't born on 01-01-1970, you can't be Time Druid. Sorry.
Well sonnie-boy, listen up... it all started on 01-01-1970...
Kodak used to run on this calendar.
> having one or two days per year which are part of no month is stupid
which I've cleverly circumvented by adding almost a while week. I believe in this case the stupidity overflows and it becomes a good plan again.
All years were 12 months of 30 days plus 4 extra days of summer (Sumarauki in Icelandic), making the year exactly 52 weeks. Leap years had one extra week added to sumarauki making it a total of 11 days and leap years exactly 53 weeks. This has the benefits that each month starts on the same day of the week (e.g. the first day of the first summer month (Harpa) is still celebrated in Iceland and always lands on Thursday).
> There is no special numbering of the years used in the Icelandic calendar, so the year may be omitted or the current Gregorian year used.
It is hard not to imagine a day in Sumarauki as being sort of magically timeless.
Ok, Im intrigued, are there months that don't? I assume it must be a country specific thing?
Don't know about more recent examples
Actually looking at that tells me it is a mess... Like Belarus and Lithuania changing back to Julian calendar in 1800... And then again to Gregorian in 1918.
Or any of a number of different dates depending on where you were located: https://en.m.wikipedia.org/wiki/List_of_adoption_dates_of_th...
But I wish this list came with examples, and if it really means a different calendar system it's IMHO not as interesting, because it's IMHO fairly obvious that different calendar systems follow different rules. Or maybe during the switch to Gregorian calendar? That you'd at least encounter with dates for things long ago - although that transition is very "here be dragons" and very local.
https://en.wikipedia.org/wiki/Intercalation_(timekeeping)
https://en.wikipedia.org/wiki/Ethiopian_calendar
I guess its the choice if you fix the offset every year or wait until you accumulate a full month of offset.
Different but related, 46 BC, the year of adoption of the Julian calendar, had 15 months [2].
[1]: https://en.wikipedia.org/wiki/Adoption_of_the_Gregorian_cale...
IMO, this list is only good at... wasting time. Except for the multiple statements (that could be one or two) that point out that there's not such a thing like "identical clocks" and "same time on two clocks".
The daylight savings time transition doesn’t “shorten” or “lengthen” the day, it merely transforms the clock. The day isn’t 25 hours or 23 hours. This is essentially the same thing as the Julian/Gregorian swap. The day didn’t really change, just the system we use to understand what day it is.
The span of time users experienced was weird, but this wasn’t the unit of time being shorter or longer. It’s an artifact of the transition not anything happening to the time.
A lot of these falsehoods on the list can be side stepped by distinguishing between the dimensions and the facts about representing time.
Good Times.
As another commenter noted, the exception appears to be September 1752.
That's a fun example but whether it's worth worrying about is another question...
They used the Julian calendar until after the Revolution, so when reading accounts of, say, most of WW1, Russian sources have dates that are 13 days off from Western sources. This leads to much confusion when authors don’t make it clear they’ve converted the dates (or not).
Amusingly, one of the first casualties of this was the October Revolution, which in the new (Gregorian) calendar actually occurred on November 7th
So I guess its not really something that I need to worry about!
Right but if that's the case, what exactly can you do about it?
If you are creating, for instance, an idle game where the user can pay to skip time; that's a problem.
If you are doing cryptographic checks dependent on time, that's a big deal (eg: how do we handle when the client or service goes "wtf, no. That's the wrong time")
I can read and understand about clock drift, vector clocks etc.
But I sometimes struggle to align that with real world design and architecture.
An IoT device reported an event happened at t=1, but t is not accurate. Ok, so? What exactly can I do about that?
This statement is also true in isolation.
> days don't overlap
If you ever have the pleasure of working with the Jewish religious calendar, it defines day boundaries by sundown and rise of the first star, which are not simultaneous. This leads to a phase during which two days co-exist. And of course it's not continuous over the year and by location.
Yes, good. But not all applications need a “platonic ideal” understanding of time. Often when you type just the code you need, the system performs excellently, and the code is minimal.
I did not fix that bug. (But I did learn that the 'TZ' database has this information, though I think 'America/Indiana/*' had been pruned out of the copy our JVM was using.)
24hs before 15:00 is USUALLY 15:00. But in some timezones, it can be (about once a year): 14:00, 16:00 or 14:59:59.
It's currently Monday 11:02 here, but it's likely still Sunday in some parts of the world (or is it already Tuesday somewhere? Not sure which is right). So, right now "today" have no single meaning; it depends on where you are.
Oh, and does your online meeting repeat at 14hs CET every Monday? Then for people in Argentina it will be at 9hs for six months a year, and at 10hs for another six months (due to CET having DST, but not Argentina).
Also it is in use for 7 months not 6 months...
Hasn't failed me yet.
Here's why: https://www.nist.gov/sites/default/files/images/2019/12/23/w...
This looks useful. I haven't checked for full accuracy: https://www.timeanddate.com/time/map/
Isn't leap year calculation one of the very first things you do in most programming tutorials/schools? I know that a lot of people don't know this, but most programmers should, r-r-r-right?
Handling time and dates correctly has a similar difficulty to writing your own cryptographic primitives: If you don't know exactly what you are doing you will shoot yourself (and potentially countless others) into the foot at one in point or another.
I find this simplified date/time very useful, unless you have to manage “continuous and/or real” time somehow. 99% of applications are okay with it, because they’re facing users with exactly the same mental model. Also, albeit not correct scientifically, it reflects many developers’ mental model as well. This is much better than a model that just doesn’t match, which is a world of pain. Someone adds 86400 but it’s the same day, good luck debugging it.
I don’t think this is a cryptographic-level issue.
Anyway if you queried something to get the current date-time and clock-time, you could be farming out the annoying edge cases to some arbitrarily complicated library, right? Which is the right way to do things.
Unless you work all day on time-related software, you'll probably never encounter most of these quirks.
Humans don't write in BNF. We expect, rightly or wrongly, for other humans to use Postel's law to interpret what we mean.
Computerphile managed a much better title[1]: The Problem with Time & Timezones
A "(for programmers)" could be appended if needed.
But of course what happens is the outliers have to deal with these systems that treat them as bad data possessing impossible properties and then the curse and say hey these stupid programmers don't realize that the world is not just like X1 or Y1, but that us rare instances of X2 and Y2 also exist!
And then an expert with sufficient knowledge about all the outliers compiles a list entitled Falsehoods Programmers believe about {X}.
Average programmer who hasn't done anything datetime-specific: unlikely.
me: programmers are less likely to believe this stuff than non-programmers
you: no, they are not
me: programmers are conscious that time is more complex than it seems to be, therefore they avoid holding simple beliefs regarding it
I would've presumed this one - for the Gregorian calendar, at least. What are some counterexamples?
https://en.m.wikipedia.org/wiki/Calendar_(New_Style)_Act_175...
IIRC, that event is the reason SQLServer's datetime type is only good back to 1753, and thus why you should use datetime2 for dealing with older historical dates:
https://database.guide/datetime-vs-datetime2-in-sql-server-w...
Which Outlook in particular seems to get direly wrong. I have lost count of the number of times I have been sent an email from someone using Outlook containing a supposed calendar event in summer which declares that it is at a particular time GMT. It's wrong, and if I were to turn up at the time it stated, I would be an hour late.
https://github.com/evansiroky/timezone-boundary-builder
In principle a calendar program could use its output to perform GIS lookups of locations then use the tzinfo DB to get the correct timezone at the given location and specified time.
Even the most inexperienced developers I’ve worked with are well aware that time, and timezones in particular, are really difficult.
I’ve yet to meet anyone that has suggested using anything other than a battle-hardened standard library for time.
Does any programmer believe ALL these falsehoods? Not very likely.
Do most programmers believe AT LEAST ONE of these falsehoods? Likely.
> I’ve yet to meet anyone that has suggested using anything other than a battle-hardened standard library for time.
Many stdlibs still don't account for the most edge of corner cases -- or make it very easy to screw up anyway.
And you also need to understand your timing requirements.
If all you care about is recording a date on an invoice, you really don’t need to worry about leap seconds or smearing or whatever.
Such as storing location + date + time, because that should be unambiguous, right? Or confusing "same time tomorrow" with now + 24h. Are you even sure which one you need?
Any examples of when you need "now + 24h" instead of same time tomorrow?
For example, daylight savings may start the next day, and time will be adjusted... And everything will be done 1 hour earlier than today despite the hour on the clock being "same time" as today, so what? Other than your body needing to readjust the sleep cycles, noone else seems to actually care.
Meanwhile, when I setup cron to do something daily, I don't care about this at all, so what if on one day, the interval will be 23 or 25 hours?
At my previous job matching datapoints on timestamp was crucial, so we did a lot of fun things with time. Leap seconds cost us 3 months of testing.
https://engineering.fb.com/2022/07/25/production-engineering...
Falsehoods Programmers Believe About Names https://news.ycombinator.com/item?id=1438472
Is this referring to leap seconds or what do the mean?
Data aquisition instrumentation needs to use a lapsed epoch (to avoid UTC leap seconds) with a calibration at start and end of projects to adjust for drift, etc.