[libcxx-commits] [libcxx] [libc++][TZDB] Fixes %z escaping. (PR #125399)
Mark de Wever via libcxx-commits
libcxx-commits at lists.llvm.org
Sun Feb 2 04:27:43 PST 2025
https://github.com/mordante created https://github.com/llvm/llvm-project/pull/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: https://github.com/llvm/llvm-project/issues/108957
>From ee1a6d842a0cc46fd1792199ee1ca4fc15556113 Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Sun, 2 Feb 2025 13:23:14 +0100
Subject: [PATCH] [libc++][TZDB] Fixes %z escaping.
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: https://github.com/llvm/llvm-project/issues/108957
---
libcxx/src/experimental/time_zone.cpp | 2 +-
.../time.zone.members/get_info.sys_time.pass.cpp | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/libcxx/src/experimental/time_zone.cpp b/libcxx/src/experimental/time_zone.cpp
index 764a89ab513c86..b11e52fec65c4f 100644
--- a/libcxx/src/experimental/time_zone.cpp
+++ b/libcxx/src/experimental/time_zone.cpp
@@ -668,7 +668,7 @@ __first_rule(seconds __stdoff, const vector<__tz::__rule>& __rules) {
__continuation_end,
__continuation.__stdoff + __save,
chrono::duration_cast<minutes>(__save),
- __continuation.__format},
+ chrono::__format(__continuation, __continuation.__format, __save)},
true};
}
diff --git a/libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp b/libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
index 7f08c64d5e0e71..afd1273421f398 100644
--- a/libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
+++ b/libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp
@@ -157,7 +157,6 @@ static void test_abbrev(std::string_view input, std::string_view expected) {
TEST_LIBCPP_REQUIRE(result == expected, TEST_WRITE_CONCATENATED("\nExpected ", expected, "\nActual ", result, '\n'));
}
-// This format is valid, however is not used in the tzdata.zi.
static void percentage_z_format() {
test_abbrev(
R"(
@@ -188,6 +187,12 @@ Z Format 0:45 F %z)",
R F 1999 max - Jan 5 0 -1 foo
Z Format 0:45 F %z)",
"-0015");
+
+ test_abbrev(
+ R"(
+Z Format -1:2:20 - LMT 1912 Ja 1 1u
+-1 - %z)",
+ "-01");
}
int main(int, const char**) {
More information about the libcxx-commits
mailing list