All software dev, all the time. R38Y = R&Y = RANDY.

How to Save Future Times

I deal a lot with time and time zones in the software I develop, and thankfully most frameworks make it pretty easy to manage. The rule tends to be, convert and store everything in UTC, and display it in the user's time zone in the UI, and call it a day.

In Pasito, the user selects the date and time of an event, Pasito detects the time zone from the browser, and converts it to UTC in the database. Since we have the time zone saved, Pasito can convert it back to the proper local time in the browser and the calendar feed. Done.

There are a couple problems with this:

  1. What if I'm in Denver looking for events to go to in Philly? The event is at 7 PM, but I'm seeing 5 PM in my browser in Denver, and might enter the wrong time in my calendar.
  2. What if the rules around when daylight savings time changes between when the event was created and when it happens? Suddenly that 7 PM turns into 6 PM without any change to the event in the database.

Pasito already does #1 correctly by using the time zone saved with the event instead of adjusting the display in the browser with the browser's current time zone, but #2 is still a problem.

To solve it, I need to start storing:

  1. The clock time (what the user meant locally) to show in the browser
  2. Time zone of the location of the event, and
  3. The UTC time to use programmatically.

When the timezone rules change, I need to update the UTC timestamp accordingly. It's kind of a pain, but I take accurate information seriously in Pasito and I don't want someone showing up to an event at the wrong time.

Thanks to this article by Lau Taarnskov for the solution to the problem.