I wrote a thing about "Storing time for human events" - how if you're building an events website used by actual human beings the standard advice of "convert times to UTC and just store that" isn't actually the best approach
https://simonwillison.net/2024/Nov/27/storing-times-for-human-events/
https://simonwillison.net/2024/Nov/27/storing-times-for-human-events/
Comments
The “exact instant when this occurs relative to other events” is a secondary concern and can be derived as UTC when necessary.
• uncertain or approximate dates, or dates with portions unspecified;
• extended time intervals;
• divisions of a year;
• sets and choices of calendar dates;
• grouped time scale units;
1/2
• date and time arithmetic.
I have a personal project that would really benefit from an implementation... although I'm sure I'll go absolutely insane.
2/2
The main concern was having graphing working across DST changes so we graphed in UTC and created graph ticks based on display time.
Those users (in SE Asia) had their phones set to use the Buddhist calendar; we were using the "local" calendar API in iOS. Events were created just fine, but 543 years in the future!
So all you need to do is serialize your time and all relevant bits are captured automatically via RFC 9557. As long as you're using Jiff's Zoned type, you can't mess up!
I was thinking more broadly of how to store future and past date times as I recently had to make this decision on multiple occasions and it gets annoying.