File indexing completed on 2026-05-03 08:13:24
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef _LIBCPP___CXX03___CHRONO_MONTH_H
0011 #define _LIBCPP___CXX03___CHRONO_MONTH_H
0012
0013 #include <__cxx03/__chrono/duration.h>
0014 #include <__cxx03/__config>
0015 #include <__cxx03/compare>
0016
0017 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0018 # pragma GCC system_header
0019 #endif
0020
0021 #if _LIBCPP_STD_VER >= 20
0022
0023 _LIBCPP_BEGIN_NAMESPACE_STD
0024
0025 namespace chrono {
0026
0027 class month {
0028 private:
0029 unsigned char __m_;
0030
0031 public:
0032 month() = default;
0033 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr month(unsigned __val) noexcept
0034 : __m_(static_cast<unsigned char>(__val)) {}
0035 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator++() noexcept {
0036 *this += months{1};
0037 return *this;
0038 }
0039 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator++(int) noexcept {
0040 month __tmp = *this;
0041 ++(*this);
0042 return __tmp;
0043 }
0044 _LIBCPP_HIDE_FROM_ABI inline constexpr month& operator--() noexcept {
0045 *this -= months{1};
0046 return *this;
0047 }
0048 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator--(int) noexcept {
0049 month __tmp = *this;
0050 --(*this);
0051 return __tmp;
0052 }
0053 _LIBCPP_HIDE_FROM_ABI constexpr month& operator+=(const months& __m1) noexcept;
0054 _LIBCPP_HIDE_FROM_ABI constexpr month& operator-=(const months& __m1) noexcept;
0055 _LIBCPP_HIDE_FROM_ABI explicit inline constexpr operator unsigned() const noexcept { return __m_; }
0056 _LIBCPP_HIDE_FROM_ABI inline constexpr bool ok() const noexcept { return __m_ >= 1 && __m_ <= 12; }
0057 };
0058
0059 _LIBCPP_HIDE_FROM_ABI inline constexpr bool operator==(const month& __lhs, const month& __rhs) noexcept {
0060 return static_cast<unsigned>(__lhs) == static_cast<unsigned>(__rhs);
0061 }
0062
0063 _LIBCPP_HIDE_FROM_ABI inline constexpr strong_ordering operator<=>(const month& __lhs, const month& __rhs) noexcept {
0064 return static_cast<unsigned>(__lhs) <=> static_cast<unsigned>(__rhs);
0065 }
0066
0067 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const month& __lhs, const months& __rhs) noexcept {
0068 auto const __mu = static_cast<long long>(static_cast<unsigned>(__lhs)) + (__rhs.count() - 1);
0069 auto const __yr = (__mu >= 0 ? __mu : __mu - 11) / 12;
0070 return month{static_cast<unsigned>(__mu - __yr * 12 + 1)};
0071 }
0072
0073 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator+(const months& __lhs, const month& __rhs) noexcept {
0074 return __rhs + __lhs;
0075 }
0076
0077 _LIBCPP_HIDE_FROM_ABI inline constexpr month operator-(const month& __lhs, const months& __rhs) noexcept {
0078 return __lhs + -__rhs;
0079 }
0080
0081 _LIBCPP_HIDE_FROM_ABI inline constexpr months operator-(const month& __lhs, const month& __rhs) noexcept {
0082 auto const __dm = static_cast<unsigned>(__lhs) - static_cast<unsigned>(__rhs);
0083 return months(__dm <= 11 ? __dm : __dm + 12);
0084 }
0085
0086 _LIBCPP_HIDE_FROM_ABI inline constexpr month& month::operator+=(const months& __dm) noexcept {
0087 *this = *this + __dm;
0088 return *this;
0089 }
0090
0091 _LIBCPP_HIDE_FROM_ABI inline constexpr month& month::operator-=(const months& __dm) noexcept {
0092 *this = *this - __dm;
0093 return *this;
0094 }
0095
0096 inline constexpr month January{1};
0097 inline constexpr month February{2};
0098 inline constexpr month March{3};
0099 inline constexpr month April{4};
0100 inline constexpr month May{5};
0101 inline constexpr month June{6};
0102 inline constexpr month July{7};
0103 inline constexpr month August{8};
0104 inline constexpr month September{9};
0105 inline constexpr month October{10};
0106 inline constexpr month November{11};
0107 inline constexpr month December{12};
0108
0109 }
0110
0111 _LIBCPP_END_NAMESPACE_STD
0112
0113 #endif
0114
0115 #endif