Getting the Windows timezone index using TimeZoneInfo.GetSystemTimeZones ();

so something i struggled with is pulling a list of time zones in .net 4 (C #) to populate a drop down list in the form. I know I can do this:

var TimeZoneList = TimeZoneInfo.GetSystemTimeZones(); 

which will receive a list of time zones in the TimeZoneInfo class, which has the "Id" property. However, the identifier is not a Microsoft time zone index.

For example, with Eastern time, โ€œIdโ€ is simply โ€œEastern Standard Time,โ€ where the internal index is โ€œ35โ€. (Other indexes are here: http://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11).aspx )

Is there a way to get these indices from TimeZoneInfo.GetSystemTimeZones () or is there some other method that I can call to find them? I know that I can just make a switch case or a bunch of if statements to check each identifier and match the index value, but I think there should be a better way.

Thanks!

+4
source share
1 answer

This is a bit dated, but this MSDN forum post since 2008 (.NET 3.5) suggests that there is no good mapping, and perhaps you should create a cross-reference table from TimeZoneInfo identifiers in time zone identifiers from the page you are pointing to.

0
source

Source: https://habr.com/ru/post/1403734/


All Articles