A talk about how to handle time and timezones. Given at Twente.rb
TimeDirkjan Bussink!@dbussink
View Slide
Time is hard
Basics
Timezones
http://momentjs.com/
Storing
UTC
Why?
2014-10-26 02:34
A bit more!complicated
Group!by date
Who’s date?
http://pellepim.bitbucket.org/jstz/
Calculations
Perspective
UTC loses data
UTC + offset
2014-08-19 16:12:50 +0200
Time as a feature
Calendars
DST
amsterdam = ActiveSupport::TimeZone["Europe/Amsterdam"]time = amsterdam.parse("2014-08-19 17:15")=> Tue, 19 Aug 2014 17:15:00 CEST +02:00
sydney = ActiveSupport::TimeZone[“Australia/Sydney"]!time=> Tue, 19 Aug 2014 17:15:00 CEST +02:00time.in_time_zone(sydney)=> Wed, 20 Aug 2014 01:15:00 EST +10:00
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
Our recurring meeting!just moved 2 hours!
UTC + offset!isn’t good enough
Time & time zoneEurope/AmsterdamTue, 19 Aug 2014 17:15:00 CEST +02:00
Time tracking
Check in & check out
125%22:00 00:00150% Break 150%01:00 01:30 06:00
125% 150% Break 150%01:30 02:00 02:5902:0003:00
9 hours from 22:00 until 06:00
Very specific!storage format
Day!! ! ! ! ! ! ! 2014-10-26!Start!! ! ! ! ! ! 79200!! ! !End!! ! ! ! ! ! ! 108000!Duration!! ! 32400
Take away
Start with UTC
Be careful!with timezones
Make conscious!decisions