Skip to content

[libc++][TZDB] Implements zoned_seconds typedef. #95141

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 10, 2024

Conversation

mordante
Copy link
Member

Implements parts of:

  • P0355 Extending to chrono Calendars and Time Zones

@mordante mordante requested a review from a team as a code owner June 11, 2024 16:36
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jun 11, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 11, 2024

@llvm/pr-subscribers-libcxx

Author: Mark de Wever (mordante)

Changes

Implements parts of:

  • P0355 Extending to chrono Calendars and Time Zones

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

4 Files Affected:

  • (modified) libcxx/include/__chrono/zoned_time.h (+2)
  • (modified) libcxx/include/chrono (+2)
  • (modified) libcxx/modules/std/chrono.inc (-2)
  • (modified) libcxx/test/std/time/time.zone/time.zone.zonedtime/types.compile.pass.cpp (+5)
diff --git a/libcxx/include/__chrono/zoned_time.h b/libcxx/include/__chrono/zoned_time.h
index db5e67135d844..d9518ce0a8313 100644
--- a/libcxx/include/__chrono/zoned_time.h
+++ b/libcxx/include/__chrono/zoned_time.h
@@ -204,6 +204,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 df7ebf45bd907..9a6159cf2c4ab 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 f2b198249e73d..91e37d0d02897 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>
@@ -57,3 +59,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>>);

@mordante mordante force-pushed the users/mordante/zoned_time__operator== branch from 86dc932 to 24e1151 Compare July 8, 2024 05:43
@mordante mordante force-pushed the users/mordante/zoned_time__zoned_seconds branch from e12d450 to 711d47e Compare July 8, 2024 10:45
@ldionne ldionne self-assigned this Jul 9, 2024
@ldionne ldionne added this to the LLVM 19.X Release milestone Jul 9, 2024
@mordante mordante force-pushed the users/mordante/zoned_time__operator== branch 3 times, most recently from c2640df to 7ec00b6 Compare July 10, 2024 12:42
Base automatically changed from users/mordante/zoned_time__operator== to main July 10, 2024 14:06
Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
@mordante mordante force-pushed the users/mordante/zoned_time__zoned_seconds branch from 711d47e to a7a2023 Compare July 10, 2024 14:08
@mordante mordante merged commit eae174c into main Jul 10, 2024
52 of 54 checks passed
@mordante mordante deleted the users/mordante/zoned_time__zoned_seconds branch July 10, 2024 16:35
aaryanshukla pushed a commit to aaryanshukla/llvm-project that referenced this pull request Jul 14, 2024
Implements parts of:
- P0355 Extending to chrono Calendars and Time Zones
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
None yet
Development

Successfully merging this pull request may close these issues.

3 participants