Skip to content

year_month_day

Header: chrono.h
From: 20.41.0
Similar to: std::chrono::year_month_day

A class representing a year, month, and day.

class year_month_day

Construction

ETL_CONSTEXPR year_month_day()

Description
Default constructor.


ETL_CONSTEXPR14 
year_month_day(const etl::chrono::year&  y, 
               const etl::chrono::month& m, 
               const etl::chrono::day&   d) 
ETL_NOEXCEPT

Description
Construct from month and day.


ETL_CONSTEXPR14 
year_month_day(const etl::chrono::year_month_day_last& ymdl) 
ETL_NOEXCEPT

Description
Construct from year_month_day_last.


ETL_CONSTEXPR14 
year_month_day(const etl::chrono::sys_days& sd) 
ETL_NOEXCEPT

Description
Construct from sys_days.


ETL_CONSTEXPR14
year_month_day(const etl::chrono::local_days& ld) 
ETL_NOEXCEPT

Description
Construct from local_days.

Access

ETL_NODISCARD
ETL_CONSTEXPR14 
etl::chrono::year year() const 
ETL_NOEXCEPT

Return
The year.


ETL_NODISCARD
ETL_CONSTEXPR14 
etl::chrono::month month() const 
ETL_NOEXCEPT

Return
The month.


ETL_NODISCARD
ETL_CONSTEXPR14 etl::chrono::day day() const
ETL_NOEXCEPT

Return
The day.

Tests

ETL_NODISCARD
ETL_CONSTEXPR14 
bool ok() const 
ETL_NOEXCEPT

Return
true if the year and month is within the valid limits.


ETL_NODISCARD
ETL_CONSTEXPR14 
int compare(const etl::chrono::year_month_day& other) const 
ETL_NOEXCEPT

Description
Compare year_month_day with another.
if year < other.year, returns -1
else if year > other.year, returns 1
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

operators

ETL_CONSTEXPR14 
etl::chrono::year_month_day& operator +=(const etl::chrono::years& dy) 
ETL_NOEXCEPT

Description
Adds etl::chrono::years.


ETL_CONSTEXPR14 
etl::chrono::year_month_day& operator +=(const etl::chrono::months& dm) 
ETL_NOEXCEPT

Description
Adds etl::chrono::months.


ETL_CONSTEXPR14
etl::chrono::year_month_day& operator -=(const etl::chrono::years& dy)
ETL_NOEXCEPT

Description
Subtracts etl::chrono::years.


ETL_CONSTEXPR14 
etl::chrono::year_month_day& operator -=(const etl::chrono::months& dm)
ETL_NOEXCEPT

Description
Subtracts etl::chrono::months.

Non-member operators

ETL_CONSTEXPR14
etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ym,
                                       const etl::chrono::years&          dy)

Description
Adds etl::chrono::years.


ETL_CONSTEXPR14
etl::chrono::year_month_day operator +(const etl::chrono::years&          dy,
                                       const etl::chrono::year_month_day& ym) 
ETL_NOEXCEPT

Description
Adds etl::chrono::years.


ETL_CONSTEXPR14
etl::chrono::year_month_day operator +(const etl::chrono::year_month_day& ym,
                                       const etl::chrono::months&         dm) 
ETL_NOEXCEPT

Description
Adds etl::chrono::months.


ETL_CONSTEXPR14 
etl::chrono::year_month operator +(const etl::chrono::months&         dm,
                                   const etl::chrono::year_month_day& ym) 
ETL_NOEXCEPT

Description
Adds etl::chrono::months.


ETL_CONSTEXPR14 
etl::chrono::year_month operator -(const etl::chrono::year_month_day& ym,
                                   const etl::chrono::years&          dy) 
ETL_NOEXCEPT

Description
Subtracts etl::chrono::years.


ETL_CONSTEXPR14 
etl::chrono::year_month operator -(const etl::chrono::year_month_day& ym,
                                   const etl::chrono::months&         dm) 
ETL_NOEXCEPT

Description
Subtracts etl::chrono::months.

Non-member comparison operators

ETL_CONSTEXPR14 
bool operator ==(const etl::chrono::year_month_day& lhs, 
                 const etl::chrono::year_month_day& rhs) 
ETL_NOEXCEPT

Description
Equality operator.


ETL_CONSTEXPR14 
bool operator !=(const etl::chrono::year_month_day& lhs, 
                 const etl::chrono::year_month_day& rhs) 
ETL_NOEXCEPT

Description
Inequality operator.


[[nodiscard]] friend constexpr
auto operator <=>(const etl::chrono::year_month_day& lhs, 
                  const etl::chrono::year_month_day& rhs)
ETL_NOEXCEPT

Description
Spaceship operator
C++20

Hash

template <>
struct hash<etl::chrono::year_month_day>

Description
Hash function for etl::chrono::year_month_day.