I built a small Christmas side project this year: an online advent calendar that friends fill. You create a calendar, share one link, and each friend hides a note, photo, song or voice message behind one of 24 doors. The owner opens one door a day until Christmas Eve.
The rule that sounds trivial is "door 9 opens on December 9". The question is: December 9 where ? The friends filling the doors are in different countries, the server runs on Cloudflare's edge in whatever data centre is closest, and the person opening the doors expects their own midnight. Here's how that ended up working, with no date library at all.
Store the owner's time zone, not an offset
When a calendar is created, the browser sends its IANA time zone:
let tz = "UTC" ; try { tz = Intl . DateTimeFormat ( ) . resolvedOptions ( ) . timeZone ; } catch ( e ) { } // "Europe/London" await fetch ( "/api/calendars" , { method : "POST" , headers : { "content-type" : "application/json" } , body : JSON .…