[time.cal.ymwdlast]

# 30 Time library [[time]](./#time)

## 30.8 The civil calendar [[time.cal]](time.cal#ymwdlast)

### 30.8.17 Class year_month_weekday_last [time.cal.ymwdlast]

#### [30.8.17.1](#overview) Overview [[time.cal.ymwdlast.overview]](time.cal.ymwdlast.overview)

namespace std::chrono {class year_month_weekday_last { chrono::year y_; // *exposition only* chrono::month m_; // *exposition only* chrono::weekday_last wdl_; // *exposition only*public:constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m, const chrono::weekday_last& wdl) noexcept; constexpr year_month_weekday_last& operator+=(const months& m) noexcept; constexpr year_month_weekday_last& operator-=(const months& m) noexcept; constexpr year_month_weekday_last& operator+=(const years& y) noexcept; constexpr year_month_weekday_last& operator-=(const years& y) noexcept; constexpr chrono::year year() const noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::weekday weekday() const noexcept; constexpr chrono::weekday_last weekday_last() const noexcept; constexpr operator sys_days() const noexcept; constexpr explicit operator local_days() const noexcept; constexpr bool ok() const noexcept; };}

[1](#overview-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7586)

year_month_weekday_last represents a specific year, month,
and last weekday of the month[.](#overview-1.sentence-1)

year_month_weekday_last is a field-based time point with a resolution of days,
except that it is restricted to pointing to the last weekday of a year and month[.](#overview-1.sentence-2)

[*Note [1](#overview-note-1)*:

year_month_weekday_last supports years- and months-oriented arithmetic,
but not days-oriented arithmetic[.](#overview-1.sentence-3)

For the latter, there is a conversion to sys_days,
which efficiently supports days-oriented arithmetic[.](#overview-1.sentence-4)

â *end note*]

year_month_weekday_last meets the [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements")) requirements[.](#overview-1.sentence-5)

[2](#overview-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7599)

year_month_weekday_last is a trivially copyable and standard-layout class type[.](#overview-2.sentence-1)

#### [30.8.17.2](#members) Member functions [[time.cal.ymwdlast.members]](time.cal.ymwdlast.members)

[ð](#lib:year_month_weekday_last,constructor)

`constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
                                  const chrono::weekday_last& wdl) noexcept;
`

[1](#members-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7611)

*Effects*: Initializes y_ with y, m_ with m, and wdl_ with wdl[.](#members-1.sentence-1)

[ð](#lib:operator+=,year_month_weekday_last)

`constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
`

[2](#members-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7622)

*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 tomonths ([[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"))[.](#members-2.sentence-1)

[3](#members-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7630)

*Effects*: *this = *this + m[.](#members-3.sentence-1)

[4](#members-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7634)

*Returns*: *this[.](#members-4.sentence-1)

[ð](#lib:operator-=,year_month_weekday_last)

`constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
`

[5](#members-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7645)

*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 tomonths ([[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"))[.](#members-5.sentence-1)

[6](#members-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7653)

*Effects*: *this = *this - m[.](#members-6.sentence-1)

[7](#members-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7657)

*Returns*: *this[.](#members-7.sentence-1)

[ð](#lib:operator+=,year_month_weekday_last_)

`constexpr year_month_weekday_last& operator+=(const years& y) noexcept;
`

[8](#members-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7668)

*Effects*: *this = *this + y[.](#members-8.sentence-1)

[9](#members-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7672)

*Returns*: *this[.](#members-9.sentence-1)

[ð](#lib:operator-=,year_month_weekday_last_)

`constexpr year_month_weekday_last& operator-=(const years& y) noexcept;
`

[10](#members-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7683)

*Effects*: *this = *this - y[.](#members-10.sentence-1)

[11](#members-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7687)

*Returns*: *this[.](#members-11.sentence-1)

[ð](#lib:year,year_month_weekday_last)

`constexpr chrono::year year() const noexcept;
`

[12](#members-12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7698)

*Returns*: y_[.](#members-12.sentence-1)

[ð](#lib:month,year_month_weekday_last)

`constexpr chrono::month month() const noexcept;
`

[13](#members-13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7709)

*Returns*: m_[.](#members-13.sentence-1)

[ð](#lib:weekday,year_month_weekday_last)

`constexpr chrono::weekday weekday() const noexcept;
`

[14](#members-14)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7720)

*Returns*: wdl_.weekday()[.](#members-14.sentence-1)

[ð](#lib:weekday_last,year_month_weekday_last)

`constexpr chrono::weekday_last weekday_last() const noexcept;
`

[15](#members-15)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7731)

*Returns*: wdl_[.](#members-15.sentence-1)

[ð](#lib:operator_sys_days,year_month_weekday_last)

`constexpr operator sys_days() const noexcept;
`

[16](#members-16)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7742)

*Returns*: If ok() == true,
returns a sys_days that represents
the last weekday() of year()/month()[.](#members-16.sentence-1)

Otherwise the returned value is unspecified[.](#members-16.sentence-2)

[ð](#lib:operator_local_days,year_month_weekday_last)

`constexpr explicit operator local_days() const noexcept;
`

[17](#members-17)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7756)

*Returns*: local_days{sys_days{*this}.time_since_epoch()}[.](#members-17.sentence-1)

[ð](#lib:ok,year_month_weekday_last)

`constexpr bool ok() const noexcept;
`

[18](#members-18)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7767)

*Returns*: y_.ok() && m_.ok() && wdl_.ok()[.](#members-18.sentence-1)

#### [30.8.17.3](#nonmembers) Non-member functions [[time.cal.ymwdlast.nonmembers]](time.cal.ymwdlast.nonmembers)

[ð](#lib:operator==,year_month_weekday_last)

`constexpr bool operator==(const year_month_weekday_last& x,
                          const year_month_weekday_last& y) noexcept;
`

[1](#nonmembers-1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7781)

*Returns*: x.year() == y.year() && x.month() == y.month() && x.weekday_last() == y.weekday_last()

[ð](#lib:operator+,year_month_weekday_last)

`constexpr year_month_weekday_last
  operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
`

[2](#nonmembers-2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7795)

*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 tomonths ([[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"))[.](#nonmembers-2.sentence-1)

[3](#nonmembers-3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7803)

*Returns*: (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last()[.](#nonmembers-3.sentence-1)

[ð](#lib:operator+,year_month_weekday_last_)

`constexpr year_month_weekday_last
  operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
`

[4](#nonmembers-4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7815)

*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 tomonths ([[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"))[.](#nonmembers-4.sentence-1)

[5](#nonmembers-5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7823)

*Returns*: ymwdl + dm[.](#nonmembers-5.sentence-1)

[ð](#lib:operator-,year_month_weekday_last)

`constexpr year_month_weekday_last
  operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
`

[6](#nonmembers-6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7835)

*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 tomonths ([[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"))[.](#nonmembers-6.sentence-1)

[7](#nonmembers-7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7843)

*Returns*: ymwdl + (-dm)[.](#nonmembers-7.sentence-1)

[ð](#lib:operator+,year_month_weekday_last__)

`constexpr year_month_weekday_last
  operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
`

[8](#nonmembers-8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7855)

*Returns*: {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()}[.](#nonmembers-8.sentence-1)

[ð](#lib:operator+,year_month_weekday_last___)

`constexpr year_month_weekday_last
  operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
`

[9](#nonmembers-9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7867)

*Returns*: ymwdl + dy[.](#nonmembers-9.sentence-1)

[ð](#lib:operator-,year_month_weekday_last_)

`constexpr year_month_weekday_last
  operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
`

[10](#nonmembers-10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7879)

*Returns*: ymwdl + (-dy)[.](#nonmembers-10.sentence-1)

[ð](#lib:operator%3c%3c,year_month_weekday_last)

`template<class charT, class traits>
  basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
`

[11](#nonmembers-11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L7892)

*Effects*: Equivalent to:return os << format(os.getloc(), *STATICALLY-WIDEN*<charT>("{}/{:L}/{:L}"),
 ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
