Skip to content

Commit a27f3b2

Browse files
authored
[libc++][TZDB] Fixes %z escaping. (#125399)
The previous tested TZDB did not contain %z for the rule letters. The usage of %z in TZDB 2024b revealed a bug in the implementation. The patch fixes it and has been locally tested with TZDB 2024b. Fixes #108957
1 parent 25daf7b commit a27f3b2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

libcxx/src/experimental/time_zone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,7 @@ __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) {
668668
__continuation_end,
669669
__continuation.__stdoff + __save,
670670
chrono::duration_cast<minutes>(__save),
671-
__continuation.__format},
671+
chrono::__format(__continuation, __continuation.__format, __save)},
672672
true};
673673
}
674674

libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,6 @@ static void test_abbrev(std::string_view input, std::string_view expected) {
157157
TEST_LIBCPP_REQUIRE(result == expected, TEST_WRITE_CONCATENATED("\nExpected ", expected, "\nActual ", result, '\n'));
158158
}
159159

160-
// This format is valid, however is not used in the tzdata.zi.
161160
static void percentage_z_format() {
162161
test_abbrev(
163162
R"(
@@ -188,6 +187,12 @@ Z Format 0:45 F %z)",
188187
R F 1999 max - Jan 5 0 -1 foo
189188
Z Format 0:45 F %z)",
190189
"-0015");
190+
191+
test_abbrev(
192+
R"(
193+
Z Format -1:2:20 - LMT 1912 Ja 1 1u
194+
-1 - %z)",
195+
"-01");
191196
}
192197

193198
int main(int, const char**) {

0 commit comments

Comments
 (0)