NodaTime IANA时区偏移在C#中不匹配



转换日期:2016年10月12日12:00:00 AM要转换的时区:美国/纽约

这是我的函数,用于返回我提供的日期(dt)的偏移量。

LocalDateTime fromLocal = LocalDateTime.FromDateTime(dt);
DateTimeZone fromZone = DateTimeZoneProviders.Tzdb[timeZone];
ZonedDateTime fromZoned = fromLocal.InZoneLeniently(fromZone);
return fromZoned.ToDateTimeOffset();

结果:2016-12-10T000:00:00美国/纽约(-05)

当我在谷歌上搜索美国/纽约的偏移量时,我得到-04作为偏移量。

如果有人知道为什么会发生这种事,请帮忙。

当我搜索美国/纽约的偏移量时,我得到-04作为偏移量。

这在夏天是真的(尤其是你提问时的当前偏移量),但在冬天(包括2016-12-10年-你的"12/10/2016"在12月还是10月是模糊的)。

美国/纽约在冬季观测到UTC-5,在夏季观测到UTC-4。

这里没有bug。

最新更新