How does NodaTime handle future dates if our Government changes the DLS start times?

If I use NodaTime to convert a future date and time to UTC, it uses the Offset of that future date (as known from the global offset database), what happens if suddenly that future offset for a particular Timezone changes because of a Govt change or State referendum changes it (like might happen in QLD and SA in Australia)? Now all my future dates would be out by whatever change they make... It seems unlikely but it is still a valid scenario to think about...

Jon Skeet
people
quotationmark

Firstly, you would need to update the data in order to know about the change, and obtain an appropriate IDateTimeZoneProvider in your code. Instructions for that are in the user guide but we hope to make it simpler in the future. In particular:

  • We already build and publish new data files when IANA publishes a new release of the source data
  • We expect to create a Nuget package which can also be updated on each new source data release; this would allow users who have regular deployments to pick up the latest one on each build, leaving a relatively small time window where it's out of date
  • We may provide the building blocks for you to make your app poll and self-update in some form
  • We're very likely to host the files on a CDN rather than just on the Noda Time web site as it currently is

So that's the matter of getting the new data. How you use it is another matter. If you have stored UTC in your database, you will end up getting a different local time when you later apply the new time zone data to the same timestamps. If that's not what you want to happen - if your app deals with users scheduling events in local time - then you should be storing local time and the time zone, so that a change to the time zone data means a change to the instant in time when the event happens, rather than a change to the local time at which it happens. Of course, you then need to consider what happens if someone scheduled an event at a local time which was going to exist, but later turned out to be a "skipped time" where the clocks are adjusted past it. Noda Time can't make those choices for you, but it does allow you to express your decision reasonably easily with a ZoneLocalMappingResolver delegate, possibly created or obtained via the Resolvers class.

people

See more on this question at Stackoverflow