Europe/Dublin 的 NodaTime DST 问题

NodaTime DST problems with Europe/Dublin

我正在尝试两种不同的方法来确定 NodaTime 的夏令时:

now = SystemClock.Instance.GetCurrentInstant

Dim nowInIsoUtc As String = now.InUtc.ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
Dim localTimeZone As DateTimeZone = DateTimeZoneProviders.Tzdb(ComboBox1.SelectedItem.ToString)
Dim nowInLocal As String = now.InZone(localTimeZone).ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)
Dim DST As Boolean = now.InZone(localTimeZone).IsDaylightSavingTime
Dim interval As ZoneInterval = localTimeZone.GetZoneInterval(now)
Dim DstStart As Instant = interval.Start
Dim DstEnd As Instant = interval.End
' Gets the Daylight Savings value for this period
Dim DstSavings As Offset = interval.Savings
' Gets the Standard Offset for this period without any Daylight Savings contributions
Dim StandardOffset As Offset = interval.StandardOffset                           
Tb1.AppendText("Current DateTime in UTC: " & nowInIsoUtc & vbCrLf)
Tb1.AppendText("Current DateTime in Local Time: " & nowInLocal & vbCrLf)
Tb1.AppendText("Local TimeZone: " & localTimeZone.ToString & vbCrLf)
Tb1.AppendText("Amount of Daylight Savings in hours: " & DstSavings.ToString & vbCrLf)
Tb1.AppendText("StandardOffset: " & StandardOffset.ToString & vbCrLf)
Tb1.AppendText("DST: " & DST.ToString & ". From " & DstStart.ToString & " to " & DstEnd.ToString & vbCrLf)

Dim SelectedZone As DateTimeZone = DateTimeZoneProviders.Tzdb(ComboBox1.SelectedItem.ToString)
Dim clock As ZonedClock = SystemClock.Instance.InZone(SelectedZone)
Dim ThisDate As LocalDate = clock.GetCurrentDate()
Dim ThisTime As LocalTime = clock.GetCurrentTimeOfDay
Dim DST As Boolean = clock.GetCurrentZonedDateTime.IsDaylightSavingTime

Tb1.AppendText("DateTime in selected Zone: " & SelectedZone.ToString & vbCrLf)
Tb1.AppendText("Date: " & ThisDate.ToString & ", Time: " & ThisTime.ToString & " DST: " & DST & vbCrLf)

当使用 'Europe/Dublin' 和 'Europe/London' 作为时区时,我得到了相互矛盾的结果:

METHOD A:
Current DateTime in UTC: 2020-07-29 08:46:27

Current DateTime in Local Time: 2020-07-29 09:46:27
Local TimeZone: Europe/Dublin
Amount of Daylight Savings in hours: +00
StandardOffset: +01
DST: False. From 2020-03-29T01:00:00Z to 2020-10-25T01:00:00Z

Current DateTime in UTC: 2020-07-29 08:46:46
Current DateTime in Local Time: 2020-07-29 09:46:46
Local TimeZone: Europe/London
Amount of Daylight Savings in hours: +01
StandardOffset: +00
DST: True. From 2020-03-29T01:00:00Z to 2020-10-25T01:00:00Z
METHOD B:
DateTime in selected Zone: Europe/Dublin
Date: Wednesday, 29 July, 2020, Time: 09:47:03 DST: False

DateTime in selected Zone: Europe/London
Date: Wednesday, 29 July, 2020, Time: 09:47:09 DST: True

这两种方法似乎都表明都柏林没有夏令时,即使两者都给出了相同的 DST 开始和结束 date/times。请问有什么想法吗?

结果正确 - 这是爱尔兰时区的一个奇怪之处。目前爱尔兰没有遵守夏令时。它的标准偏移量是 UTC+1.

2020 年 10 月 25 日,爱尔兰将进入“夏令时”,夏令时偏移量为 -1 小时。因此,如果您将测试更改为尝试 11 月的日期(例如),您会看到 Europe/Dublin 显示 DST:True 和 Europe/London 显示 DST:False。

爱尔兰自 1968 年以来一直如此。以下是 IANA database 评论中的相关信息:

# (Note that the time in the Republic of Ireland since 1968 has been defined
# in terms of standard time being GMT+1 with a period of winter time when it
# is GMT, rather than standard time being GMT with a period of summer time
# being GMT+1.)