Files
2025-10-25 03:02:53 +03:00

12 KiB

[time.cal.ymwdlast]

30 Time library [time]

30.8 The civil calendar [time.cal]

30.8.17 Class year_month_weekday_last [time.cal.ymwdlast]

30.8.17.1 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 onlypublic: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

#

year_month_weekday_last represents a specific year, month, and last weekday of the month.

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.

[Note 1:

year_month_weekday_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_weekday_last meets the Cpp17EqualityComparable (Table 28) requirements.

2

#

year_month_weekday_last is a trivially copyable and standard-layout class type.

30.8.17.2 Member functions [time.cal.ymwdlast.members]

🔗

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

1

#

Effects: Initializes y_ with y, m_ with m, and wdl_ with wdl.

🔗

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

2

#

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]).

3

#

Effects: *this = *this + m.

4

#

Returns: *this.

🔗

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

5

#

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]).

6

#

Effects: *this = *this - m.

7

#

Returns: *this.

🔗

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

8

#

Effects: *this = *this + y.

9

#

Returns: *this.

🔗

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

10

#

Effects: *this = *this - y.

11

#

Returns: *this.

🔗

constexpr chrono::year year() const noexcept;

12

#

Returns: y_.

🔗

constexpr chrono::month month() const noexcept;

13

#

Returns: m_.

🔗

constexpr chrono::weekday weekday() const noexcept;

14

#

Returns: wdl_.weekday().

🔗

constexpr chrono::weekday_last weekday_last() const noexcept;

15

#

Returns: wdl_.

🔗

constexpr operator sys_days() const noexcept;

16

#

Returns: If ok() == true, returns a sys_days that represents the last weekday() of year()/month().

Otherwise the returned value is unspecified.

🔗

constexpr explicit operator local_days() const noexcept;

17

#

Returns: local_days{sys_days{*this}.time_since_epoch()}.

🔗

constexpr bool ok() const noexcept;

18

#

Returns: y_.ok() && m_.ok() && wdl_.ok().

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

🔗

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

1

#

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

🔗

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

2

#

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]).

3

#

Returns: (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last().

🔗

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

4

#

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]).

5

#

Returns: ymwdl + dm.

🔗

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

6

#

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]).

7

#

Returns: ymwdl + (-dm).

🔗

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

8

#

Returns: {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()}.

🔗

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

9

#

Returns: ymwdl + dy.

🔗

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

10

#

Returns: ymwdl + (-dy).

🔗

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

11

#

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