27 Time library [time]

27.8 The civil calendar [time.cal]

27.8.14 Class year_­month_­day [time.cal.ymd]

27.8.14.2 Member functions [time.cal.ymd.members]

constexpr year_month_day(const chrono::year& y, const chrono::month& m, const chrono::day& d) noexcept;
Effects: Initializes y_­ with y, m_­ with m, and d_­ with d.
constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
Effects: Initializes y_­ with ymdl.year(), m_­ with ymdl.month(), and d_­ with ymdl.day().
[Note 1:
This conversion from year_­month_­day_­last to year_­month_­day might be more efficient than converting a year_­month_­day_­last to a sys_­days, and then converting that sys_­days to a year_­month_­day.
— end note]
constexpr year_month_day(const sys_days& dp) noexcept;
Effects: Constructs an object of type year_­month_­day that corresponds to the date represented by dp.
Remarks: For any value ymd of type year_­month_­day for which ymd.ok() is true, ymd == year_­month_­day{sys_­days{ymd}} is true.
constexpr explicit year_month_day(const local_days& dp) noexcept;
Effects: Equivalent to constructing with sys_­days{dp.time_­since_­epoch()}.
constexpr year_month_day& 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& 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& year_month_day::operator+=(const years& y) noexcept;
Effects: *this = *this + y.
Returns: *this.
constexpr year_month_day& year_month_day::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: m_­.
constexpr chrono::day day() const noexcept;
Returns: d_­.
constexpr operator sys_days() const noexcept;
Returns: If ok(), returns a sys_­days holding a count of days from the sys_­days epoch to *this (a negative value if *this represents a date prior to the sys_­days epoch).
Otherwise, if y_­.ok() && m_­.ok() is true, returns sys_­days{y_­/m_­/1d} + (d_­ - 1d).
Otherwise the value returned is unspecified.
Remarks: A sys_­days in the range [days{-12687428}, days{11248737}] which is converted to a year_­month_­day has the same value when converted back to a sys_­days.
[Example 1: static_assert(year_month_day{sys_days{2017y/January/0}} == 2016y/December/31); static_assert(year_month_day{sys_days{2017y/January/31}} == 2017y/January/31); static_assert(year_month_day{sys_days{2017y/January/32}} == 2017y/February/1); — end example]
constexpr explicit operator local_days() const noexcept;
Returns: local_­days{sys_­days{*this}.time_­since_­epoch()}.
constexpr bool ok() const noexcept;
Returns: If y_­.ok() is true, and m_­.ok() is true, and d_­ is in the range [1d, (y_­/m_­/last).day()], then returns true; otherwise returns false.