Skip to content

Fix inverted null check in time_zone_name_win.cc#340

Open
yukawa wants to merge 1 commit intogoogle:masterfrom
yukawa:fix_icu_load_null_check
Open

Fix inverted null check in time_zone_name_win.cc#340
yukawa wants to merge 1 commit intogoogle:masterfrom
yukawa:fix_icu_load_null_check

Conversation

@yukawa
Copy link
Copy Markdown
Contributor

@yukawa yukawa commented Mar 15, 2026

This commit follows up the previous commit (27ca173), which aimed to improve the code but ended up introducing an inverted null check in time_zone_name_win.cc. As a result, LoadIcuGetTimeZoneIDForWindowsID() currently returns nullptr when it should be returning a valid time zone ID.

This is also a preparation for implementing TimeZoneIf with Windows time APIs (#328).

Comment thread src/time_zone_name_win.cc
@yukawa yukawa force-pushed the fix_icu_load_null_check branch 2 times, most recently from e33561c to cbbfd28 Compare March 23, 2026 02:08
Comment thread CMakeLists.txt Outdated
@yukawa yukawa force-pushed the fix_icu_load_null_check branch from cbbfd28 to 841a08a Compare March 23, 2026 18:54
Comment thread src/time_zone_name_win_test.cc Outdated
This commit follows up the previous commit [1], which aimed to improve
the code but ended up introducing an inverted null check in
time_zone_name_win.cc. As a result, LoadIcuGetTimeZoneIDForWindowsID()
currently returns nullptr when it should be returning a valid time zone
ID.

A unit test is also added, as the fallback chain in local_time_zone()
makes it difficult to verify the behavior of
LoadIcuGetTimeZoneIDForWindowsID() in isolation. The test ensures that
the function correctly returns a valid time zone ID on Windows.

This is also a preparation for implementing TimeZoneIf with Windows time
APIs (google#328).

[1] 27ca173
@yukawa yukawa force-pushed the fix_icu_load_null_check branch from 841a08a to d09a3fd Compare March 23, 2026 19:53
Comment on lines +34 to +39
if (icu_dll != nullptr) {
EXPECT_FALSE(tz.empty());
::FreeLibrary(icu_dll);
} else {
EXPECT_TRUE(tz.empty());
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My final question before handing off to @derekmauro.

Do we know which branch our Windows CI actually takes? That is, is it checking that GetWindowsLocalTimeZone() succeeds or fails?

Copy link
Copy Markdown
Contributor Author

@yukawa yukawa Apr 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should go to icu_dll != nullptr route, so GetWindowsLocalTimeZone() should now be continuously tested in CI.

According to a recent run, runner image is windows-2025, which should have icu.dll there.

Runner Image
Image: windows-2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants