jekyll-theme-conference
jekyll-theme-conference copied to clipboard
Set program initial day based on local TZ, not UTC
Problem: When using this theme over here in the America/Los_Angeles
time zone (GMT-8 / GMT-9), for a 2-day event, during the event on the first day, the program page defaulted to showing the 2nd day. And on the 2nd day of the event, the program went back to showing the 1st day.
Tracing the problem down, it looks like the JS Date API doesn't provide good functions for converting between UTC and local time zones well. The code in program.js
was taking the user's days' strings, which are representing local time zone days, instantiating a Date
in JS (which only creates a UTC time zone date), and then compares the day part to the user's JS runtime's current Date instance's day part.
This issue probably doesn't manifest for people whose time zone is close enough to GMT / UTC.
Solution:
Treat the user provided day string from the program as the day in the local time zone. Construct an analogous string in the user's JS runtime and then do string comparison. This works around JS's lack of time zone support in the Date API to compare 2 "local dates" (dates that are not representing an absolute time pinned to the UTC time zone).