3#ifndef TETL_CHRONO_MONTH_HPP
4#define TETL_CHRONO_MONTH_HPP
24 constexpr explicit month(
unsigned m) noexcept
25 : _count{
static_cast<unsigned char>(m)}
30 [[nodiscard]]
constexpr auto ok() const noexcept ->
bool {
return (_count > 0U) and (_count <= 12U); }
32 constexpr explicit operator unsigned() const noexcept {
return _count; }
35 constexpr auto operator++(
int) noexcept ->
month;
36 constexpr auto operator--() noexcept ->
month&;
37 constexpr auto operator--(
int) noexcept ->
month;
39 constexpr auto operator+=(
months const& m) noexcept ->
month&;
40 constexpr auto operator-=(
months const& m) noexcept ->
month&;
46[[nodiscard]] constexpr auto operator==(
month lhs,
month rhs) noexcept ->
bool
48 return static_cast<unsigned>(lhs) ==
static_cast<unsigned>(rhs);
53 return static_cast<unsigned>(lhs) <
static_cast<unsigned>(rhs);
58 return static_cast<unsigned>(lhs) <=
static_cast<unsigned>(rhs);
63 return static_cast<unsigned>(lhs) >
static_cast<unsigned>(rhs);
68 return static_cast<unsigned>(lhs) >=
static_cast<unsigned>(rhs);
73 auto const mo =
static_cast<long long>(
static_cast<unsigned>(m)) + (ms.count() - 1);
74 auto const div = (mo >= 0 ? mo : mo - 11) / 12;
75 return month{
static_cast<unsigned int>(mo -
div * 12 + 1)};
84 auto const delta =
static_cast<unsigned>(m1) -
static_cast<unsigned>(m2);
103 *
this = *
this -
months{1};
#define TETL_PRECONDITION(...)
Definition check.hpp:16
constexpr auto February
Definition month.hpp:127
constexpr auto operator<(duration< Rep1, Period1 > const &lhs, duration< Rep2, Period2 > const &rhs) -> bool
Compares two durations. Compares lhs to rhs, i.e. compares the number of ticks for the type common to...
Definition duration.hpp:316
constexpr auto operator+(day const &d, days const &ds) noexcept -> day
Definition day.hpp:92
constexpr auto operator>(duration< Rep1, Period1 > const &lhs, duration< Rep2, Period2 > const &rhs) -> bool
Compares two durations. Compares lhs to rhs, i.e. compares the number of ticks for the type common to...
Definition duration.hpp:333
constexpr auto July
Definition month.hpp:132
duration< int_least32_t, ratio< 31556952 > > months
Signed integer type of at least 20 bits.
Definition duration.hpp:371
constexpr auto October
Definition month.hpp:135
constexpr auto January
Definition month.hpp:126
constexpr auto August
Definition month.hpp:133
constexpr auto June
Definition month.hpp:131
constexpr auto March
Definition month.hpp:128
constexpr auto April
Definition month.hpp:129
constexpr auto operator<=(duration< Rep1, Period1 > const &lhs, duration< Rep2, Period2 > const &rhs) -> bool
Compares two durations. Compares lhs to rhs, i.e. compares the number of ticks for the type common to...
Definition duration.hpp:325
constexpr auto May
Definition month.hpp:130
constexpr auto November
Definition month.hpp:136
constexpr auto September
Definition month.hpp:134
constexpr auto December
Definition month.hpp:137
constexpr auto operator-(day const &d, days const &ds) noexcept -> day
Definition day.hpp:102
constexpr auto operator>=(duration< Rep1, Period1 > const &lhs, duration< Rep2, Period2 > const &rhs) -> bool
Compares two durations. Compares lhs to rhs, i.e. compares the number of ticks for the type common to...
Definition duration.hpp:341
constexpr auto div(int x, int y) noexcept -> div_t
Computes both the quotient and the remainder of the division of the numerator x by the denominator y....
Definition div.hpp:37
TETL_BUILTIN_INT32 int_least32_t
Signed integer type with width of at least 32 bits.
Definition int_least_t.hpp:17
The class month represents a month in a year.
Definition month.hpp:21
constexpr auto operator-=(months const &m) noexcept -> month &
Definition month.hpp:120
constexpr auto ok() const noexcept -> bool
Definition month.hpp:30
constexpr auto operator+=(months const &m) noexcept -> month &
Definition month.hpp:114
constexpr month(unsigned m) noexcept
Definition month.hpp:24
constexpr auto operator--() noexcept -> month &
Definition month.hpp:101
constexpr auto operator++() noexcept -> month &
Definition month.hpp:88
static constexpr auto max() noexcept
Definition numeric_limits.hpp:21