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
Slide 5
Slide 5 text
Approach 1
Everything is local
Slide 6
Slide 6 text
Everything is local
2018-11-06T09:05:23
Slide 7
Slide 7 text
Everything is local
Pro: super easy, no thought/effort
Con: What if you have users in a different time zone?
Slide 8
Slide 8 text
Approach 2
Local plus time zone offset
Slide 9
Slide 9 text
Local plus offset
2018-11-06T09:05:23-06:00
Slide 10
Slide 10 text
Local plus offset
Pro: can convert to other time zones
Con: Not consistent, lots of tz values
Slide 11
Slide 11 text
Approach 3
Always store UTC
Slide 12
Slide 12 text
Always store UTC
2018-11-06T15:05:23Z
2018-11-06T15:05:23+00:00
Slide 13
Slide 13 text
Always store UTC
Pro: able to convert, consistent
Con: ?? Is there an unsolved problem?
Slide 14
Slide 14 text
Problem
Politicians can break your code
Slide 15
Slide 15 text
No content
Slide 16
Slide 16 text
What if the time zone
rules change?
Slide 17
Slide 17 text
https://www.timeanddate.com/news/time/
Slide 18
Slide 18 text
https://www.timeanddate.com/news/time/
Slide 19
Slide 19 text
Approach 4
Future dates as wall time + tz name
Slide 20
Slide 20 text
Future as wall + tz name
2019-11-06T12:00:00
America/Sao_Paulo
Slide 21
Slide 21 text
Future as wall + tz name
Pro: TZ rules can change
Con: New time zones? God help you