Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How to Save Time

How to Save Time

This isn't a productivity talk. It's a survey of some idiosyncrasies related to persisting date/time values to a database.

Joel Clermont

November 07, 2018

More Decks by Joel Clermont

Other Decks in Technology


 How to Save Time Joel Clermont

  2. Productivity

  3. ISO8601

  4. Date time values are tricky • Date math • Leap

    years/seconds • Daylight Saving Time • Time Zones • Many more . . . https://infiniteundo.com/post/25326999628/falsehoods- programmers-believe-about-time
  5. Approach 1 Everything is local

  6. Everything is local 2018-11-06T09:05:23

  7. Everything is local Pro: super easy, no thought/effort Con: What

    if you have users in a different time zone?
  8. Approach 2 Local plus time zone offset

  9. Local plus offset 2018-11-06T09:05:23-06:00

  10. Local plus offset Pro: can convert to other time zones

    Con: Not consistent, lots of tz values
  11. Approach 3 Always store UTC

  12. Always store UTC 2018-11-06T15:05:23Z 2018-11-06T15:05:23+00:00

  13. Always store UTC Pro: able to convert, consistent Con: ??

    Is there an unsolved problem?
  14. Problem Politicians can break your code

  15. None
  16. What if the time zone rules change?

  17. https://www.timeanddate.com/news/time/

  18. https://www.timeanddate.com/news/time/

  19. Approach 4 Future dates as wall time + tz name

  20. Future as wall + tz name 2019-11-06T12:00:00 America/Sao_Paulo

  21. Future as wall + tz name Pro: TZ rules can

    change Con: New time zones? God help you
  22. Questions? @jclermont

  23. Thank you! @jclermont