Storing time information: Timezone required?

Scheduling future time is inherently hard, because you don’t know what changes are coming in the future. It is a completely different beast than recording past time.

For past time events, all you really need is the local date and time, and the offset from UTC (many platforms call this a “DateTimeOffset”).

But for future events, you don’t necessarily know what the offset will be. You can guess what it is based upon your current knowledge of the time zone information, but that information is subject to change. In reality, it changes many times per year as governments of the world change their mind about daylight saving time and other situations.

Because you can’t determine the offset reliably, you also cannot determine the exact UTC timestamp. So it’s important that you hold on to the original local time. If you’re going to calculate a UTC timestamp, you should also recalculate that any time you update your time zone data.

I’ve already written about this multiple times, (here, here and here). I suggest you read those posts.

Now you brought up one point that I hadn’t touched on before, otherwise I’d have marked your question as a duplicate. That is – what if the location of the event moves into a new time zone entirely because the time zone boundaries have changed?

I agree with Deceze, that you need to think about how likely this scenario is and how bad a failure would be. In my opinion, it’s probably not worth investing a lot of time to. If you have an event scheduled in the future and that location breaks off into a new time zone, you could always go back and edit the event. You need to ask yourself how much detail your app is expected to know about the time zone changes. Most scheduling systems I’ve worked with don’t handle this aspect.

If it is indeed something that you want to handle, then you will need more than just the city. You should store latitude and longitude coordinates for the location. Then you can use one of these methods to resolve the time zone from those coordinates. But also note that you would want to make sure the source of the time zone boundaries was as up to date as possible.

Also note that the IANA Time Zone database that is the original source for the time zone data, does not keep boundary data at all! Most of the boundary data comes from independent sources, such as Eric Muller’s shapefiles, which as of today is aligned with the 2013b data of the IANA database (which is at 2013i), so there have been at least 7 updates to the time zone data that either didn’t change any boundaries, or the changes were not tracked.

Leave a Comment