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

The programmers guide to timestamps and timezon...

The programmers guide to timestamps and timezones - PyCon India 2023

Shrayas Rajagopal

October 02, 2023
Tweet

More Decks by Shrayas Rajagopal

Other Decks in Programming

Transcript

  1. 👀 󰑑 👀 󰑜 👀 󰎲 September 17th 11:15AM September

    17th 4:15PM September 17th 12:15PM 󰏝 September 17th 2:45PM
  2. 👀 󰑑 👀 󰑜 👀 󰎲 September 17th 11:15AM September

    17th 4:15PM September 17th 12:15PM 󰏝 September 17th 2:45PM Wall Time
  3. A group of places, that observes the same time on

    their watches, for any given instant.
  4. 👀 󰑑 👀 󰑜 👀 󰎲 September 17th 11:15AM Europe/Berlin

    September 17th 4:15PM Asia/Ho Chi Minh September 17th 12:15PM Africa/Dar es Salaam 󰏝 September 17th 2:45PM Asia/Kolkata
  5. Europe/Berlin September 17th 11:15AM Asia/Ho Chi Minh September 17th 4:15PM

    Africa/Dar es Salaam September 17th 12:15PM Asia/Kolkata September 17th 2:45PM 󰏝 󰑑 󰑜 󰎲 September 17th 2023 9:15AM
  6. September 17th 2023 9:15AM Europe/Berlin September 17th 11:15AM (+2) Asia/Ho

    Chi Minh September 17th 4:15PM (+7) Africa/Dar es Salaam September 17th 12:15PM (+3) Asia/Kolkata September 17th 2:45PM (+05:30) 󰏝 󰑑 󰑜 󰎲
  7. September 17th 2023 9:15AM (+0) Europe/Berlin September 17th 11:15AM (+2)

    Asia/Ho Chi Minh September 17th 4:15PM (+7) Africa/Dar es Salaam September 17th 12:15PM (+3) Asia/Kolkata September 17th 2:45PM (+05:30) 󰏝 󰑑 󰑜 󰎲
  8. On 26th of March, Just as the local time reaches

    2:00AM, move the clock forward to 3:00AM Europe/Berlin +02:00 -> +01:00
  9. On 29th of October, Just as the local time reaches

    3:00AM, move the clock backward to 2:00AM Europe/Berlin +01:00 -> +02:00
  10. THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS

    THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS
  11. THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS

    THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS THE CHAOS The Chaos
  12. NO

  13. The tzdb is a collaborative compilation of information about the

    world's time zones, primarily intended for use with computer programs and operating systems
  14. Heyy, what’s up? How are you? 2:45PM 󰏝 Bob Alice

    󰎲 󰐵 SERVER Heyy, what’s up? How are you? 11:15AM
  15. Title: Company All Hands Meeting Start: April 28th 2024 -

    01:00 PM 󰎺 󰐵 SERVER Send a reminder before the meeting
  16. Title: Company All Hands Meeting Start: April 28th 2024 -

    01:00 PM 󰎺 󰐵 SERVER Send a reminder before the meeting
  17. NOW

  18. NOW April 28th 2024, 01:00 PM Local Time (Africa/Cairo +3)

    April 28th 2024, 10:00 AM UTC +0 APPOINTMENT
  19. NOW APPOINTMENT Egypt to cancel DST and switch to the

    +2 time zone for the entire year of 2024 March 1st, 2024
  20. NOW April 28th 2024, 10:00 AM APPOINTMENT UTC +0 April

    28th 2024, 12:00 PM Local Time (Africa/Cairo +2)
  21. April 28th 2024, 01:00 PM Local Time (Africa/Cairo +3) April

    28th 2024, 12:00 PM Local Time (Africa/Cairo +2)
  22. April 28th 2024, 01:00 PM Local Time (Africa/Cairo +3) April

    28th 2024, 12:00 PM Local Time (Africa/Cairo +2)
  23. NOW APPOINTMENT Egypt to cancel DST and switch to the

    +2 time zone for the entire year of 2024 March 1st, 2024
  24. NOW APPOINTMENT Egypt to cancel DST and stay in the

    +2 time zone for the entire year of 2024 March 1st, 2024 RARE?
  25. 2013 9 2014 10 2015 7 2016 10 2017 3

    2018 9 2019 3 2020 6 2021 5 2022 7 2023 3 TZDB VERSIONS
  26. 2013 9 2014 10 2015 7 2016 10 2017 3

    2018 9 2019 3 2020 6 2021 5 2022 7 2023 3 TZDB VERSIONS AVERAGE 6 PER YEAR
  27. create table appointments ( ... title text, scheduled_at_local timestamp without

    time zone, scheduled_at_timezone text, scheduled_at_utc timestamp with time zone, ... );
  28. 1 Server OS sits in UTC time zone 2 Server

    communicates only in UTC 3 Store past-ish timestamps as UTC
  29. 1 Server OS sits in UTC time zone 2 Server

    communicates only in UTC 3 Store past-ish timestamps as UTC 4 Store future timestamps as wall time with time zone
  30. 1 Server OS sits in UTC time zone 2 Server

    communicates only in UTC 3 Store past-ish timestamps as UTC 4 Store future timestamps as wall time with time zone 5 Client stores UTC and converts to local time
  31. 1. Dates only? 2. Times only? 3. Both dates &

    times? 4. Microsecond precision? 5. Customers only in one time zone?
  32. 6. Limits on future datetimes? 7. Any customers from volatile

    time zones? 8. Current libraries in the stack 9. Channel for customer intimation