in reply to System for calculating timing of reminder messages?

Working with dates and times, especially calculating differences, is always extremely complicated and requires lots spaghetti code.

You have to deal with different time zones (that get re-defined all the time for political shenanigans), daylight "savings" times (different if you cross the equator, different in different countries and redefined for political shenanigans), different calendars altogether (julian, gregorian, japanese, china, north korea, ...) including different times of the year when the year number (or name) changes, leap days, leap seconds, etc...

Tom Scott has a video on YouTube called "The Problem with Time & Timezones" that goes into more details, but, basically, you have to pull in dozens of data files (in different formats, no less) that describe the current and past situations, do a whole lot of complicated parsing and calculations and then you get a result...

...that may not be correct if you schedule an event in the future, because by then a country might have decided to entirely skip a day and/or the IERS(*) might have released a new Bulletin C that adds a 61th second to a specified minute on the last day of March or June or September or December.

Edit: And, oh, if you calculate times from late 1793 to 1805 in France (for with the regions only somewhat match the current borders), please note that they used the French Republican calendar, with 12 months with 30 days each, plus 5 (or 6 in leap years) "extra" days, weeks were 10 days long. And each day had 10 hours with 100 minutes each, each with 100 seconds. And those seconds don't match up in length with the seconds you are probably used to.

Edit 2: Also keep in mind, when daylight savings time starts, the clocks go backwards (usually an hour, could be more, could be less), so usually the same hour repeats in the local time zone. You need to know which version of that hour is the correct one and send out the reminder notification accordingly...

Edit 3: As a side note, did you know that French (and other countries) railways used (past tense, maybe, hopefully) their own time zone(s)? Why French Railway Stations Delayed Their Clocks (& What Happened When They Did).


(*) IERS = International Earth Rotation and Reference Systems Service
PerlMonks XP is useless? Not anymore: XPD - Do more with your PerlMonks XP
Also check out my sisters artwork and my weekly webcomics
  • Comment on Re: System for calculating timing of reminder messages?