The types in [time.
cal] describe the civil (Gregorian) calendar
and its relationship to
sys_days and
local_days.
namespace std::chrono {
struct last_spec {
explicit last_spec() = default;
};
}
The type
last_spec is used
in conjunction with other calendar types
to specify the last in a sequence
. For example, depending on context,
it can represent the last day of a month,
or the last day of the week of a month
.namespace std::chrono {
class day {
unsigned char d_;
public:
day() = default;
constexpr explicit day(unsigned d) noexcept;
constexpr day& operator++() noexcept;
constexpr day operator++(int) noexcept;
constexpr day& operator--() noexcept;
constexpr day operator--(int) noexcept;
constexpr day& operator+=(const days& d) noexcept;
constexpr day& operator-=(const days& d) noexcept;
constexpr explicit operator unsigned() const noexcept;
constexpr bool ok() const noexcept;
};
}
day represents a day of a month
. It normally holds values in the range 1 to 31,
but may hold non-negative values outside this range
. It can be constructed with any
unsigned value,
which will be subsequently truncated to fit into
day's unspecified internal storage
. day is a trivially copyable and standard-layout class type
. constexpr explicit day(unsigned d) noexcept;
Effects: Initializes
d_ with
d. The value held is unspecified if
d is not in the range [
0, 255]
.constexpr day& operator++() noexcept;
constexpr day operator++(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr day& operator--() noexcept;
Effects: Equivalent to:
--d_. constexpr day operator--(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr day& operator+=(const days& d) noexcept;
Effects:
*this = *this + d. constexpr day& operator-=(const days& d) noexcept;
Effects:
*this = *this - d. constexpr explicit operator unsigned() const noexcept;
constexpr bool ok() const noexcept;
Returns:
1 <= d_ && d_ <= 31. constexpr bool operator==(const day& x, const day& y) noexcept;
Returns:
unsigned{x} == unsigned{y}. constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
Returns:
unsigned{x} <=> unsigned{y}. constexpr day operator+(const day& x, const days& y) noexcept;
Returns:
day(unsigned{x} + y.count()). constexpr day operator+(const days& x, const day& y) noexcept;
constexpr day operator-(const day& x, const days& y) noexcept;
constexpr days operator-(const day& x, const day& y) noexcept;
Returns:
days{int(unsigned{x}) - int(unsigned{y})}. template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const day& d);
Effects: Equivalent to:
return os << (d.ok() ?
format(STATICALLY-WIDEN<charT>("{:%d}"), d) :
format(STATICALLY-WIDEN<charT>("{:%d} is not a valid day"), d));
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
day d using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid day,
is.setstate(ios_base::failbit) is called and
d is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.constexpr chrono::day operator""d(unsigned long long d) noexcept;
Returns:
day{static_cast<unsigned>(d)}. namespace std::chrono {
class month {
unsigned char m_;
public:
month() = default;
constexpr explicit month(unsigned m) noexcept;
constexpr month& operator++() noexcept;
constexpr month operator++(int) noexcept;
constexpr month& operator--() noexcept;
constexpr month operator--(int) noexcept;
constexpr month& operator+=(const months& m) noexcept;
constexpr month& operator-=(const months& m) noexcept;
constexpr explicit operator unsigned() const noexcept;
constexpr bool ok() const noexcept;
};
}
month represents a month of a year
. It normally holds values in the range 1 to 12,
but may hold non-negative values outside this range
. It can be constructed with any
unsigned value,
which will be subsequently truncated to fit into
month's unspecified internal storage
. month is a trivially copyable and standard-layout class type
. constexpr explicit month(unsigned m) noexcept;
Effects: Initializes
m_ with
m. The value held is unspecified if
m is not in the range [
0, 255]
.constexpr month& operator++() noexcept;
Effects:
*this += months{1}. constexpr month operator++(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr month& operator--() noexcept;
Effects:
*this -= months{1}. constexpr month operator--(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr month& operator+=(const months& m) noexcept;
Effects:
*this = *this + m. constexpr month& operator-=(const months& m) noexcept;
Effects:
*this = *this - m. constexpr explicit operator unsigned() const noexcept;
constexpr bool ok() const noexcept;
Returns:
1 <= m_ && m_ <= 12. constexpr bool operator==(const month& x, const month& y) noexcept;
Returns:
unsigned{x} == unsigned{y}. constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
Returns:
unsigned{x} <=> unsigned{y}. constexpr month operator+(const month& x, const months& y) noexcept;
Returns:
month{modulo(static_cast<long long>(unsigned{x}) + (y.count() - 1), 12) + 1}
where
modulo(n, 12) computes the remainder of
n divided by 12 using Euclidean division
. [
Note 1:
Given a divisor of 12, Euclidean division truncates towards negative infinity and
always produces a remainder in the range of [
0, 11]
. Assuming no overflow in the signed summation,
this operation results in a
month holding a value in the range [
1, 12] even if
!x.ok(). —
end note]
[
Example 1:
February + months{11} == January. —
end example]
constexpr month operator+(const months& x, const month& y) noexcept;
constexpr month operator-(const month& x, const months& y) noexcept;
constexpr months operator-(const month& x, const month& y) noexcept;
Returns: If
x.ok() == true
and
y.ok() == true,
returns a value
m
in the range [
months{0}, months{11}]
satisfying
y + m == x. Otherwise the value returned is unspecified
. [
Example 2:
January - February == months{11}. —
end example]
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const month& m);
Effects: Equivalent to:
return os << (m.ok() ?
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%b}"), m) :
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid month"),
static_cast<unsigned>(m)));
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
month m using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid month,
is.setstate(ios_base::failbit) is called and
m is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.namespace std::chrono {
class year {
short y_;
public:
year() = default;
constexpr explicit year(int y) noexcept;
constexpr year& operator++() noexcept;
constexpr year operator++(int) noexcept;
constexpr year& operator--() noexcept;
constexpr year operator--(int) noexcept;
constexpr year& operator+=(const years& y) noexcept;
constexpr year& operator-=(const years& y) noexcept;
constexpr year operator+() const noexcept;
constexpr year operator-() const noexcept;
constexpr bool is_leap() const noexcept;
constexpr explicit operator int() const noexcept;
constexpr bool ok() const noexcept;
static constexpr year min() noexcept;
static constexpr year max() noexcept;
};
}
year represents a year in the civil calendar
. It can represent values in the range [
min(), max()]
. It can be constructed with any
int value,
which will be subsequently truncated to fit into
year's unspecified internal storage
. year is a trivially copyable and standard-layout class type
. constexpr explicit year(int y) noexcept;
Effects: Initializes
y_ with
y. The value held is unspecified if
y is not in the range [
-32767, 32767]
.constexpr year& operator++() noexcept;
constexpr year operator++(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr year& operator--() noexcept;
constexpr year operator--(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr year& operator+=(const years& y) noexcept;
Effects:
*this = *this + y. constexpr year& operator-=(const years& y) noexcept;
Effects:
*this = *this - y. constexpr year operator+() const noexcept;
constexpr year operator-() const noexcept;
constexpr bool is_leap() const noexcept;
Returns:
y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0). constexpr explicit operator int() const noexcept;
constexpr bool ok() const noexcept;
Returns:
min().y_ <= y_ && y_ <= max().y_. static constexpr year min() noexcept;
static constexpr year max() noexcept;
constexpr bool operator==(const year& x, const year& y) noexcept;
Returns:
int{x} == int{y}. constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
Returns:
int{x} <=> int{y}. constexpr year operator+(const year& x, const years& y) noexcept;
Returns:
year{int{x} + static_cast<int>(y.count())}. constexpr year operator+(const years& x, const year& y) noexcept;
constexpr year operator-(const year& x, const years& y) noexcept;
constexpr years operator-(const year& x, const year& y) noexcept;
Returns:
years{int{x} - int{y}}. template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const year& y);
Effects: Equivalent to:
return os << (y.ok() ?
format(STATICALLY-WIDEN<charT>("{:%Y}"), y) :
format(STATICALLY-WIDEN<charT>("{:%Y} is not a valid year"), y));
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
year& y, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
year y using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid year,
is.setstate(ios_base::failbit) is called and
y is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.constexpr chrono::year operator""y(unsigned long long y) noexcept;
Returns:
year{static_cast<int>(y)}. namespace std::chrono {
class weekday {
unsigned char wd_;
public:
weekday() = default;
constexpr explicit weekday(unsigned wd) noexcept;
constexpr weekday(const sys_days& dp) noexcept;
constexpr explicit weekday(const local_days& dp) noexcept;
constexpr weekday& operator++() noexcept;
constexpr weekday operator++(int) noexcept;
constexpr weekday& operator--() noexcept;
constexpr weekday operator--(int) noexcept;
constexpr weekday& operator+=(const days& d) noexcept;
constexpr weekday& operator-=(const days& d) noexcept;
constexpr unsigned c_encoding() const noexcept;
constexpr unsigned iso_encoding() const noexcept;
constexpr bool ok() const noexcept;
constexpr weekday_indexed operator[](unsigned index) const noexcept;
constexpr weekday_last operator[](last_spec) const noexcept;
};
}
weekday represents a day of the week in the civil calendar
. It normally holds values in the range
0 to
6,
corresponding to Sunday through Saturday, but
it may hold non-negative values outside this range
. It can be constructed with any
unsigned value,
which will be subsequently truncated to fit into
weekday's unspecified internal storage
. [
Note 1:
weekday is not
Cpp17LessThanComparable
because there is no universal consensus on which day is the first day of the week
. weekday's arithmetic operations treat the days of the week as a circular range,
with no beginning and no end
. —
end note]
weekday is a trivially copyable and standard-layout class type
. constexpr explicit weekday(unsigned wd) noexcept;
Effects: Initializes
wd_ with
wd == 7 ? 0 : wd. The value held is unspecified if
wd is not in the range [
0, 255]
.constexpr weekday(const sys_days& dp) noexcept;
Effects: Computes what day of the week corresponds to the
sys_days dp,
and initializes that day of the week in
wd_. [
Example 1:
If
dp represents 1970-01-01,
the constructed
weekday represents Thursday
by storing
4 in
wd_. —
end example]
constexpr explicit weekday(const local_days& dp) noexcept;
Effects: Computes what day of the week corresponds to the
local_days dp,
and initializes that day of the week in
wd_. Postconditions: The value is identical to that constructed from
sys_days{dp.time_since_epoch()}. constexpr weekday& operator++() noexcept;
Effects:
*this += days{1}. constexpr weekday operator++(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr weekday& operator--() noexcept;
Effects:
*this -= days{1}. constexpr weekday operator--(int) noexcept;
Returns: A copy of
*this as it existed on entry to this member function
. constexpr weekday& operator+=(const days& d) noexcept;
Effects:
*this = *this + d. constexpr weekday& operator-=(const days& d) noexcept;
Effects:
*this = *this - d. constexpr unsigned c_encoding() const noexcept;
constexpr unsigned iso_encoding() const noexcept;
Returns:
wd_ == 0u ? 7u : wd_. constexpr bool ok() const noexcept;
constexpr weekday_indexed operator[](unsigned index) const noexcept;
constexpr weekday_last operator[](last_spec) const noexcept;
Returns:
weekday_last{*this}. constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
constexpr weekday operator+(const weekday& x, const days& y) noexcept;
Returns:
weekday{modulo(static_cast<long long>(x.wd_) + y.count(), 7)}
where
modulo(n, 7) computes the remainder of
n divided by 7 using Euclidean division
. [
Note 1:
Given a divisor of 7, Euclidean division truncates towards negative infinity and
always produces a remainder in the range of [
0, 6]
. Assuming no overflow in the signed summation,
this operation results in a
weekday holding a value in the range [
0, 6] even if
!x.ok(). —
end note]
[
Example 1:
Monday + days{6} == Sunday. —
end example]
constexpr weekday operator+(const days& x, const weekday& y) noexcept;
constexpr weekday operator-(const weekday& x, const days& y) noexcept;
constexpr days operator-(const weekday& x, const weekday& y) noexcept;
Returns: If
x.ok() == true
and
y.ok() == true,
returns a value
d
in the range [
days{0}, days{6}]
satisfying
y + d == x. Otherwise the value returned is unspecified
. [
Example 2:
Sunday - Monday == days{6}. —
end example]
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
Effects: Equivalent to:
return os << (wd.ok() ?
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L%a}"), wd) :
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid weekday"),
static_cast<unsigned>(wd.wd_)));
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
weekday wd using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid weekday,
is.setstate(ios_base::failbit) is called and
wd is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.namespace std::chrono {
class weekday_indexed {
chrono::weekday wd_;
unsigned char index_;
public:
weekday_indexed() = default;
constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
constexpr chrono::weekday weekday() const noexcept;
constexpr unsigned index() const noexcept;
constexpr bool ok() const noexcept;
};
}
weekday_indexed represents a
weekday
and a small index in the range 1 to 5
. This class is used to represent the
first, second, third, fourth, or fifth weekday of a month
.[
Note 1:
A
weekday_indexed object
can be constructed by indexing a
weekday
with an
unsigned. —
end note]
[
Example 1:
constexpr auto wdi = Sunday[2];
static_assert(wdi.weekday() == Sunday);
static_assert(wdi.index() == 2);
—
end example]
weekday_indexed is a trivially copyable and standard-layout class type
. constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
Effects: Initializes
wd_ with
wd and
index_ with
index. The values held are unspecified if
!wd.ok() or
index is not in the range [
0, 7]
.constexpr chrono::weekday weekday() const noexcept;
constexpr unsigned index() const noexcept;
constexpr bool ok() const noexcept;
Returns:
wd_.ok() && 1 <= index_ && index_ <= 5. constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
Returns:
x.weekday() == y.weekday() && x.index() == y.index(). template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
Effects: Equivalent to:
auto i = wdi.index();
return os << (i >= 1 && i <= 5 ?
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[{}]"), wdi.weekday(), i) :
format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[{} is not a valid index]"),
wdi.weekday(), i));
namespace std::chrono {
class weekday_last {
chrono::weekday wd_;
public:
constexpr explicit weekday_last(const chrono::weekday& wd) noexcept;
constexpr chrono::weekday weekday() const noexcept;
constexpr bool ok() const noexcept;
};
}
weekday_last represents the last weekday of a month
. [
Note 1:
A
weekday_last object
can be constructed by indexing a
weekday with
last. —
end note]
[
Example 1:
constexpr auto wdl = Sunday[last];
static_assert(wdl.weekday() == Sunday);
—
end example]
weekday_last is a trivially copyable and standard-layout class type
. constexpr explicit weekday_last(const chrono::weekday& wd) noexcept;
Effects: Initializes
wd_ with
wd. constexpr chrono::weekday weekday() const noexcept;
constexpr bool ok() const noexcept;
constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
Returns:
x.weekday() == y.weekday(). template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}[last]"), wdl.weekday());
namespace std::chrono {
class month_day {
chrono::month m_;
chrono::day d_;
public:
month_day() = default;
constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::day day() const noexcept;
constexpr bool ok() const noexcept;
};
}
month_day represents a specific day of a specific month,
but with an unspecified year
. month_day is a trivially copyable and standard-layout class type
. constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
Effects: Initializes
m_ with
m, and
d_ with
d. constexpr chrono::month month() const noexcept;
constexpr chrono::day day() const noexcept;
constexpr bool ok() const noexcept;
Returns:
true if
m_.ok() is
true,
1d <= d_, and
d_ is less than or equal to the number of days in month
m_;
otherwise returns
false. When
m_ == February,
the number of days is considered to be 29
.constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
Returns:
x.month() == y.month() && x.day() == y.day(). constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
Effects: Equivalent to:
if (auto c = x.month() <=> y.month(); c != 0) return c;
return x.day() <=> y.day();
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const month_day& md);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{}"),
md.month(), md.day());
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
month_day& md, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
month_day md using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid
month_day,
is.setstate(ios_base::failbit) is called and
md is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.namespace std::chrono {
class month_day_last {
chrono::month m_;
public:
constexpr explicit month_day_last(const chrono::month& m) noexcept;
constexpr chrono::month month() const noexcept;
constexpr bool ok() const noexcept;
};
}
month_day_last represents the last day of a month
. [
Note 1:
A
month_day_last object
can be constructed using the expression
m/last or
last/m,
where
m is an expression of type
month. —
end note]
[
Example 1:
constexpr auto mdl = February/last;
static_assert(mdl.month() == February);
—
end example]
month_day_last is a trivially copyable and standard-layout class type
. constexpr explicit month_day_last(const chrono::month& m) noexcept;
Effects: Initializes
m_ with
m. constexpr month month() const noexcept;
constexpr bool ok() const noexcept;
constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
Returns:
x.month() == y.month(). constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
Returns:
x.month() <=> y.month(). template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/last"), mdl.month());
namespace std::chrono {
class month_weekday {
chrono::month m_;
chrono::weekday_indexed wdi_;
public:
constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
constexpr bool ok() const noexcept;
};
}
month_weekday represents the
nth weekday of a month,
of an as yet unspecified year
. To do this the
month_weekday stores a
month and a
weekday_indexed.[
Example 1:
constexpr auto mwd
= February/Tuesday[3];
static_assert(mwd.month() == February);
static_assert(mwd.weekday_indexed() == Tuesday[3]);
—
end example]
month_weekday is a trivially copyable and standard-layout class type
. constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
Effects: Initializes
m_ with
m, and
wdi_ with
wdi. constexpr chrono::month month() const noexcept;
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
constexpr bool ok() const noexcept;
Returns:
m_.ok() && wdi_.ok(). constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
Returns:
x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed(). template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{:L}"),
mwd.month(), mwd.weekday_indexed());
namespace std::chrono {
class month_weekday_last {
chrono::month m_;
chrono::weekday_last wdl_;
public:
constexpr month_weekday_last(const chrono::month& m,
const chrono::weekday_last& wdl) noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::weekday_last weekday_last() const noexcept;
constexpr bool ok() const noexcept;
};
}
month_weekday_last represents the last weekday of a month,
of an as yet unspecified year
. To do this the
month_weekday_last stores a
month and a
weekday_last.[
Example 1:
constexpr auto mwd
= February/Tuesday[last];
static_assert(mwd.month() == February);
static_assert(mwd.weekday_last() == Tuesday[last]);
—
end example]
month_weekday_last is a trivially copyable and standard-layout class type
. constexpr month_weekday_last(const chrono::month& m,
const chrono::weekday_last& wdl) noexcept;
Effects: Initializes
m_ with
m, and
wdl_ with
wdl. constexpr chrono::month month() const noexcept;
constexpr chrono::weekday_last weekday_last() const noexcept;
constexpr bool ok() const noexcept;
Returns:
m_.ok() && wdl_.ok(). constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
Returns:
x.month() == y.month() && x.weekday_last() == y.weekday_last(). template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:L}/{:L}"),
mwdl.month(), mwdl.weekday_last());
namespace std::chrono {
class year_month {
chrono::year y_;
chrono::month m_;
public:
year_month() = default;
constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
constexpr chrono::year year() const noexcept;
constexpr chrono::month month() const noexcept;
constexpr year_month& operator+=(const months& dm) noexcept;
constexpr year_month& operator-=(const months& dm) noexcept;
constexpr year_month& operator+=(const years& dy) noexcept;
constexpr year_month& operator-=(const years& dy) noexcept;
constexpr bool ok() const noexcept;
};
}
year_month represents a specific month of a specific year,
but with an unspecified day
. year_month is a field-based time point with a resolution of
months. year_month is a trivially copyable and standard-layout class type
. constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
Effects: Initializes
y_ with
y, and
m_ with
m. constexpr chrono::year year() const noexcept;
constexpr chrono::month month() const noexcept;
constexpr year_month& operator+=(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])
. Effects:
*this = *this + dm. constexpr year_month& operator-=(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])
. Effects:
*this = *this - dm. constexpr year_month& operator+=(const years& dy) noexcept;
Effects:
*this = *this + dy. constexpr year_month& operator-=(const years& dy) noexcept;
Effects:
*this = *this - dy. constexpr bool ok() const noexcept;
Returns:
y_.ok() && m_.ok(). constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
Returns:
x.year() == y.year() && x.month() == y.month(). constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
Effects: Equivalent to:
if (auto c = x.year() <=> y.year(); c != 0) return c;
return x.month() <=> y.month();
constexpr year_month operator+(const year_month& ym, 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: A
year_month value
z such that
z.ok() && z - ym == dm
is
true. Complexity:
O(1) with respect to the value of
dm. constexpr year_month operator+(const months& dm, const year_month& ym) 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])
. constexpr year_month operator-(const year_month& ym, 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])
. constexpr months operator-(const year_month& x, const year_month& y) noexcept;
Returns: x.year() - y.year() + months{static_cast<int>(unsigned{x.month()}) -
static_cast<int>(unsigned{y.month()})}
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
Returns:
(ym.year() + dy) / ym.month(). constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}"),
ym.year(), ym.month());
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
year_month& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
year_month ym using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid
year_month,
is.setstate(ios_base::failbit) is called and
ym is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.namespace std::chrono {
class year_month_day {
chrono::year y_;
chrono::month m_;
chrono::day d_;
public:
year_month_day() = default;
constexpr year_month_day(const chrono::year& y, const chrono::month& m,
const chrono::day& d) noexcept;
constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
constexpr year_month_day(const sys_days& dp) noexcept;
constexpr explicit year_month_day(const local_days& dp) noexcept;
constexpr year_month_day& operator+=(const months& m) noexcept;
constexpr year_month_day& operator-=(const months& m) noexcept;
constexpr year_month_day& operator+=(const years& y) noexcept;
constexpr year_month_day& operator-=(const years& y) noexcept;
constexpr chrono::year year() const noexcept;
constexpr chrono::month month() 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 represents a specific year, month, and day
. year_month_day is a field-based time point with a resolution of
days. [
Note 1:
year_month_day 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 is a trivially copyable and standard-layout class type
. 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
can 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. 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. constexpr year_month_day& year_month_day::operator+=(const years& y) noexcept;
Effects:
*this = *this + y. constexpr year_month_day& year_month_day::operator-=(const years& y) noexcept;
Effects:
*this = *this - y. constexpr chrono::year year() const noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::day day() const noexcept;
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. constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
Returns:
x.year() == y.year() && x.month() == y.month() && x.day() == y.day(). constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
Effects: Equivalent to:
if (auto c = x.year() <=> y.year(); c != 0) return c;
if (auto c = x.month() <=> y.month(); c != 0) return c;
return x.day() <=> y.day();
constexpr year_month_day operator+(const year_month_day& ymd, 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:
(ymd.year() / ymd.month() + dm) / ymd.day(). [
Note 1:
If
ymd.day() is in the range [
1d, 28d],
ok() will return
true for
the resultant
year_month_day. —
end note]
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) 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])
. constexpr year_month_day operator-(const year_month_day& ymd, 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])
. constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
Returns:
(ymd.year() + dy) / ymd.month() / ymd.day(). [
Note 2:
If
ymd.month() is February
and
ymd.day() is not in the range [
1d, 28d],
ok() can return
false for
the resultant
year_month_day. —
end note]
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
Effects: Equivalent to:
return os << (ymd.ok() ?
format(STATICALLY-WIDEN<charT>("{:%F}"), ymd) :
format(STATICALLY-WIDEN<charT>("{:%F} is not a valid date"), ymd));
template<class charT, class traits, class Alloc = allocator<charT>>
basic_istream<charT, traits>&
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
year_month_day& ymd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
minutes* offset = nullptr);
Effects: Attempts to parse the input stream
is
into the
year_month_day ymd using
the format flags given in the NTCTS
fmt
as specified in
[time.parse]. If the parse fails to decode a valid
year_month_day,
is.setstate(ios_base::failbit) is called and
ymd is not modified
. If
%Z is used and successfully parsed,
that value will be assigned to
*abbrev if
abbrev is non-null
. If
%z (or a modified variant) is used and successfully parsed,
that value will be assigned to
*offset if
offset is non-null
.namespace std::chrono {
class year_month_day_last {
chrono::year y_;
chrono::month_day_last mdl_;
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 is a trivially copyable and standard-layout class type
. 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. 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. constexpr year_month_day_last& operator+=(const years& y) noexcept;
Effects:
*this = *this + y. constexpr year_month_day_last& operator-=(const years& y) noexcept;
Effects:
*this = *this - y. 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;
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(). 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])
. 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])
. 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;
constexpr year_month_day_last
operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
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());
namespace std::chrono {
class year_month_weekday {
chrono::year y_;
chrono::month m_;
chrono::weekday_indexed wdi_;
public:
year_month_weekday() = default;
constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
const chrono::weekday_indexed& wdi) noexcept;
constexpr year_month_weekday(const sys_days& dp) noexcept;
constexpr explicit year_month_weekday(const local_days& dp) noexcept;
constexpr year_month_weekday& operator+=(const months& m) noexcept;
constexpr year_month_weekday& operator-=(const months& m) noexcept;
constexpr year_month_weekday& operator+=(const years& y) noexcept;
constexpr year_month_weekday& operator-=(const years& y) noexcept;
constexpr chrono::year year() const noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::weekday weekday() const noexcept;
constexpr unsigned index() const noexcept;
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
constexpr operator sys_days() const noexcept;
constexpr explicit operator local_days() const noexcept;
constexpr bool ok() const noexcept;
};
}
year_month_weekday represents a specific year, month,
and
nth weekday of the month
. year_month_weekday is a field-based time point with a resolution of
days. [
Note 1:
year_month_weekday 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 is a trivially copyable and standard-layout class type
. constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
const chrono::weekday_indexed& wdi) noexcept;
Effects: Initializes
y_ with
y,
m_ with
m, and
wdi_ with
wdi. constexpr year_month_weekday(const sys_days& dp) noexcept;
Effects: Constructs an object of type
year_month_weekday
which corresponds to the date represented by
dp. Remarks: For any value
ymwd of type
year_month_weekday
for which
ymwd.ok() is
true,
ymwd == year_month_weekday{sys_days{ymwd}} is
true. constexpr explicit year_month_weekday(const local_days& dp) noexcept;
Effects: Equivalent to constructing with
sys_days{dp.time_since_epoch()}. constexpr year_month_weekday& 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. constexpr year_month_weekday& 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. constexpr year_month_weekday& operator+=(const years& y) noexcept;
Effects:
*this = *this + y. constexpr year_month_weekday& operator-=(const years& y) noexcept;
Effects:
*this = *this - y. constexpr chrono::year year() const noexcept;
constexpr chrono::month month() const noexcept;
constexpr chrono::weekday weekday() const noexcept;
constexpr unsigned index() const noexcept;
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
constexpr operator sys_days() const noexcept;
Returns: If
y_.ok() && m_.ok() && wdi_.weekday().ok(),
returns a
sys_days that
represents the date
(index() - 1) * 7 days after
the first
weekday() of
year()/month(). If
index() is 0
the returned
sys_days
represents the date 7 days prior to
the first
weekday() of
year()/month(). Otherwise the returned value is unspecified
.constexpr explicit operator local_days() const noexcept;
Returns:
local_days{sys_days{*this}.time_since_epoch()}. constexpr bool ok() const noexcept;
Returns: If any of
y_.ok(),
m_.ok(), or
wdi_.ok()
is
false, returns
false. Otherwise, if
*this represents a valid date,
returns
true. Otherwise, returns
false.constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept;
Returns: x.year() == y.year() && x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed()
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, 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:
(ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed(). constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) 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])
. constexpr year_month_weekday operator-(const year_month_weekday& ymwd, 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])
. constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
Returns:
{ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}. constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}/{:L}"),
ymwd.year(), ymwd.month(), ymwd.weekday_indexed());
namespace std::chrono {
class year_month_weekday_last {
chrono::year y_;
chrono::month m_;
chrono::weekday_last wdl_;
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;
};
}
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 is a trivially copyable and standard-layout class type
. constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
const chrono::weekday_last& wdl) noexcept;
Effects: Initializes
y_ with
y,
m_ with
m, and
wdl_ with
wdl. constexpr year_month_weekday_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. constexpr year_month_weekday_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. constexpr year_month_weekday_last& operator+=(const years& y) noexcept;
Effects:
*this = *this + y. constexpr year_month_weekday_last& operator-=(const years& y) noexcept;
Effects:
*this = *this - y. 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;
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;
Returns:
local_days{sys_days{*this}.time_since_epoch()}. constexpr bool ok() const noexcept;
Returns:
y_.ok() && m_.ok() && wdl_.ok(). constexpr bool operator==(const year_month_weekday_last& x,
const year_month_weekday_last& y) noexcept;
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;
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:
(ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last(). constexpr year_month_weekday_last
operator+(const months& dm, const year_month_weekday_last& ymwdl) 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])
. constexpr year_month_weekday_last
operator-(const year_month_weekday_last& ymwdl, 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])
. constexpr year_month_weekday_last
operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
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;
constexpr year_month_weekday_last
operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
Effects: Equivalent to:
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{:L}/{:L}"),
ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
A set of overloaded
operator/ functions provides
a conventional syntax for the creation of civil calendar dates
.[
Note 1:
The year, month, and day are accepted in any of the following 3 orders:
year/month/day
month/day/year
day/month/year
Anywhere a day is needed, any of the following can also be specified:
last
weekday[i]
weekday[last]
—
end note]
[
Note 2:
Partial-date types such as
year_month and
month_day
can be created by not applying the second division operator
for any of the three orders
. For example:
year_month ym = 2015y/April;
month_day md1 = April/4;
month_day md2 = 4d/April;
—
end note]
[
Example 1:
auto a = 2015/4/4;
auto b = 2015y/4/4;
auto c = 2015y/4d/April;
auto d = 2015/April/4;
—
end example]
constexpr year_month
operator/(const year& y, const month& m) noexcept;
constexpr year_month
operator/(const year& y, int m) noexcept;
constexpr month_day
operator/(const month& m, const day& d) noexcept;
constexpr month_day
operator/(const month& m, int d) noexcept;
constexpr month_day
operator/(int m, const day& d) noexcept;
constexpr month_day
operator/(const day& d, const month& m) noexcept;
constexpr month_day
operator/(const day& d, int m) noexcept;
constexpr month_day_last
operator/(const month& m, last_spec) noexcept;
Returns:
month_day_last{m}. constexpr month_day_last
operator/(int m, last_spec) noexcept;
Returns:
month(m) / last. constexpr month_day_last
operator/(last_spec, const month& m) noexcept;
constexpr month_day_last
operator/(last_spec, int m) noexcept;
Returns:
month(m) / last. constexpr month_weekday
operator/(const month& m, const weekday_indexed& wdi) noexcept;
constexpr month_weekday
operator/(int m, const weekday_indexed& wdi) noexcept;
constexpr month_weekday
operator/(const weekday_indexed& wdi, const month& m) noexcept;
constexpr month_weekday
operator/(const weekday_indexed& wdi, int m) noexcept;
constexpr month_weekday_last
operator/(const month& m, const weekday_last& wdl) noexcept;
constexpr month_weekday_last
operator/(int m, const weekday_last& wdl) noexcept;
constexpr month_weekday_last
operator/(const weekday_last& wdl, const month& m) noexcept;
constexpr month_weekday_last
operator/(const weekday_last& wdl, int m) noexcept;
constexpr year_month_day
operator/(const year_month& ym, const day& d) noexcept;
Returns:
{ym.year(), ym.month(), d}. constexpr year_month_day
operator/(const year_month& ym, int d) noexcept;
constexpr year_month_day
operator/(const year& y, const month_day& md) noexcept;
Returns:
y / md.month() / md.day(). constexpr year_month_day
operator/(int y, const month_day& md) noexcept;
constexpr year_month_day
operator/(const month_day& md, const year& y) noexcept;
constexpr year_month_day
operator/(const month_day& md, int y) noexcept;
constexpr year_month_day_last
operator/(const year_month& ym, last_spec) noexcept;
Returns:
{ym.year(), month_day_last{ym.month()}}. constexpr year_month_day_last
operator/(const year& y, const month_day_last& mdl) noexcept;
constexpr year_month_day_last
operator/(int y, const month_day_last& mdl) noexcept;
constexpr year_month_day_last
operator/(const month_day_last& mdl, const year& y) noexcept;
constexpr year_month_day_last
operator/(const month_day_last& mdl, int y) noexcept;
constexpr year_month_weekday
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
Returns:
{ym.year(), ym.month(), wdi}. constexpr year_month_weekday
operator/(const year& y, const month_weekday& mwd) noexcept;
Returns:
{y, mwd.month(), mwd.weekday_indexed()}. constexpr year_month_weekday
operator/(int y, const month_weekday& mwd) noexcept;
constexpr year_month_weekday
operator/(const month_weekday& mwd, const year& y) noexcept;
constexpr year_month_weekday
operator/(const month_weekday& mwd, int y) noexcept;
constexpr year_month_weekday_last
operator/(const year_month& ym, const weekday_last& wdl) noexcept;
Returns:
{ym.year(), ym.month(), wdl}. constexpr year_month_weekday_last
operator/(const year& y, const month_weekday_last& mwdl) noexcept;
Returns:
{y, mwdl.month(), mwdl.weekday_last()}. constexpr year_month_weekday_last
operator/(int y, const month_weekday_last& mwdl) noexcept;
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, const year& y) noexcept;
constexpr year_month_weekday_last
operator/(const month_weekday_last& mwdl, int y) noexcept;