【问题标题】:How to find out the actual times when DST starts/ends for a timezone and particular year?如何找出某个时区和特定年份的 DST 开始/结束的实际时间?
【发布时间】:2011-05-06 07:23:51
【问题描述】:

我想知道 DST 在特定时区和年份中开始/结束的确切时间。

使用TimeZoneInfo.GetAdjustmentRules 和AdjustmentRule.DaylightTransitionStart 我可以得到一个TransitionTime 对象,它指定了夏令时开始时刻规则。

假设我找到了适用于 2010 年的调整规则。如何将它的 TransitionTime 对象转换为 2010 年的 DateTime?

Timezone: (UTC-05:00) Eastern Time (US & Canada)
Valid: 01.01.2007 00:00:00 - 31.12.9999 00:00:00
DST Start TransitionTime:
    IsFixedDateRule: false
    Month: 3
    Week: 2
    DayOfWeek: Sunday
    TimeOfDay: 02:00:00

【问题讨论】:

    标签: .net timezone dst


    【解决方案1】:

    MSDN 有sample。见底部DisplayTransitionInfo函数。

    【讨论】:

    • 奇怪的是,TimeZoneInfo 有一个 private static GetDaylightTime(int year, TimeZoneInfo.AdjustmentRule rule),它返回 DaylightTime 和 Start 和 End DateTime 属性。我不明白为什么这是私人的? CLS 合规性?
    猜你喜欢
    • 2013-11-26
    • 1970-01-01
    • 2018-02-24
    • 2021-11-16
    • 2016-08-12
    • 2011-04-07
    • 2023-03-04
    • 2011-11-05
    • 1970-01-01
    相关资源
    最近更新 更多