[time.cal.year.nonmembers]

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

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

### 30.8.5 Class year [[time.cal.year]](time.cal.year#nonmembers)

#### 30.8.5.3 Non-member functions [time.cal.year.nonmembers]

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

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

[1](#1)

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

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

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

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

[2](#2)

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

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

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

`constexpr year operator+(const year& x, const years& y) noexcept;
`

[3](#3)

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

*Returns*: year{int{x} + static_cast<int>(y.count())}[.](#3.sentence-1)

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

`constexpr year operator+(const years& x, const year& y) noexcept;
`

[4](#4)

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

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

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

`constexpr year operator-(const year& x, const years& y) noexcept;
`

[5](#5)

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

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

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

`constexpr years operator-(const year& x, const year& y) noexcept;
`

[6](#6)

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

*Returns*: years{int{x} - int{y}}[.](#6.sentence-1)

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

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

[7](#7)

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

*Effects*: Equivalent to:return os << (y.ok() ? format(*STATICALLY-WIDEN*<charT>("{:%Y}"), y) : format(*STATICALLY-WIDEN*<charT>("{:%Y} is not a valid year"), y));

[ð](#lib:from_stream,year)

`template<class charT, class traits, class Alloc = allocator<charT>>
  basic_istream<charT, traits>&
    from_stream(basic_istream<charT, traits>& is, const charT* fmt,
                year& y, basic_string<charT, traits, Alloc>* abbrev = nullptr,
                minutes* offset = nullptr);
`

[8](#8)

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

*Effects*: Attempts to parse the input stream is into the year y 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 year,is.setstate(ios_base​::​failbit) is called andy 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#L4876)

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

[ð](#lib:operator%22%22y,year)

`constexpr chrono::year operator""y(unsigned long long y) noexcept;
`

[10](#10)

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

*Returns*: year{static_cast<int>(y)}[.](#10.sentence-1)
