First, using class
System.TimeZoneInfo
instead of
System.TimeZone
as it is recommended in the MSDN help page of the last one.
You current time zone is returned by
System.TimeZoneInfo.Local
; the names of the same time zone are returned by the properties
DaylightName
,
DisplayName
,
Id
and
StandardName
.
See
http://msdn.microsoft.com/en-us/library/system.timezoneinfo.aspx[
^].
Which of the names represent the abbreviated form! No one! Same thing as with
System.TimeZone
. Why?
I think it is understandable. Look at the list of all abbreviated names of the time zones:
http://www.timeanddate.com/library/abbreviations/timezones/[
^].
Your can see that there is no one-to-one correspondence between abbreviations and time zones. More exactly, more than one time zone can be mapped onto the same abbreviated form; for example, "AMT" means UTC+4 (Armenia Time) and UTC-4 (Amazon Time) at the same time. Same thing with "EDT" and other abbreviations. On other words,
abbreviated forms are useless for identification purposes, so their use should be best avoided as they can cause confusion. Even if you use abbreviated form of the name, it should be accompanied by UTC notation to avoid ambiguity.
It is known that .NET does not support abbreviated forms; I think — for a good reason.
There is an old W3C RFC822 standard
http://www.w3.org/Protocols/rfc822/#z28[
^] (1977) which described several abbreviations which cover only US; and this subset does not create ambiguity.
There are different discussion on various hacks which attempt to create the abbreviated name by automatic abbreviation of the standard names. I don't want to reference such codes; you can easily find them. Nothing can guarantee they match knows abbreviated names. One can use the table referenced above, list all time zones using
System.TimeZoneInfo.GetSystemTimeZones
, manually type abbreviated names, create a look-up table in the form of
System.Collections.Generic.Dictionary<System.TimeZoneInfo, string>
; (not the other way around, due to ambiguity described above), populate it once and persist on the disk. During run-time, you can populate the dictionary from the file and use it to find abbreviated name by the "real" time zone. I would not recommend to waste time on it.
—SA