Wikis & learning

Pick a daily puzzle across timezones

Choose a single timezone if all visitors should share a puzzle at the same instant. If visitors should switch at local midnight, keep a validated IANA timezone in the account and calculate the date in that zone.

Question

Pick a daily puzzle across timezones

Editorial answer

Choose a single timezone if all visitors should share a puzzle at the same instant. If visitors should switch at local midnight, keep a validated IANA timezone in the account and calculate the date in that zone.

Derive a calendar key on the server and use that key to look up a persisted puzzle. Enforce uniqueness on the combination of puzzle series and date. Initialize that row once, then return its existing ID to all concurrent requests.

Verify the result

Test the same instant in Tokyo and Los Angeles, both sides of midnight, and a daylight-saving transition. Adding 86,400 seconds to local midnight does not always locate the next local midnight.

Discussion

Sign in to participate.