在 Windows Server 2019 版本 10.0.17763 上,以下代码返回 false:
TimeZoneInfo.TryConvertWindowsIdToIanaId("W. Europe Standard Time", out var timeZoneIana)
但是这段代码可以在 Windows Server 2022 的测试机上运行。 此方法工作的系统要求是什么?
最佳答案
方法 TimeZoneInfo.TryConvertWindowsIdToIanaId
和 TimeZoneInfo.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/