year_month
A template representing a year and month.
Back to chrono
____________________________________________________________________________________________________
year_month
STL equivalent: std::chrono::year_month
class year_month
____________________________________________________________________________________________________
Construction
ETL_CONSTEXPR
year_month()
Default constructor.
______________________________________________
ETL_CONSTEXPR14
year_month(const etl::chrono::year& y,
const etl::chrono::month& m)
ETL_NOEXCEPT
Construct from month and day.
____________________________________________________________________________________________________
Access
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::year year() const
ETL_NOEXCEPT
Returns the year.
______________________________________________
ETL_NODISCARD
ETL_CONSTEXPR14
etl::chrono::month month() const
ETL_NOEXCEPT
Returns the month.
____________________________________________________________________________________________________
Tests
ETL_NODISCARD
ETL_CONSTEXPR14
bool ok() const
ETL_NOEXCEPT
Returns true if the year and month is within the valid limits.
______________________________________________
ETL_NODISCARD
ETL_CONSTEXPR14
int compare(const etl::chrono::year_month& other) const
ETL_NOEXCEPT
if (y < other.y) return -1
if (y > other.y) return 1
if (m < other.m) return -1
if (m > other.m) return 1
else return 0
____________________________________________________________________________________________________
Non-member mathematical operators
ETL_CONSTEXPR14
etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
const etl::chrono::years& dy)
Adds etl::chrono::years.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::year_month operator +(const etl::chrono::years& dy,
const etl::chrono::year_month& ym)
ETL_NOEXCEPT
Adds etl::chrono::years.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::year_month operator +(const etl::chrono::year_month& ym,
const etl::chrono::months& dm)
ETL_NOEXCEPT
Adds etl::chrono::months.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::year_month operator +(const etl::chrono::months& dm,
const etl::chrono::year_month& ym)
ETL_NOEXCEPT
Adds etl::chrono::months.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
const etl::chrono::years& dy)
ETL_NOEXCEPT
Subtracts etl::chrono::years.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::year_month operator -(const etl::chrono::year_month& ym,
const etl::chrono::months& dm)
ETL_NOEXCEPT
Subtracts etl::chrono::months.
______________________________________________
ETL_CONSTEXPR14
etl::chrono::months operator -(const etl::chrono::year_month& ym1,
const etl::chrono::year_month& ym2)
ETL_NOEXCEPT
Subtracts etl::chrono::year_month.
____________________________________________________________________________________________________
Non-member comparison operators
ETL_CONSTEXPR14
bool operator ==(const etl::chrono::year_month& lhs,
const etl::chrono::year_month& rhs)
ETL_NOEXCEPT
Equality operator.
______________________________________________
ETL_CONSTEXPR14
bool operator !=(const etl::chrono::year_month& lhs,
const etl::chrono::year_month& rhs)
ETL_NOEXCEPT
Inequality operator.
______________________________________________
[[nodiscard]] friend constexpr
auto operator <=>(const etl::chrono::year_month& lhs,
const etl::chrono::year_month& rhs)
ETL_NOEXCEPT
Spaceship operator
______________________________________________
ETL_CONSTEXPR14
int compare(const year_month& other) const
ETL_NOEXCEPT
Compare year_month with another.
if month < other.month, returns -1
else if month > other.month, returns 1
else if day < other.day, returns -1
else if day > other.day, returns 1
else returns 0;
____________________________________________________________________________________________________
Hash
template <typename TRep, typename TPeriod>
struct hash<etl::chrono::year_month>
Hash function for etl::chrono::year_month