Fix formatting std::tm with null tm_zone (#4790)

This commit is contained in:
Jiami Lin
2026-06-02 09:16:49 +08:00
committed by GitHub
parent f53c0408a3
commit a90ad5d6fd
2 changed files with 4 additions and 0 deletions
+3
View File
@@ -358,6 +358,9 @@ TEST(chrono_test, tm) {
char tz[] = "EET";
if (fmt::detail::set_tm_zone(time, tz)) {
EXPECT_EQ(fmt::format(fmt::runtime("{:%Z}"), time), "EET");
fmt::detail::set_tm_zone(time, nullptr);
EXPECT_THROW_MSG((void)fmt::format(fmt::runtime("{:%Z}"), time),
fmt::format_error, "no timezone");
} else {
EXPECT_THROW_MSG((void)fmt::format(fmt::runtime("{:%Z}"), time),
fmt::format_error, "no timezone");