Live data from Hacker News

Falsehoods programmers believe about time

infiniteundo.com

171–180 of 212 posts

Re: Falsehoods programmers believe about time

#171
post #153

Time would be much less of a problem if Terrestrial Time was used internally everywhere. That is: if TT (realized as TAI) were used as the fundamental definition of time, rather than UTC; and UTC were treated as just another timezone. 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…

[deleted]

Re: Falsehoods programmers believe about time

#172

I've just learned to do time conversions by converting from the target timezone to UST, then from UST, to the recipient timezone. 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/

[deleted]

Re: Falsehoods programmers believe about time

#173

When I start at a new company, it's always interesting to see how they handle dates and times. 1) Company A stores timestamps in a mysql database, no timezone, but implicitly on US pacific time. The system timezones are all on pacific. Many weird bugs around DST transitions. 2) Company B stores timestamps in a database as Unix timestamps (ints) Tons of code converting back and forth between ints. Code was a mess. 3)…

> Tons of code converting back and forth between ints. Code was a mess. 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?

The code was a mess for other reasons beyond the int/timestamp conversions. In some places it was stored as milliseconds, other places seconds. It was python 2 if it matters.

Re: Falsehoods programmers believe about time

#174

> A week (or a month) always begins and ends in the same year 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?

Depends on your calendar! 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…

"Falsehoods programmers believe about X" articles inevitably become a discussion about niche anthropology facts.

No programmer has ever cared about Lady Day when writing a program. And if they did, by definition, they would understand it's significance.

Re: Falsehoods programmers believe about time

#175

Obviously nobody believes most of these falsehoods. Presumably the op means a lot of programmers create bugs that seem t imply programmers believe these falsehoods. 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.

Agreed on all counts. The “falsehoods programmers believe about X” articles are cautionary lists of edge cases to think about, with an unfortunately aggressive naming scheme.

They should really call these lists "Incorrect assumptions programmers make about X" or: "Test cases programmers should test their software against"

Re: Falsehoods programmers believe about time

#176

Earlier quoted context omitted.

Depends on your calendar! 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…

"Falsehoods programmers believe about X" articles inevitably become a discussion about niche anthropology facts. No programmer has ever cared about Lady Day when writing a program. And if they did, by definition, they would understand it's significance.

The point of these "falsehoods" threads is that programmers may not care about these niche anthropology facts, but users may care a lot.

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.

Re: Falsehoods programmers believe about time

#177
post #133

The "opportunity for bugs" I didn't realize until I was over 10 years into my professional career: 10 AM 11 AM 12 PM 01 PM 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 chan…

am/pm users have lost their sanity.

I m surprised it’s not 7 inch past 12

Re: Falsehoods programmers believe about time

#178
post #52

In the U.S. falling back to standard time from daylight saving time is rough. Those days have 25 hours - and the interval from 1:00 - 2:00 repeats (you reach 2:00 and fallback to 1:00 and repeat the interval). Makes power scheduling difficult - which 1:00 - 2:00 interval are you talking about? Also, the offsets between the timezones change. Eastern Daylight Time falls back from 2:00 to 1:00 Eastern Standard Time, whi…

One of the interesting time-related applications I worked on was involved with medicines management. If a patient was to receive a medicine around the daylight savings change over we had to make sure it wasn't either doubled-up or missed completely.

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.

Re: Falsehoods programmers believe about time

#179

The "opportunity for bugs" I didn't realize until I was over 10 years into my professional career: 10 AM 11 AM 12 PM 01 PM 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 chan…

> Align those two cycles

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.

Re: Falsehoods programmers believe about time

#180

Earlier quoted context omitted.

bye bye Halloween...

On the other hand we'll have a whole 13'th month, which will afford us many bonus Fridays the thirteenth.

Depends, each month has exactly 28 days. So you either never get a Friday the 13th, or you get one every four weeks.
Post reply on HN