[time.cal.wd.nonmembers]

# 30 Time library [[time]](./#time)

## 30.8 The civil calendar [[time.cal]](time.cal#wd.nonmembers)

### 30.8.6 Class weekday [[time.cal.wd]](time.cal.wd#nonmembers)

#### 30.8.6.3 Non-member functions [time.cal.wd.nonmembers]

[ð](#lib:operator==,weekday)

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

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5147)

*Returns*: x.wd_ == y.wd_[.](#1.sentence-1)

[ð](#lib:operator+,weekday)

`constexpr weekday operator+(const weekday& x, const days& y) noexcept;
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5158)

*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[.](#2.sentence-1)

[*Note [1](#note-1)*:

Given a divisor of 7, Euclidean division truncates towards negative infinity and
always produces a remainder in the range of [0, 6][.](#2.sentence-2)

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()[.](#2.sentence-3)

â *end note*]

[*Example [1](#example-1)*:

Monday + days{6} == Sunday[.](#2.sentence-4)

â *end example*]

[ð](#lib:operator+,weekday_)

`constexpr weekday operator+(const days& x, const weekday& y) noexcept;
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5181)

*Returns*: y + x[.](#3.sentence-1)

[ð](#lib:operator-,weekday)

`constexpr weekday operator-(const weekday& x, const days& y) noexcept;
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5192)

*Returns*: x + -y[.](#4.sentence-1)

[ð](#lib:operator-,weekday_)

`constexpr days operator-(const weekday& x, const weekday& y) noexcept;
`

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5203)

*Returns*: If x.ok() == true and y.ok() == true,
returns a value d in the range [days{0}, days{6}]
satisfying y + d == x[.](#5.sentence-1)

Otherwise the value returned is unspecified[.](#5.sentence-2)

[*Example [2](#example-2)*:

Sunday - Monday == days{6}[.](#5.sentence-3)

â *end example*]

[ð](#lib:operator%3c%3c,weekday)

`template<class charT, class traits>
  basic_ostream<charT, traits>&
    operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
`

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5224)

*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_)));

[ð](#lib:from_stream,weekday)

`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);
`

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5245)

*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]](time.parse "30.13 Parsing")[.](#7.sentence-1)

If the parse fails to decode a valid weekday,is.setstate(ios_base​::​failbit) is called andwd is not modified[.](#7.sentence-2)

If %Z is used and successfully parsed,
that value will be assigned to *abbrev if abbrev is non-null[.](#7.sentence-3)

If %z (or a modified variant) is used and successfully parsed,
that value will be assigned to *offset if offset is non-null[.](#7.sentence-4)

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/time.tex#L5259)

*Returns*: is[.](#8.sentence-1)
