In elixir need some suggestions on handling daylight savings time without having to take systems down
Especially for medication administration for patients where time given is extremely important.
Have a Ghost hour 01:00 - 02:00 for fall back.
convert any datetime to UTC at the system boundaries, as close to the user as possible
in business parts of the application deal with UTC exclusively
in database, store UTC only
convert to local timezone when giving output to the user
There should be no issues with timezones. The new DateTime struct includes timezone, and libraries like calendar can help you with conversions. Ecto since 2.1 (currently in rc) supports native elixir calendar types and offers a utc_datetime type, that expects database to store the time in UTC and gives you the DateTime structs in UTC timezone.
I cannot overstate how important it is to be using a time format in your storage that is agnostic to all that, like UTC or unixtime or so. You should never absolutely ever be thinking about something like daylight savings time or anything of the sort unless you are converting the internal backend format to a user-displayable value, ever. I’ve personally in my 20 years doing this never seen a system that stores anything else that behaves well…
Yeah I agree. I’m quite honestly kind of confused why daylights savings time would require taking any system down at all ever, maybe someone can explain the motivation here?