Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TimeZoneInfo in WinApi return bad value

Tags:

c#

uwp

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.

like image 541
Alexei Avatar asked Jul 26 '16 08:07

Alexei


Video Answer


1 Answers

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

like image 134
snickro Avatar answered Sep 18 '22 09:09

snickro