[llvm-branch-commits] [libcxx] [libc++][TZDB] Implements zoned_seconds typedef. (PR #95141)

Mark de Wever via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Jul 8 03:45:22 PDT 2024


https://github.com/mordante updated https://github.com/llvm/llvm-project/pull/95141

>From 711d47efd989a4422e61fd400a422182868c514e Mon Sep 17 00:00:00 2001
From: Mark de Wever <koraq at xs4all.nl>
Date: Wed, 17 Apr 2024 21:00:22 +0200
Subject: [PATCH] [libc++][TZDB] Implements zoned_seconds typedef.

Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
---
 libcxx/include/__chrono/zoned_time.h                         | 2 ++
 libcxx/include/chrono                                        | 2 ++
 libcxx/modules/std/chrono.inc                                | 2 --
 .../time.zone/time.zone.zonedtime/types.compile.pass.cpp     | 5 +++++
 4 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/libcxx/include/__chrono/zoned_time.h b/libcxx/include/__chrono/zoned_time.h
index 9be206db75931..30c7fe05c0b20 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -205,6 +205,8 @@ template <class _Duration, class _TimeZonePtrOrName, class TimeZonePtr2>
 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, TimeZonePtr2>, choose = choose::earliest)
     -> zoned_time<common_type_t<_Duration, seconds>, __time_zone_representation<_TimeZonePtrOrName>>;
 
+using zoned_seconds = zoned_time<seconds>;
+
 template <class _Duration1, class _Duration2, class _TimeZonePtr>
 _LIBCPP_HIDE_FROM_ABI bool
 operator==(const zoned_time<_Duration1, _TimeZonePtr>& __lhs, const zoned_time<_Duration2, _TimeZonePtr>& __rhs) {
diff --git a/libcxx/include/chrono b/libcxx/include/chrono
index 68a7fe3cc09b3..d6faa6f8baf88 100644
--- a/libcxx/include/chrono
+++ b/libcxx/include/chrono
@@ -793,6 +793,8 @@ template<class T> struct zoned_traits;
 template<class Duration, class TimeZonePtr = const time_zone*>                   // C++20
 class zoned_time;
 
+using zoned_seconds = zoned_time<seconds>;                                       // C++20
+
 template<class Duration1, class Duration2, class TimeZonePtr>                    // C++20
   bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
                   const zoned_time<Duration2, TimeZonePtr>& y);
diff --git a/libcxx/modules/std/chrono.inc b/libcxx/modules/std/chrono.inc
index 89fe7284eb694..3ba3c46150c9c 100644
--- a/libcxx/modules/std/chrono.inc
+++ b/libcxx/modules/std/chrono.inc
@@ -233,9 +233,7 @@ export namespace std {
     // [time.zone.zonedtime], class template zoned_time
     using std::chrono::zoned_time;
 
-#    if 0
     using std::chrono::zoned_seconds;
-#    endif // if 0
 
     // [time.zone.leap], leap second support
     using std::chrono::leap_second;
diff --git a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
index 96903b761b218..497da859265c2 100644
--- a/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
+++ b/libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp
@@ -23,6 +23,8 @@
 //    zoned_time& operator=(const zoned_time&) = default;
 //
 //  };
+//
+// using zoned_seconds = zoned_time<seconds>;
 
 #include <chrono>
 #include <concepts>
@@ -61,3 +63,6 @@ static_assert(!std::is_copy_constructible_v<std::chrono::zoned_time< std::chrono
 static_assert(!std::is_move_constructible_v<std::chrono::zoned_time< std::chrono::days, std::unique_ptr<int>>>);
 static_assert(!std::is_copy_assignable_v<std::chrono::zoned_time< std::chrono::days, std::unique_ptr<int>>>);
 static_assert(!std::is_move_assignable_v<std::chrono::zoned_time< std::chrono::days, std::unique_ptr<int>>>);
+
+// using zoned_seconds = zoned_time<seconds>;
+static_assert(std::same_as<std::chrono::zoned_seconds, std::chrono::zoned_time<std::chrono::seconds>>);



More information about the llvm-branch-commits mailing list