From 4358ea7b6ee0a7791668c8f65c09d4c2ce83c89e Mon Sep 17 00:00:00 2001
From: Howard Hinnant Overview
-
-Effects: Constructs an object of type weekday
represents a day of the week in the Gregorian calendar. It should
-only be representing values in the range 0 to 6, corresponding to Sunday thru Saturday.
-However it may hold values outside this range. It can be constructed with any
+weekday
represents a day of the week in the Gregorian calendar.
+It can be constructed with any
unsigned
value, which will be subsequently truncated to fit into
-weekday
's internal storage. weekday
is equality comparable.
+weekday
's internal storage. The values [1, 6] map to Monday thru Saturday.
+Both 0 and 7 map to Sunday. Other values in the range [8, 255] will be stored, and will
+represent values of weekday
that are !ok()
.
+weekday
is equality comparable.
weekday
is not less-than comparable because there is no universal consensus
-on which day is the first day of the week. This design chooses the encoding of 0 to 6 to
-represent Sunday thru Saturday only because this is consistent with existing C and C++
-practice. However weekday
's comparison and arithmetic operations treat the
+on which day is the first day of the week. weekday
's comparison and arithmetic operations treat the
days of the week as a circular range, with no beginning and no end. One can stream out a
weekday
for debugging purposes. weekday
has explicit conversions
to and from unsigned
. There are 7 weekday
constants, one for each
@@ -3301,9 +3300,14 @@ explicit constexpr weekday::weekday(unsigned wd) noexcept;
@@ -3421,23 +3425,14 @@ constexpr weekday& weekday::operator-=(const days& d) noexcept;
weekday
by constructing
-wd_
with wd
. The value held is unspecified if wd
-is not in the range [0, 255]
.
+Effects: Constructs an object of type weekday
+which represents a day of the week according to the ISO 8601 mapping
+of integers to days of the week. Additionally, if wd ==
+0
, Sunday is represented. [Note: Sunday can be
+constructed from both 0 and 7 — end note]. If
+wd
is in the range [8, 255], wd_
is
+initialized with wd. If wd is not in the range [0, 255], the value
+held is unspecified.
-constexpr explicit weekday::operator unsigned() const noexcept; -- -
---Returns:
-wd_
. -
constexpr bool weekday::ok() const noexcept;
@@ -3467,7 +3462,7 @@ constexpr bool operator==(const weekday& x, const weekday& y) noexcept;-Returns:
wd_ <= 6
. +Returns:true
if*this
holds a value in the range +Monday thru Sunday, else returnsfalse
.
-Returns:
unsigned{x} == unsigned{y}
. +Returns:x.wd_ == y.wd_
.