[libcxx-commits] [libcxx] [libc++][chrono] P0355R7 Implement from_stream and parse (PR #227590)

via libcxx-commits libcxx-commits at lists.llvm.org
Tue Oct 20 01:24:52 PDT 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions ,cpp,h,inc -- libcxx/include/__chrono/from_stream.h libcxx/include/__chrono/parse.h libcxx/include/__chrono/parser_data.h libcxx/test/libcxx/time/from_stream.pass.cpp libcxx/test/std/time/time.parse/from_stream.pass.cpp libcxx/test/std/time/time.parse/parse.pass.cpp libcxx/include/chrono libcxx/modules/std/chrono.inc --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/libcxx/test/libcxx/time/from_stream.pass.cpp b/libcxx/test/libcxx/time/from_stream.pass.cpp
index 254fa7e0d..124580bd4 100644
--- a/libcxx/test/libcxx/time/from_stream.pass.cpp
+++ b/libcxx/test/libcxx/time/from_stream.pass.cpp
@@ -24,7 +24,7 @@
 
 template <class CharT>
 void test_read_digits() {
-  using Traits = std::char_traits<CharT>;
+  using Traits             = std::char_traits<CharT>;
   constexpr auto max_value = std::numeric_limits<std::uint64_t>::max();
   struct TestCase {
     std::basic_string<CharT> input;
@@ -80,11 +80,11 @@ void test_read_digits() {
 
 template <class CharT>
 void test_read_signed() {
-  using Traits = std::char_traits<CharT>;
-  constexpr int sentinel = 42;
+  using Traits            = std::char_traits<CharT>;
+  constexpr int sentinel  = 42;
   constexpr int min_value = std::numeric_limits<int>::min();
   constexpr int max_value = std::numeric_limits<int>::max();
-  const auto make_input = [](std::int64_t value) {
+  const auto make_input   = [](std::int64_t value) {
     const auto input = std::to_string(value);
     return std::basic_string<CharT>(input.begin(), input.end());
   };
@@ -118,7 +118,7 @@ void test_read_signed() {
   };
   for (const auto& c : cases) {
     std::basic_istringstream<CharT> stream{c.input};
-    int result = sentinel;
+    int result                   = sentinel;
     std::ios_base::iostate state = std::ios_base::goodbit;
     std::chrono::__from_stream_parser<CharT, Traits> parser{stream, state};
     parser.__read_signed(std::numeric_limits<unsigned>::max(), result);
diff --git a/libcxx/test/std/time/time.parse/from_stream.pass.cpp b/libcxx/test/std/time/time.parse/from_stream.pass.cpp
index 676a37ee5..b16da01f9 100644
--- a/libcxx/test/std/time/time.parse/from_stream.pass.cpp
+++ b/libcxx/test/std/time/time.parse/from_stream.pass.cpp
@@ -347,9 +347,7 @@ void test_modifier_O() {
   check(STR("2026-07-20 12 PM"), STR("%F %OI %p"), sys_time<hours>{date} + 12h);
 
   // Parse fractional seconds with a colon-separated UTC offset.
-  check(STR("2026-07-20 13:45:30.125 +4:30"),
-        STR("%F %H:%M:%OS %Oz"),
-        date + 13h + 45min + 30s + 125ms - 4h - 30min);
+  check(STR("2026-07-20 13:45:30.125 +4:30"), STR("%F %H:%M:%OS %Oz"), date + 13h + 45min + 30s + 125ms - 4h - 30min);
 
   // This date has week number 29 with either Sunday or Monday as the first day.
   for (const auto& format : {STR("%Y %OU %w"), STR("%Y %OW %w")})

``````````

</details>


https://github.com/llvm/llvm-project/pull/227590


More information about the libcxx-commits mailing list