Storing UTC is not a silver bullet (2019)
Storing events in UTC is a common practice, but Jon Skeet's blog challenges this notion due to EU time zone rule changes. Options include permanent UTC storage, UTC conversion with adjustments, and preserving local time while deriving UTC for convenience. The blog stresses the complexity of handling time zone data in applications, advocating for a strategy that prioritizes local time preservation with UTC for ordering and countdown.
Read original articleStoring UTC is a common recommendation to avoid time zone issues, but Jon Skeet's blog provides a counterpoint, highlighting that it's not always the best approach. The post discusses the impact of EU time zone rule changes on applications and presents different implementation options using a conference organizer scenario. Option 1 suggests storing events in UTC permanently, leading to countdown discrepancies. Option 2 proposes converting to UTC immediately but adjusting after rule changes, requiring additional fields for time zone rules. Option 3, the preferred choice, involves preserving local time and deriving UTC for convenience, maintaining the original event time while updating the UTC representation when needed. The blog emphasizes the importance of considering time zone rule changes and the complexity of handling multiple versions of time zone data in applications, especially in platforms like C#. It concludes by advocating for a strategy that prioritizes preserving local time while using UTC as derived data for ordering and countdown purposes.
Related
Y292B Bug
The Y292B bug is a potential timekeeping issue in Unix systems due to a rollover in the year 292,277,026,596. Solutions involve using dynamic languages or GNU Multiple Precision Arithmetic Library in C, emphasizing the need for kernel-level fixes.
All I want for Christmas is a negative leap second
The author explores leap seconds, discussing the potential for a negative leap second due to Earth's rotation changes. They argue against abolishing leap seconds, emphasizing the rarity and complexity of a negative leap second.
Let's stop counting centuries
Count centuries as "the 1700s" for clarity, addressing confusion with decades. Language evolution and adapting conventions are crucial. Emphasizes easy language evolution and practical time period references.
Time Travel with Python
The blog post discusses testing time-based functionality in software development, emphasizing the importance of accurate time-based tests for applications across time zones and daylight-saving changes. It introduces Python testing methods using unittest.mock and Freezegun for robust time manipulation.
Timezone-naive datetimes are one of the most dangerous objects in Python
Date and time handling in Python can be tricky, especially with timezones and epoch timestamps. Not specifying a timezone when using `datetime.datetime.fromtimestamp()` can lead to errors. It's crucial to attach timezones to datetime objects for accuracy.
The moment in time case is pretty straightforward. The moment in a calendar case can get horribly complex because calendars are... very human constructs, and there are challenges capturing the entirety of human intent (did you mean for the position on the calendar to remain fixed even if the calendar changes? what about leap seconds? etc.), because often humans aren't even sure about their intent.
It’s worth noting that this did not end up happening. Maybe a 2019 tag could be added to the title?
The remaining edge cases are future events that span different time zones (e.g. scheduled calls with participants from different TZs). If one of the timezone rules chances, this can only really be resolved by rescheduling and updating the info for the participants.
Just by reading some of his answers on SO, or by reading his C# in depth book, or his talks and blogs, I learned how you can think of scenarios where a design falls short, and to think of pros and cons rather than right and wrong. He has a clear mind on things, and a very direct style of writing.
You can replace UTC with US dollars and Amsterdam time with euros and talk about conference prices. If you convert 100 euro to US dollars at the time of record creation, the price at the day may not be 100 euros anymore.
Ideally you record a tuple that allows to define value unambiguously (e.g. time 2022-02-21 9:00 timezone Europe/Amsterdam) because in this case you can always resolve the absolute time value later.
This is a typical hiccup for any business expanding into multiple locations with different parameters (time zones, currencies, units etc).
Once case that I find particularly interesting is an event that happens in different locations at the same logical (but different absolute time). Let's say you want to send an email to all your users across the global on Monday 9:00. If you want to add up to complexity, you could think about sending an email to all your users across the globe on the first working day next week.
Unfortunately many implementations simply store the UTC timestamp and throw away any time zone information (e.g. postgres TIMESTAMP WITH TIME ZONE, despite the misleading name). There are two ways around it: store the user's current time zone in another field, or record it in something like ISO8601 as local time with offset (although this only records the offset, not the IANA time zone). Both options have pros and cons.
I wish implementations supported the basic tuple of (timestamp, timezone) where timestamp is a Unix-style timestamp (a number). The timezone can be ignored when it isn't needed, but is always there when it is. The difficulty is how to store the timezone and I'm sure there are numerous other issues with this.
Is there any library that can translate utc to local time where it addresses time offset changes based on the knowing the utc when the future time was decided upon?
After all, if I schedule a weekly recurring video call at 9:00 in City A, aka 14:00 in City B, then daylight savings starts in City A but not City B then either the meeting shifts to 13:00 in City B, or to 10:00 in City A.
No amount of clever date representation can sidestep the fact that the meeting has moved by an hour for some attendees but not others.
1. Events that are socially bound to a context, and capturing that contract or triggering rules, e.g. "Whenever the nation of Ruritania declares March 3rd end of workday".
2. Events that occur a fixed and knowable internal from "now."
It is complicated further by the fact that many users won't really be aware of their own varying different intentions.
The issue is that they keep enacting laws that have good intentions, but are written poorly and without any sort of experience in the technical realm. This results in the laws' implementation being filled with weird loopholes that you can use to get around the extra work while still maintaining the legality, but completely missing the intention of the law in the first place. It just seems like a massive waste of time to me.
Related
Y292B Bug
The Y292B bug is a potential timekeeping issue in Unix systems due to a rollover in the year 292,277,026,596. Solutions involve using dynamic languages or GNU Multiple Precision Arithmetic Library in C, emphasizing the need for kernel-level fixes.
All I want for Christmas is a negative leap second
The author explores leap seconds, discussing the potential for a negative leap second due to Earth's rotation changes. They argue against abolishing leap seconds, emphasizing the rarity and complexity of a negative leap second.
Let's stop counting centuries
Count centuries as "the 1700s" for clarity, addressing confusion with decades. Language evolution and adapting conventions are crucial. Emphasizes easy language evolution and practical time period references.
Time Travel with Python
The blog post discusses testing time-based functionality in software development, emphasizing the importance of accurate time-based tests for applications across time zones and daylight-saving changes. It introduces Python testing methods using unittest.mock and Freezegun for robust time manipulation.
Timezone-naive datetimes are one of the most dangerous objects in Python
Date and time handling in Python can be tricky, especially with timezones and epoch timestamps. Not specifying a timezone when using `datetime.datetime.fromtimestamp()` can lead to errors. It's crucial to attach timezones to datetime objects for accuracy.