diff --git a/CHANGELOG.md b/CHANGELOG.md index 4d0610340ab1..a62d049e2410 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,9 +9,14 @@ This is a patch release that: [#55158][]). - Fixes an issue in the CFE that prevented redirecting factories from being resolved in initializers of extension types (issue [#55194][]). +- Fixes an issues with VM's implementation of `DateTime.timeZoneName` + on Windows, which was checking whether current date is in the summer or + standard time rather than checking if the given moment is in the summer or + standard time (issue [#55240][]). [#55158]: https://github.com/dart-lang/sdk/issues/55158 [#55194]: https://github.com/dart-lang/sdk/issues/55194 +[#55240]: https://github.com/dart-lang/sdk/issues/55240 ## 3.3.1 - 2024-03-06 diff --git a/runtime/vm/os_win.cc b/runtime/vm/os_win.cc index 9daec00e6f3c..9e5ea5519aaa 100644 --- a/runtime/vm/os_win.cc +++ b/runtime/vm/os_win.cc @@ -112,13 +112,11 @@ const char* OS::GetTimeZoneName(int64_t seconds_since_epoch) { } // Figure out whether we're in standard or daylight. - bool daylight_savings = (status == TIME_ZONE_ID_DAYLIGHT); - if (status == TIME_ZONE_ID_UNKNOWN) { - tm local_time; - if (LocalTime(seconds_since_epoch, &local_time)) { - daylight_savings = (local_time.tm_isdst == 1); - } + tm local_time; + if (!LocalTime(seconds_since_epoch, &local_time)) { + return ""; } + const bool daylight_savings = (local_time.tm_isdst == 1); // Convert the wchar string to a null-terminated utf8 string. wchar_t* wchar_name = daylight_savings ? zone_information.DaylightName diff --git a/tests/corelib/date_time7_test.dart b/tests/corelib/date_time7_test.dart index f59236a040ce..576c13eff26b 100644 --- a/tests/corelib/date_time7_test.dart +++ b/tests/corelib/date_time7_test.dart @@ -34,6 +34,8 @@ testLocal() { Expect.equals(-4, offset.inHours); case "PDT" || "Pacific Daylight Time": Expect.equals(-7, offset.inHours); + case "PST" || "Pacific Standard Time": + Expect.equals(-8, offset.inHours); case "CST" || "Central Standard Time": Expect.equals(-6, offset.inHours); case "CDT" || "Central Daylight Time":