What to do when a city/state changes time zone?

36 views
Skip to first unread message

Cory

unread,
Sep 5, 2024, 4:13:45 PM9/5/24
to Noda Time
If this is covered in the manual, I missed it, sorry!  There are occasions where a city or state has by legislation changed their time zone (not sure if right term), from Eastern to Central or vice-versa.  

I'm working on a web application managing parking facilities, and I'm storing the time zone string in the db on my Facility table, and then I'm storing Instants in other tables in my SQL Server for events that correspond to an point on the time line such as when someone checked-in or bought something.  Now, since I'm using Instant for these things in concert with the time zone, I need to convert it to a LocalDateTime or a ZonedDateTime before showing it to the user.  

Let's assume there's a time zone border town, and I have a facility that currently uses "America/New_York, but after let's say Sept 21, 2024 at 3am they'll switch to "America/Chicago".  Since the normal way for me to convert these instants to a ZonedDateTime is to use the TZDB for those strings, if I change that field in my DB, won't it mess up the interpretation of those old Instants when I want to convert them?  Or will it not be a problem, so long as my TZDB has the info in it?  

What's a good way to handle this?  Should an updated time zone database have an entry for this city?  What if there isn't one?  How would I do it manually, let's assume they've gone rogue and didn't tell anybody but me (just as an exercise)?

Jon Skeet

unread,
Sep 6, 2024, 5:57:41 AM9/6/24
to noda...@googlegroups.com
In theory, places don't "change time zones" so much as there should be a time zone for any given place, which should cover the whole of history.
Whether that absolutely works in practice, I'm not sure - but it would be worth checking with any concrete examples of the scenario that you're concerned about before embarking on any complex schemes. But if it does become a problem for you, you could have a table with "facility code, time zone, instant-at-which-that-starts" and use that to work out the effective time zone at any given instant.

Jon


--

---
You received this message because you are subscribed to the Google Groups "Noda Time" group.
To unsubscribe from this group and stop receiving emails from it, send an email to noda-time+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/noda-time/7b253505-42ee-4908-b58a-9a0110257a13n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages