【发布时间】:2016-11-06 13:14:14
【问题描述】:
我使用 NodaTime 在 ical.net 中进行时区转换,因为它的性能比之前尝试使用 VTIMEZONE 元素处理时间更改和时区转换的实现要好得多。
实际上,这种方法对性能非常重要:它将测试套件运行时间从大约 6 秒降低到大约 2.5 秒。
public static DateTimeZone GetZone(string tzId)
{
// IANA lookup attempt
zone = DateTimeZoneProviders.Bcl.GetZoneOrNull(tzId);
if (zone != null)
{
return zone;
}
// Serialization lookup attempt
// Some other tricks to find a reasonable time zone, etc.
}
NodaTime 的 .NET Core 实现没有 Bcl 作为 DateTimeZoneProvider。 (它仍然有 Tzdb 和 Serialization。)我在 NodaTime 源代码中翻了一下,但我不确定替换是什么意思,如果有的话。
我们应该在 NodaTime 的 .NET Core 端口中使用什么进行 BCL 时区查找?
【问题讨论】:
标签: c# timezone .net-core nodatime base-class-library