0

When I use

ReadOnlyCollection timeZones = TimeZoneInfo.GetSystemTimeZones();

I get a list of timezones and it contains this timezone:

timeZone.DisplayName = (UTC+09:00) Yakutsk

timeZone.StandardName = Russia TZ 8 Standard Time ...

but I think timeZone.StandardName should be:

Yakutsk Standard Time

to perform the transition from one time zone to another. I use:

TimeZoneInfo timeInfo = TimeZoneInfo.FindSystemTimeZoneById(timeZone.StandardName);

and the following error occurs:

the time zone id 'Russia TZ 8 Standard Time was not found on the local computer

Please someone help me with…

Kira
  • 27
  • 5
  • Does this answer your question? [What value should I pass into TimeZoneInfo.FindSystemTimeZoneById(String)?](https://stackoverflow.com/questions/14149346/what-value-should-i-pass-into-timezoneinfo-findsystemtimezonebyidstring) – Pranav Hosangadi Oct 12 '21 at 03:53
  • Lookup NodaTime – Flydog57 Oct 12 '21 at 04:17

1 Answers1

0

If you want to know the ID of the time zone, use the Id property, not the StandardName property. After all, the method is called FindSystemTimeZoneById, not FindSystemTimeZoneByStandardName.

To elaborate further, the Id property returns a string that uniquely identifies the time zone and is not affected by localization (language, culture, etc.). The DisplayName, StandardName, and DaylightName properties return strings that are intended to be human readable and are affected by localization. In modern .NET 6, that localization is CultureInfo.CurrentUICulture. In prior incantations such as .NET Framework on Windows, that culture was determined by the operating system's default language setting. Although some time zones may have had their StandardName and Id properties match for US-English, this was never guaranteed nor universally applicable for all time zones or all languages/cultures.

Matt Johnson-Pint
  • 230,703
  • 74
  • 448
  • 575