2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP___CHRONO_DAY_H
11 #define _LIBCPP___CHRONO_DAY_H
13 #include <__chrono/duration.h>
14 #include <__compare/ordering.h>
17 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
18 # pragma GCC system_header
21 #if _LIBCPP_STD_VER >= 20
23 _LIBCPP_BEGIN_NAMESPACE_STD
33 _LIBCPP_HIDE_FROM_ABI
explicit inline constexpr day(unsigned __val
) noexcept
34 : __d_(static_cast<unsigned char>(__val
)) {}
35 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
& operator++() noexcept
{
39 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
operator++(int) noexcept
{
44 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
& operator--() noexcept
{
48 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
operator--(int) noexcept
{
53 _LIBCPP_HIDE_FROM_ABI
constexpr day
& operator+=(const days
& __dd
) noexcept
;
54 _LIBCPP_HIDE_FROM_ABI
constexpr day
& operator-=(const days
& __dd
) noexcept
;
55 _LIBCPP_HIDE_FROM_ABI
explicit inline constexpr operator unsigned() const noexcept
{ return __d_
; }
56 _LIBCPP_HIDE_FROM_ABI
inline constexpr bool ok() const noexcept
{ return __d_
>= 1 && __d_
<= 31; }
59 _LIBCPP_HIDE_FROM_ABI
inline constexpr bool operator==(const day
& __lhs
, const day
& __rhs
) noexcept
{
60 return static_cast<unsigned>(__lhs
) == static_cast<unsigned>(__rhs
);
63 _LIBCPP_HIDE_FROM_ABI
inline constexpr strong_ordering
operator<=>(const day
& __lhs
, const day
& __rhs
) noexcept
{
64 return static_cast<unsigned>(__lhs
) <=> static_cast<unsigned>(__rhs
);
67 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
operator+(const day
& __lhs
, const days
& __rhs
) noexcept
{
68 return day(static_cast<unsigned>(__lhs
) + __rhs
.count());
71 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
operator+(const days
& __lhs
, const day
& __rhs
) noexcept
{
75 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
operator-(const day
& __lhs
, const days
& __rhs
) noexcept
{
76 return __lhs
+ -__rhs
;
79 _LIBCPP_HIDE_FROM_ABI
inline constexpr days
operator-(const day
& __lhs
, const day
& __rhs
) noexcept
{
80 return days(static_cast<int>(static_cast<unsigned>(__lhs
)) - static_cast<int>(static_cast<unsigned>(__rhs
)));
83 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
& day::operator+=(const days
& __dd
) noexcept
{
88 _LIBCPP_HIDE_FROM_ABI
inline constexpr day
& day::operator-=(const days
& __dd
) noexcept
{
95 _LIBCPP_END_NAMESPACE_STD
97 #endif // _LIBCPP_STD_VER >= 20
99 #endif // _LIBCPP___CHRONO_DAY_H