[time.cal.month.nonmembers]

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

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

### 30.8.4 Class month [[time.cal.month]](time.cal.month#nonmembers)

#### 30.8.4.3 Non-member functions [time.cal.month.nonmembers]

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

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

[1](#1)

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

*Returns*: unsigned{x} == unsigned{y}[.](#1.sentence-1)

[ð](#lib:operator%3c=%3e,month)

`constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
`

[2](#2)

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

*Returns*: unsigned{x} <=> unsigned{y}[.](#2.sentence-1)

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

`constexpr month operator+(const month& x, const months& y) noexcept;
`

[3](#3)

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

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

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

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

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

â *end note*]

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

February + months{11} == January[.](#3.sentence-4)

â *end example*]

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

`constexpr month operator+(const months& x, const month& y) noexcept;
`

[4](#4)

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

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

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

`constexpr month operator-(const month& x, const months& y) noexcept;
`

[5](#5)

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

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

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

`constexpr months operator-(const month& x, const month& y) noexcept;
`

[6](#6)

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

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

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

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

January - February == months{11}[.](#6.sentence-3)

â *end example*]

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

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

[7](#7)

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

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

[ð](#lib:from_stream,month)

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

[8](#8)

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

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

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

If %Z is used and successfully parsed,
that value will be assigned to *abbrev if abbrev is non-null[.](#8.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[.](#8.sentence-4)

[9](#9)

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

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