DEV Community

Discussion on: 3 simple rules for effectively handling dates and timezones

Collapse
 
atdotde profile image
Robert C. Helling

I think you should have mentioned rule #0: Don't try to hack it yourself, use a library. There are far too many traps to fall into, like "in two days" is the same as "in 48 hours" but could as well be 47 or 49 hours.

And to complicate things there is also what I would call "subjective time" as I had to learn when contributing to Subsurface, a scuba diving log: Divers often do their dives at holiday destinations with time zones different from their home. They want to log things like "I did a dive at 2 p.m.". That is obviously in the time zone of the dive site. But it should still be "2 p.m." when they look at their log at home even when this is in a different time zone. This sounds like one could ignore time zones all together but unfortunately there are other relevant times that should be time zone aware like the above "let's check again for updates in two days" or when interacting with other devices like dive computers or cameras to match pictures takes to the dives in the log. In short: it's a pain!