.NET 6 TimeZoneInfo.TryConvertWindowsIdToIanaId() 确实返回 false

标签 .net windows timezone .net-6.0

在 Windows Server 2019 版本 10.0.17763 上,以下代码返回 false:

TimeZoneInfo.TryConvertWindowsIdToIanaId("W. Europe Standard Time", out var timeZoneIana)

但是这段代码可以在 Windows Server 2022 的测试机上运行。 此方法工作的系统要求是什么?

最佳答案

方法 TimeZoneInfo.TryConvertWindowsIdToIanaIdTimeZoneInfo.TryConvertIanaIdToWindowsId 依赖 ICU globalization ,自 Windows 10 May 2019 更新起可在 Windows 计算机上使用。这对应于 Windows Server 1903(内部版本 10.0.18362)。

如果您需要在旧系统上支持 Windows 和 IANA 时区,请使用 TimeZoneConverter图书馆代替。对应的方法是TZConvert.TryWindowsToIana

关于.NET 6 TimeZoneInfo.TryConvertWindowsIdToIanaId() 确实返回 false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74093527/

相关文章:

c# - 如何在 Entity Framework 中添加种子方法

.net - 使用命令行编译强命名程序集

windows - glFlush() 在具有透明背景的窗口上需要很长时间

windows - 如何通过批处理文件在 Windows 防火墙上打开端口

datetime - 改变时区 Elixir 的正确方法是什么

C# 默认可选参数选择器

python - 加载库: pyinstaller :format messageW failed

timezone - 区分 UTC 和 GMT 的常见做法是什么?

ruby-on-rails - 命名范围不与时区合作?

c# - sql命令不适用于c#中的select语句