llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-libcxx Author: Mark de Wever (mordante) <details> <summary>Changes</summary> Implements parts of: - P0355 Extending to chrono Calendars and Time Zones - P1614R2 The Mothership has Landed --- Full diff: https://github.com/llvm/llvm-project/pull/95140.diff 4 Files Affected: - (modified) libcxx/docs/Status/SpaceshipProjects.csv (+2-2) - (modified) libcxx/include/__chrono/zoned_time.h (+6) - (modified) libcxx/include/chrono (+4) - (added) libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp (+71) ``````````diff diff --git a/libcxx/docs/Status/SpaceshipProjects.csv b/libcxx/docs/Status/SpaceshipProjects.csv index 128b23b0c2c74..74441dcdea496 100644 --- a/libcxx/docs/Status/SpaceshipProjects.csv +++ b/libcxx/docs/Status/SpaceshipProjects.csv @@ -140,7 +140,7 @@ Section,Description,Dependencies,Assignee,Complete "| `[class.slice.overview] <https://wg21.link/class.slice.overview>`_ | `[slice.ops] <https://wg21.link/slice.ops>`_",| `slice <https://reviews.llvm.org/D152617>`_,None,Hristo Hristov,|Complete| - `5.12 Clause 27: Time library <https://wg21.link/p1614r2#clause-27-time-library>`_,,,, -| `[time.syn] <https://wg21.link/time.syn>`_,|,None,Mark de Wever,|In Progress| +| `[time.syn] <https://wg21.link/time.syn>`_,|,None,Mark de Wever,|Complete| | `[time.duration.comparisons] <https://wg21.link/time.duration.comparisons>`_, `chrono::duration <https://reviews.llvm.org/D145881>`_, None, Hristo Hristov, |Complete| | `[time.point.comparisons] <https://wg21.link/time.point.comparisons>`_, `chrono::time_point <https://reviews.llvm.org/D146250>`_, None, Hristo Hristov, |Complete| "| `[time.cal.day.nonmembers] <https://wg21.link/time.cal.day.nonmembers>`_ @@ -172,7 +172,7 @@ Section,Description,Dependencies,Assignee,Complete | `year_month_weekday <https://reviews.llvm.org/D152699>`_ | `year_month_weekday_last <https://reviews.llvm.org/D152699>`_",None,Hristo Hristov,|Complete| `[time.zone.nonmembers] <https://wg21.link/time.zone.nonmembers>`_,"`chrono::time_zone`",,Mark de Wever,|Complete| -`[time.zone.zonedtime.nonmembers] <https://wg21.link/time.zone.zonedtime.nonmembers>`_,"`chrono::zoned_time`",A ``<chrono>`` implementation,Mark de Wever,|In Progress| +`[time.zone.zonedtime.nonmembers] <https://wg21.link/time.zone.zonedtime.nonmembers>`_,"`chrono::zoned_time`",,Mark de Wever,|Complete| `[time.zone.leap.nonmembers] <https://wg21.link/time.zone.leap.nonmembers>`_,"`chrono::time_leap_seconds`",,Mark de Wever,|Complete| `[time.zone.link.nonmembers] <https://wg21.link/time.zone.link.nonmembers>`_,"`chrono::time_zone_link`",,Mark de Wever,|Complete| - `5.13 Clause 28: Localization library <https://wg21.link/p1614r2#clause-28-localization-library>`_,,,, diff --git a/libcxx/include/__chrono/zoned_time.h b/libcxx/include/__chrono/zoned_time.h index 33e0ac0603a6e..db5e67135d844 100644 --- a/libcxx/include/__chrono/zoned_time.h +++ b/libcxx/include/__chrono/zoned_time.h @@ -204,6 +204,12 @@ 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>>; +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) { + return __lhs.get_time_zone() == __rhs.get_time_zone() && __lhs.get_sys_time() == __rhs.get_sys_time(); +} + } // namespace chrono # endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) diff --git a/libcxx/include/chrono b/libcxx/include/chrono index 026e920342e1e..df7ebf45bd907 100644 --- a/libcxx/include/chrono +++ b/libcxx/include/chrono @@ -793,6 +793,10 @@ template<class T> struct zoned_traits; template<class Duration, class TimeZonePtr = const time_zone*> // C++20 class zoned_time; +template<class Duration1, class Duration2, class TimeZonePtr> // C++20 + bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, + const zoned_time<Duration2, TimeZonePtr>& y); + // [time.zone.leap], leap second support class leap_second { // C++20 public: diff --git a/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp new file mode 100644 index 0000000000000..2ccb060d24ee6 --- /dev/null +++ b/libcxx/test/std/time/time.zone/time.zone.zonedtime/time.zone.zonedtime.nonmembers/eq.pass.cpp @@ -0,0 +1,71 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 + +// REQUIRES: has-unix-headers +// REQUIRES: libcpp-hardening-mode={{extensive|debug}} +// XFAIL: libcpp-hardening-mode=debug && availability-verbose_abort-missing + +// XFAIL: libcpp-has-no-experimental-tzdb + +// <chrono> + +// template<class Duration1, class Duration2, class TimeZonePtr> +// bool operator==(const zoned_time<Duration1, TimeZonePtr>& x, +// const zoned_time<Duration2, TimeZonePtr>& y); +// +// Note operator!= is generated by the compiler + +#include <chrono> + +#include "test_comparisons.h" + +int main(int, char**) { + { + std::chrono::zoned_time zt; + assert(testEquality(zt, zt, true)); + } + { + std::chrono::zoned_time lhs{"UTC"}; + std::chrono::zoned_time rhs{"Europe/Berlin"}; + assert(testEquality(lhs, rhs, false)); + } + { + std::chrono::zoned_time lhs{"UTC", std::chrono::sys_time<std::chrono::seconds>{std::chrono::seconds{123}}}; + + assert(testEquality(lhs, + std::chrono::zoned_time{ + std::chrono::sys_time<std::chrono::nanoseconds>{std::chrono::nanoseconds{123'000'000'000}}}, + true)); + assert(testEquality(lhs, + std::chrono::zoned_time{ + std::chrono::sys_time<std::chrono::nanoseconds>{std::chrono::nanoseconds{123'000'000'001}}}, + false)); + + assert(testEquality(lhs, + std::chrono::zoned_time{ + std::chrono::sys_time<std::chrono::microseconds>{std::chrono::microseconds{123'000'000}}}, + true)); + assert(testEquality(lhs, + std::chrono::zoned_time{ + std::chrono::sys_time<std::chrono::microseconds>{std::chrono::microseconds{123'000'001}}}, + false)); + + assert(testEquality( + lhs, + std::chrono::zoned_time{std::chrono::sys_time<std::chrono::milliseconds>{std::chrono::milliseconds{123'000}}}, + true)); + assert(testEquality( + lhs, + std::chrono::zoned_time{std::chrono::sys_time<std::chrono::milliseconds>{std::chrono::milliseconds{123'001}}}, + false)); + } + + return 0; +} `````````` </details> https://github.com/llvm/llvm-project/pull/95140 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits