4 ms·
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 Chica
by eldavido 8y ago
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/ https://www.interval.org/ and using the excellent NodaTime library. Thank you, Jon Skeet.
- macintux 8y ago> 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 https://news.ycombinator.com/item?id=18036403