Alexei
Alexei

Reputation: 211

TimeZoneInfo in WinApi return bad value

It seems that I found a mistake in WinApi. When I use TimeZoneInfo.Local.DisplayName in Debug in my Visual Studio 2015 it return right variant to me, as example "(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius". In release mode(.net native) same api return me "FLE Standard Time". Be greatfull to hear how to get time zone information in other way, or how to fix this issue.

Upvotes: 6

Views: 136

Answers (1)

snickro
snickro

Reputation: 481

You most likely have missed something in your code. One mistake that I made before, and is easy to make is confusing DisplayName with DaylightName:

        static void Main(string[] args)
        {
            var timeZoneName = TimeZoneInfo.Local.DaylightName; //FLE Standard Time
            var displayName = TimeZoneInfo.Local.DisplayName; //(UTC+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
        }

For reference, you can check Time Zone IDs

Upvotes: 2

Related Questions