There is a standard for time zones which is the IANA time zones. Sadly the browsers or better said EcmaScript (a.k.a JavaScript™) for long time had no idea of time zones at all. Even more said is that windows knows about time zones but does not care at all about the IANA ones.

Client

To compensate the lack of the client side engine there is a nice library that I use for some yeas now: jstz

The usage is quite simple:

var tz = jstz.determine();
tz.name();
'Europe/Berlin'

And even better: jstz is on NPM

But times get better and now for some time the Intl API is in place.

Intl.DateTimeFormat().resolvedOptions().timeZone

This works for all browsers but Internet Explorer (of course).

So far I see this as a solved problem.

Server

Now we can transmit the IANA time zone to the server. This is important for instance when rendering CSV File (RFC 7111), witch lacks specification of date time handling and also excel in not capable of rendering Zulutime as a local date.

So we still have the issue to convert IANA to Windows time zone. Of course there is a library with a nuget package for that. But I’d like to keep my external dependency footprint small and have my own solution around for a while. What was missing is the automatic update of changes to the IANA or Windows time zones.The Unicode Consortium has a nice repository over at github which contains everything that is needed.

So here is a T4 template that generates my class with the latest time zone information.