Live data from Hacker News

Insane complexity of calendrically correct date and time operations

yourcalendricalfallacyis.com

41–50 of 146 posts

Re: Insane complexity of calendrically correct date and time operations

#42
This is actually a lot simpler than it looks. There are two concepts.

Calendars almost never have crazy holes in the middle of them. When you say "I'm in Chicago", you pretty much can schedule an appointment at 1 or 2pm on "Sunday" or "9/20" or "next Wednesday" and everybody knows when that will happen. Leap years cause a little bit of trouble.

Where it gets tricky is when you have to interact with wall clock times, say, calculating the number of hours until your calendar event happens, or looking for all the events in a given range of wall clock dates. This is the world of timestamps, offsets, and "the global timeline" that everyone in the world experiences together.

Calendars also don't really care about daylight saving time.

If you keep these two separate and are specific about which you're dealing with, 90% of this goes away. Separate calendar from arithmetic/wall clock times. Not all will disappear, but a surprisingly large amount.

Source: working on https://www.interval.org/ and using the excellent NodaTime library. Thank you, Jon Skeet.

Re: Insane complexity of calendrically correct date and time operations

#43

Imagine we did not have names for months and days. Would you call the tenth month October or December? It does not make sense. Then, the other months at the start of the calendar, would you name them after phases of a military campaign of preparation for war, conquering, looting and pillaging? Would that be deemed politically correct? On the weekday names we are not doing any better. Tuesday - named after the god of…

simple: call them by their ordinal/cardinal names. that's what east asian calendars do. october is "month ten"

https://en.wikipedia.org/wiki/Japanese_calendar#Months

https://en.wikipedia.org/wiki/Names_of_the_days_of_the_week#...

Re: Insane complexity of calendrically correct date and time operations

#44
post #4
post #2

Is it true that Unix time is as simple as it seems? Is there exactly one second between adjacent integers? Do all Unix time values occur only once simultaneously around the world?

What you want is probably TAI [1], Unix Time has leap seconds. [1] https://en.wikipedia.org/wiki/International_Atomic_Time

Thanks! That's what I was looking for.

Re: Insane complexity of calendrically correct date and time operations

#46
post #15

What surprised me the most on that list was the the Unix epoch is December 31, 1969 in Los Angeles.

Don't let that answer confuse you. It seems to be phrased in an intentionally confusing way, but it's really only talking about time zones. At midnight 1970-01-01 UTC, Los Angeles, North America, and roughly half of the world still had their calendars on the previous day, because they have a negative time zone offset (Los Angeles was UTC-8:00).

Re: Insane complexity of calendrically correct date and time operations

#47

The leap second has a history of breaking computers. Pretty much every Linux server running Java broke in 2012, for example. 2009 saw a bunch of Linux kernels crashing in logging code. 2016 was mostly better except for Cloudflare: their systems had an assumption time never runs backwards. https://blog.cloudflare.com/how-and-why-the-leap-second-affe...

There's now "Google time".[1] This handles by leap seconds by making each second slightly longer, starting 12 hours before the leap second and ending 12 hours after it.

[1] https://developers.google.com/time/smear

Re: Insane complexity of calendrically correct date and time operations

#48

This is actually a lot simpler than it looks. There are two concepts. Calendars almost never have crazy holes in the middle of them. When you say "I'm in Chicago", you pretty much can schedule an appointment at 1 or 2pm on "Sunday" or "9/20" or "next Wednesday" and everybody knows when that will happen. Leap years cause a little bit of trouble. Where it gets tricky is when you have to interact with wall clock times,…

> Calendars almost never have crazy holes in the middle of them.

The comment right above yours at the moment talks about effectively that very problem (in this case, an unforeseen date moving a calendar back a day).

https://news.ycombinator.com/item?id=18036403

Re: Insane complexity of calendrically correct date and time operations

#50
post #43

Imagine we did not have names for months and days. Would you call the tenth month October or December? It does not make sense. Then, the other months at the start of the calendar, would you name them after phases of a military campaign of preparation for war, conquering, looting and pillaging? Would that be deemed politically correct? On the weekday names we are not doing any better. Tuesday - named after the god of…

simple: call them by their ordinal/cardinal names. that's what east asian calendars do. october is "month ten" https://en.wikipedia.org/wiki/Japanese_calendar#Months https://en.wikipedia.org/wiki/Names_of_the_days_of_the_week#...

That's what we did in latin! October is month 8! And then some dude messed it up.
Post reply on HN