# 27 Time library [time]

## 27.8 The civil calendar [time.cal]

### 27.8.4 Class month[time.cal.month]

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

```constexpr bool operator==(const month& x, const month& y) noexcept; ```
Returns: unsigned{x} == unsigned{y}.
```constexpr bool 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
:
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
:
February + months{11} == January.
â€”â€‰end example
â€‰]
```constexpr month operator+(const months& x, const month& y) noexcept; ```
Returns: y + x.
```constexpr month operator-(const month& x, const months& y) noexcept; ```
Returns: x + -y.
```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
:
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: If m.ok() == true inserts format(os.getloc(), fmt, m) where fmt is "%b" widened to charT.
Otherwise inserts unsigned{m} << " is not a valid month".
Returns: os.
```template<class charT, class traits> basic_ostream<charT, traits>& to_stream(basic_ostream<charT, traits>& os, const charT* fmt, const month& m); ```
Effects: Streams m 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, 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) shall be called and m 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.