Skip to content

Conversation

@mordante
Copy link
Member

@mordante mordante commented Feb 2, 2025

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

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: llvm#108957
@mordante mordante requested a review from a team as a code owner February 2, 2025 12:27
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Feb 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 2, 2025

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/125399.diff

2 Files Affected:

  • (modified) libcxx/src/experimental/time_zone.cpp (+1-1)
  • (modified) libcxx/test/libcxx/time/time.zone/time.zone.timezone/time.zone.members/get_info.sys_time.pass.cpp (+6-1)
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**) {

@mordante mordante added this to the LLVM 20.X Release milestone Feb 3, 2025
@ldionne ldionne merged commit a27f3b2 into llvm:main Feb 4, 2025
78 checks passed
@mordante mordante deleted the review/fixes_%z_escaping branch February 4, 2025 17:20
@mordante
Copy link
Member Author

mordante commented Feb 4, 2025

/cherry-pick a27f3b2

@llvmbot
Copy link
Member

llvmbot commented Feb 4, 2025

Failed to create pull request for issue125399 https://github.com/llvm/llvm-project/actions/runs/13141160669

@mordante
Copy link
Member Author

mordante commented Feb 4, 2025

/cherry-pick a27f3b2

@llvmbot
Copy link
Member

llvmbot commented Feb 4, 2025

/pull-request #125730

swift-ci pushed a commit to swiftlang/llvm-project that referenced this pull request Feb 7, 2025
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 llvm#108957

(cherry picked from commit a27f3b2)
Icohedron pushed a commit to Icohedron/llvm-project that referenced this pull request Feb 11, 2025
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 llvm#108957
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Projects

Development

Successfully merging this pull request may close these issues.

[libc++] sys_info.zdump.pass.cpp fails on %z format with tzdata 2024b

3 participants