Why some time zone information are missing on windows 10?

1.8k Views Asked by At

In my local computer i am trying to access the offset values of IANA timezone using the converter as follows,

foreach (var timeZone in TZConvert.KnownIanaTimeZoneNames)
{
  var tzi = TZConvert.GetTimeZoneInfo(timeZone.ToString());
  TimeSpan offset = tzi.GetUtcOffset(DateTime.Now);
  .......
}

the line TZConvert.GetTimeZoneInfo(timeZone.ToString()) sometimes throw an error saying

System.TimeZoneNotFoundException: 'The time zone ID 'Sudan Standard Time' was not found on the local computer.'

when i try the same on power shell with the same command,

PS C:\Users\SajeetharanS> [System.TimeZoneInfo]::FindSystemTimeZoneById("Aleutian Standard Time") Exception calling "FindSystemTimeZoneById" with "1" argument(s): "The time zone ID 'Aleutian Standard Time' was not found on the local computer." At line:1 char:1 + [System.TimeZoneInfo]::FindSystemTimeZoneById("Aleutian Standard Time ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : TimeZoneNotFoundException

why some timezone information are missing? how can i fix it?

1

There are 1 best solutions below

0
On BEST ANSWER

The particular time zone, "Sudan Standard Time" was just released by Microsoft on December 12, 2017. It is likely that the computer where the code is running does not yet have this update. See the "How to get this update" section of the support document. (Basically, run Windows Update).

As far as "Aleutian Standard Time", that was released in June 2016. So if the computer does not have that, then it is quite behind with updates.

In general, time zones are a moving target because the governments of the world make changes to their standard offset and DST policies. In order to have accurate local time, staying current with updates is essential.

My TimeZoneConverter library that you are using makes the assumption that the computer is current. I push updates as time zone changes are released by Microsoft and IANA, but I do not attempt to reconcile with whether or not a particular computer has the time zones installed.

If you are trying to list all the time zones on the computer, you would better off using the built in TimeZoneInfo.GetSystemTimeZones() method, then using the .Id property of each.

Also, in most cases, you don't want to use .StandardName, because the .StandardName, .DaylightName, and .DisplayName properties are localized for the language installed on the OS. Sometimes the .Id matches the .StandardName, but that is not guaranteed - even in English.