From fbb95412f633facb82dc756c141549061ef196c4 Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Fri, 1 Aug 2025 19:02:33 +0800 Subject: [PATCH 1/3] Use designated aggregate initialization when returning `tm` --- stl/inc/chrono | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index dd1dec49d1a..09c4e7b9b0c 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -5115,16 +5115,17 @@ namespace chrono { _Seconds = static_cast(_Val.seconds().count()); } - tm _Time; - _Time.tm_sec = _Seconds; - _Time.tm_min = _Minutes; - _Time.tm_hour = _Hours; - _Time.tm_mday = static_cast(_Day); - _Time.tm_mon = static_cast(_Month) - 1; - _Time.tm_year = _Year - 1900; - _Time.tm_yday = _Yearday; - _Time.tm_wday = _Weekday; - return _Time; + return tm{ + .tm_sec = _Seconds, + .tm_min = _Minutes, + .tm_hour = _Hours, + .tm_mday = static_cast(_Day), + .tm_mon = static_cast(_Month) - 1, + .tm_year = _Year - 1900, + .tm_wday = _Weekday, + .tm_yday = _Yearday, + .tm_isdst{}, + }; } } From edaa5fc1765b28910036deff3fbd523d384520dc Mon Sep 17 00:00:00 2001 From: "A. Jiang" Date: Sat, 2 Aug 2025 17:05:42 +0800 Subject: [PATCH 2/3] Address @jovibor's review comments --- stl/inc/chrono | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index 09c4e7b9b0c..63db87691bf 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -5115,7 +5115,7 @@ namespace chrono { _Seconds = static_cast(_Val.seconds().count()); } - return tm{ + return { .tm_sec = _Seconds, .tm_min = _Minutes, .tm_hour = _Hours, @@ -5124,7 +5124,7 @@ namespace chrono { .tm_year = _Year - 1900, .tm_wday = _Weekday, .tm_yday = _Yearday, - .tm_isdst{}, + .tm_isdst{} }; } } @@ -6272,3 +6272,4 @@ _STL_RESTORE_CLANG_WARNINGS #pragma pack(pop) #endif // _STL_COMPILER_PREPROCESSOR #endif // _CHRONO_ + From 0e5cf55fdd586b14c3e3424504db174d625928bd Mon Sep 17 00:00:00 2001 From: "Stephan T. Lavavej" Date: Sat, 2 Aug 2025 03:27:43 -0700 Subject: [PATCH 3/3] Restore trailing comma, clang-format. --- stl/inc/chrono | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/stl/inc/chrono b/stl/inc/chrono index 63db87691bf..16ff5ca3aa2 100644 --- a/stl/inc/chrono +++ b/stl/inc/chrono @@ -5124,7 +5124,7 @@ namespace chrono { .tm_year = _Year - 1900, .tm_wday = _Weekday, .tm_yday = _Yearday, - .tm_isdst{} + .tm_isdst{}, }; } } @@ -6272,4 +6272,3 @@ _STL_RESTORE_CLANG_WARNINGS #pragma pack(pop) #endif // _STL_COMPILER_PREPROCESSOR #endif // _CHRONO_ -