25 Time library [time]

25.8 The civil calendar [time.cal]

25.8.3 Class day [time.cal.day]

25.8.3.1 Overview [time.cal.day.overview]

namespace std::chrono {
  class day {
    unsigned char d_;           // exposition only
  public:
    day() = default;
    explicit constexpr 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;

    explicit constexpr 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 Cpp17EqualityComparable (Table 22) and Cpp17LessThanComparable (Table 23), and participates in basic arithmetic with days objects, which represent a difference between two day objects.
day is a trivially copyable and standard-layout class type.

25.8.3.2 Member functions [time.cal.day.members]

explicit constexpr day(unsigned d) noexcept;
Effects: Constructs an object of type day by initializing d_­ with d.
The value held is unspecified if d is not in the range [0, 255].
constexpr day& operator++() noexcept;
Effects: ++d_­.
Returns: *this.
constexpr day operator++(int) noexcept;
Effects: ++(*this).
Returns: A copy of *this as it existed on entry to this member function.
constexpr day& operator--() noexcept;
Effects: --d_­.
Returns: *this.
constexpr day operator--(int) noexcept;
Effects: --(*this).
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.
Returns: *this.
constexpr day& operator-=(const days& d) noexcept;
Effects: *this = *this - d.
Returns: *this.
explicit constexpr operator unsigned() const noexcept;
Returns: d_­.
constexpr bool ok() const noexcept;
Returns: 1 <= d_­ && d_­ <= 31.

25.8.3.3 Non-member functions [time.cal.day.nonmembers]

constexpr bool operator==(const day& x, const day& y) noexcept;
Returns: unsigned{x} == unsigned{y}.
constexpr bool 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;
Returns: y + x.
constexpr day operator-(const day& x, const days& y) noexcept;
Returns: x + -y.
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: Inserts format(fmt, d) where fmt is "%d" widened to charT.
If !d.ok(), appends with " is not a valid day".
Returns: os.
template<class charT, class traits> basic_ostream<charT, traits>& to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const day& d);
Effects: Streams d into os using the format specified by the NTCTS fmt.
fmt encoding follows the rules specified in [time.format].
Returns: os.
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) shall be called and d shall not be 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.
Returns: is.
constexpr day operator""d(unsigned long long d) noexcept;
Returns: day{static_­cast<unsigned>(d)}.