Time

 Time

A talk about how to handle time and timezones. Given at Twente.rb

B012094b37ab6946c44eaa41d7828478?s=128

Dirkjan Bussink

February 10, 2015
Tweet

Transcript

  1. Time Dirkjan Bussink! @dbussink

  2. Time is hard

  3. None
  4. None
  5. None
  6. None
  7. None
  8. Basics

  9. None
  10. Timezones

  11. http://momentjs.com/

  12. http://momentjs.com/

  13. Storing

  14. UTC

  15. Why?

  16. 2014-10-26 02:34

  17. A bit more! complicated

  18. Group! by date

  19. None
  20. Who’s date?

  21. http://pellepim.bitbucket.org/jstz/

  22. None
  23. None
  24. Calculations

  25. None
  26. Perspective

  27. None
  28. UTC loses data

  29. UTC + offset

  30. 2014-08-19 16:12:50 +0200

  31. Time as a feature

  32. Calendars

  33. None
  34. None
  35. DST

  36. amsterdam = ActiveSupport::TimeZone["Europe/Amsterdam"] time = amsterdam.parse("2014-08-19 17:15") => Tue, 19

    Aug 2014 17:15:00 CEST +02:00
  37. sydney = ActiveSupport::TimeZone[“Australia/Sydney"] ! time => Tue, 19 Aug 2014

    17:15:00 CEST +02:00 time.in_time_zone(sydney) => Wed, 20 Aug 2014 01:15:00 EST +10:00
  38. later = time + 6.months => Thu, 19 Feb 2015

    17:15:00 CET +01:00 ! later.in_time_zone(sydney) => Fri, 20 Feb 2015 03:15:00 EST +11:00
  39. Our recurring meeting! just moved 2 hours!

  40. UTC + offset! isn’t good enough

  41. Time & time zone Europe/Amsterdam Tue, 19 Aug 2014 17:15:00

    CEST +02:00
  42. Time tracking

  43. Check in & check out

  44. 125% 22:00 00:00 150% Break 150% 01:00 01:30 06:00

  45. DST

  46. 125% 150% Break 150% 01:30 02:00 02:59 02:00 03:00

  47. 9 hours from 22:00 until 06:00

  48. Very specific! storage format

  49. Day!! ! ! ! ! ! ! 2014-10-26! Start!! !

    ! ! ! ! 79200!! ! ! End!! ! ! ! ! ! ! 108000! Duration!! ! 32400
  50. Take away

  51. Start with UTC

  52. Be careful! with timezones

  53. Make conscious! decisions