29 Time library [time]

29.8 The civil calendar [time.cal]

29.8.15 Class year_month_day_last [time.cal.ymdlast]

29.8.15.1 Overview [time.cal.ymdlast.overview]

namespace std::chrono { class year_month_day_last { chrono::year y_; // exposition only chrono::month_day_last mdl_; // exposition only public: constexpr year_month_day_last(const chrono::year& y, const chrono::month_day_last& mdl) noexcept; constexpr year_month_day_last& operator+=(const months& m) noexcept; constexpr year_month_day_last& operator-=(const months& m) noexcept; constexpr year_month_day_last& operator+=(const years& y) noexcept; constexpr year_month_day_last& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::month_day_last month_day_last() const noexcept; constexpr chrono::day day() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; }; }
year_month_day_last represents the last day of a specific year and month.
year_month_day_last is a field-based time point with a resolution of days, except that it is restricted to pointing to the last day of a year and month.
[Note 1: 
year_month_day_last supports years- and months-oriented arithmetic, but not days-oriented arithmetic.
For the latter, there is a conversion to sys_days, which efficiently supports days-oriented arithmetic.
— end note]
year_month_day_last meets the Cpp17EqualityComparable (Table 28) and Cpp17LessThanComparable (Table 29) requirements.
year_month_day_last is a trivially copyable and standard-layout class type.

29.8.15.2 Member functions [time.cal.ymdlast.members]

constexpr year_month_day_last(const chrono::year& y, const chrono::month_day_last& mdl) noexcept;
Effects: Initializes y_ with y and mdl_ with mdl.
constexpr year_month_day_last& operator+=(const months& m) noexcept;
Constraints: If the argument supplied by the caller for the months parameter is convertible to years, its implicit conversion sequence to years is worse than its implicit conversion sequence to months ([over.ics.rank]).
Effects: *this = *this + m.
Returns: *this.
constexpr year_month_day_last& operator-=(const months& m) noexcept;
Constraints: If the argument supplied by the caller for the months parameter is convertible to years, its implicit conversion sequence to years is worse than its implicit conversion sequence to months ([over.ics.rank]).
Effects: *this = *this - m.
Returns: *this.
constexpr year_month_day_last& operator+=(const years& y) noexcept;
Effects: *this = *this + y.
Returns: *this.
constexpr year_month_day_last& operator-=(const years& y) noexcept;
Effects: *this = *this - y.
Returns: *this.
constexpr chrono::year year() const noexcept;
Returns: y_.
constexpr chrono::month month() const noexcept;
Returns: mdl_.month().
constexpr chrono::month_day_last month_day_last() const noexcept;
Returns: mdl_.
constexpr chrono::day day() const noexcept;
Returns: If ok() is true, returns a day representing the last day of the (year, month) pair represented by *this.
Otherwise, the returned value is unspecified.
[Note 1: 
This value might be computed on demand.
— end note]
constexpr operator sys_days() const noexcept;
Returns: sys_days{year()/month()/day()}.
constexpr explicit operator local_days() const noexcept;
Returns: local_days{sys_days{*this}.time_since_epoch()}.
constexpr bool ok() const noexcept;
Returns: y_.ok() && mdl_.ok().

29.8.15.3 Non-member functions [time.cal.ymdlast.nonmembers]

constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
Returns: x.year() == y.year() && x.month_day_last() == y.month_day_last().
constexpr strong_ordering operator<=>(const year_month_day_last& x, const year_month_day_last& y) noexcept;
Effects: Equivalent to: if (auto c = x.year() <=> y.year(); c != 0) return c; return x.month_day_last() <=> y.month_day_last();
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
Constraints: If the argument supplied by the caller for the months parameter is convertible to years, its implicit conversion sequence to years is worse than its implicit conversion sequence to months ([over.ics.rank]).
Returns: (ymdl.year() / ymdl.month() + dm) / last.
constexpr year_month_day_last operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
Constraints: If the argument supplied by the caller for the months parameter is convertible to years, its implicit conversion sequence to years is worse than its implicit conversion sequence to months ([over.ics.rank]).
Returns: ymdl + dm.
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
Constraints: If the argument supplied by the caller for the months parameter is convertible to years, its implicit conversion sequence to years is worse than its implicit conversion sequence to months ([over.ics.rank]).
Returns: ymdl + (-dm).
constexpr year_month_day_last operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
Returns: {ymdl.year()+dy, ymdl.month_day_last()}.
constexpr year_month_day_last operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
Returns: ymdl + dy.
constexpr year_month_day_last operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
Returns: ymdl + (-dy).
template<class charT, class traits> basic_ostream<charT, traits>& operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
Effects: Equivalent to: return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}"), ymdl.year(), ymdl.month_day_last());