TimeZoneInfo.DisplayName的IoT实现与docs不匹配 [英] IoT Implementation of TimeZoneInfo.DisplayName doesn't match docs

查看:59
本文介绍了TimeZoneInfo.DisplayName的IoT实现与docs不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档
TimeZoneInfo.DisplayName
声明它应该产生类似"(GMT-02:00)Mid-Atlantic"的系统标准字符串。此格式与文档和

TimeZoneSettings.CurrentTimeZoneDisplayName


因此TimeZoneSettings类可以获得标准格式时区字符串并且可以获取系统支持的所有时区列表。它还可以
TimeZoneSettings。 ChangeTimeZoneByDisplayName(String)并获取从SupportedTimeZoneDisplayNames返回的标准时区字符串。整个班级以标准系统显示格式处理时区字符串,如
"(GMT-02:00)Mid-Atlantic"。


但是,TimeZoneInfo类声明它也应该以相同的格式返回系统显示时区字符串。因此,您无法从TimeZoneInfo.GetSystemTimeZones()中搜索从TimeZoneSettings.CurrentTimeZoneDisplayName
返回的匹配条目的结果,以获取有关 TimeZoneSettings的各个时区的更多信息。 ChangeTimeZoneByDisplayName(String)可以接受。此外,由于您无法搜索 TimeZoneInfo.GetSystemTimeZones()
来获取特定时区的TimeZoneInfo,因此无法使用
TimeZoneInfo.ConvertTime()转换日期和时间的方法。


如果Windows IoT的TimeZoneInfo类实现确实返回了正确的字符串格式,那么UWP应用程序可能具有用户可选择的时区设置在调用  TimeZoneSettings。 ChangeTimeZoneByDisplayName(String)
但重启设备之前,控制并能够处理时间和日期的显示。 / span>


解决方案

Hello mjmeans,


>>> 如果Windows IoT的TimeZoneInfo类实现确实返回了正确的字符串格式


你能显示你的结果吗?


我在Raspberry Pi 3上用以下代码行测试:

 TimeZoneInfo localZone = TimeZoneInfo.Local; 
System.Diagnostics.Debug.WriteLine(" Local Time Zone ID:" + localZone.Id);
System.Diagnostics.Debug。 WriteLine(" Display Name is:" + localZone.DisplayName);

结果如下:

当地时区ID:太平洋标准时间
显示名称为:(UTC-08:00)太平洋时间(美国和加拿大)

致以最诚挚的问候,


Rita




Docs TimeZoneInfo.DisplayName state that it should result in a system standard string in like "(GMT-02:00) Mid-Atlantic". This format would exactly match the docs and the actual results from TimeZoneSettings.CurrentTimeZoneDisplayName.

So TimeZoneSettings class can get the standard format time zone string and can get a list of all time zones the system supports. It can also TimeZoneSettings.ChangeTimeZoneByDisplayName(String) and takes a standard time zone string returned from SupportedTimeZoneDisplayNames. This entire class handles time zone string in the standard system display format like "(GMT-02:00) Mid-Atlantic".

However, the TimeZoneInfo class which states that it should also return a system display time zone string in the same format doesn't. So you cannot search the results from TimeZoneInfo.GetSystemTimeZones() for a matching entry returned from TimeZoneSettings.CurrentTimeZoneDisplayName in order to get more information about the various time zones that TimeZoneSettings.ChangeTimeZoneByDisplayName(String) can accept. Further, since you cannot search TimeZoneInfo.GetSystemTimeZones() to get a TimeZoneInfo for the specific time zone, you cannot use the TimeZoneInfo.ConvertTime() method to convert dates and times.

If the TimeZoneInfo class implementation for Windows IoT did return the correct string format, then it would be possible for the UWP app to have a user selectable time zone setting control and be able to handle display of a time and date after calling TimeZoneSettings.ChangeTimeZoneByDisplayName(String) but before restarting the device.

解决方案

Hello mjmeans,

>>>If the TimeZoneInfo class implementation for Windows IoT did return the correct string format

Can you show your result?

I test with the following code lines on Raspberry Pi 3:

            TimeZoneInfo localZone = TimeZoneInfo.Local;
            System.Diagnostics.Debug.WriteLine("Local Time Zone ID: " + localZone.Id);
            System.Diagnostics.Debug.WriteLine("   Display Name is: " + localZone.DisplayName);

This is the result:

Local Time Zone ID: Pacific Standard Time
   Display Name is: (UTC-08:00) Pacific Time (US & Canada)

Best regards,

Rita


这篇关于TimeZoneInfo.DisplayName的IoT实现与docs不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆