TimeZoneInfo.DisplayName returns the binding value [UWP]

well, this is rather strange, but I created a simple UWP project and added a simple line to the code:

IEnumerable<string> TimeZones = TimeZoneInfo.GetSystemTimeZones().Select(_ => _.DisplayName);

When I run the program, I get the expected result:

  • (UTC-11: 00) Coordinated Universal Time-11 ",
  • (UTC-10: 00) Aleutian Islands ",
  • (UTC-10: 00) Hawaii ",
  • (UTC-09: 30) Marquesas Islands ",
  • ...

But if I set the "Compile with .Net Native tool chain" flag , I get:

  • UTC-11
  • Aleutian Standard Time
  • Hawaiian Standard Time
  • Standard time Marquesas
  • ...

Is it possible to somehow get the expected behavior using "Compile with .Net Native tool chain" ?

+4
source share
1

.

, .Net Native DisplayName , StandardName. .

UTC :

        var TimeZoneList=TimeZoneInfo.GetSystemTimeZones();
        foreach(var i in TimeZoneList)
        {
            TimeSpan ts = i.GetUtcOffset(DateTime.Now);

            if (ts.ToString().Contains("-"))
            {
                string s = "(UTC" + ts.ToString() + ")" + i.StandardName;

            }
            else
            {
                string s = "(UTC+" + ts.ToString() + ")" + i.StandardName;

            }
        }

.

0

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


All Articles