[time.cal.md]

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

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

### 30.8.9 Class month_day [time.cal.md]

#### [30.8.9.1](#overview) Overview [[time.cal.md.overview]](time.cal.md.overview)

namespace std::chrono {class month_day { chrono::month m_; // *exposition only* chrono::day d_; // *exposition only*public: month_day() = default; constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept; constexpr chrono::month month() const noexcept; constexpr chrono::day day() const noexcept; constexpr bool ok() const noexcept; };}

[1](#overview-1)

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

month_day represents a specific day of a specific month,
but with an unspecified year[.](#overview-1.sentence-1)

month_day meets the [*Cpp17EqualityComparable*](utility.arg.requirements#:Cpp17EqualityComparable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [28](utility.arg.requirements#tab:cpp17.equalitycomparable "Table 28: Cpp17EqualityComparable requirements"))
and [*Cpp17LessThanComparable*](utility.arg.requirements#:Cpp17LessThanComparable "16.4.4.2 Template argument requirements [utility.arg.requirements]") (Table [29](utility.arg.requirements#tab:cpp17.lessthancomparable "Table 29: Cpp17LessThanComparable requirements")) requirements[.](#overview-1.sentence-2)

[2](#overview-2)

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

month_day is a trivially copyable and standard-layout class type[.](#overview-2.sentence-1)

#### [30.8.9.2](#members) Member functions [[time.cal.md.members]](time.cal.md.members)

[ð](#lib:month_day,constructor)

`constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
`

[1](#members-1)

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

*Effects*: Initializes m_ with m, and d_ with d[.](#members-1.sentence-1)

[ð](#lib:month,month_day)

`constexpr chrono::month month() const noexcept;
`

[2](#members-2)

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

*Returns*: m_[.](#members-2.sentence-1)

[ð](#lib:day,month_day)

`constexpr chrono::day day() const noexcept;
`

[3](#members-3)

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

*Returns*: d_[.](#members-3.sentence-1)

[ð](#lib:ok,month_day)

`constexpr bool ok() const noexcept;
`

[4](#members-4)

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

*Returns*: true ifm_.ok() is true,1d <= d_, andd_ is less than or equal to the number of days in month m_;
otherwise returns false[.](#members-4.sentence-1)

When m_ == February,
the number of days is considered to be 29[.](#members-4.sentence-2)

#### [30.8.9.3](#nonmembers) Non-member functions [[time.cal.md.nonmembers]](time.cal.md.nonmembers)

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

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

[1](#nonmembers-1)

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

*Returns*: x.month() == y.month() && x.day() == y.day()[.](#nonmembers-1.sentence-1)

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

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

[2](#nonmembers-2)

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

*Effects*: Equivalent to:if (auto c = x.month() <=> y.month(); c != 0) return c;return x.day() <=> y.day();

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

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

[3](#nonmembers-3)

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

*Effects*: Equivalent to:return os << format(os.getloc(), *STATICALLY-WIDEN*<charT>("{:L}/{}"),
 md.month(), md.day());

[ð](#lib:from_stream,month_day)

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

[4](#nonmembers-4)

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

*Effects*: Attempts to parse the input stream is into the month_day md using
the format flags given in the NTCTS fmt as specified in [[time.parse]](time.parse "30.13 Parsing")[.](#nonmembers-4.sentence-1)

If the parse fails to decode a valid month_day,is.setstate(ios_base​::​failbit) is called andmd is not modified[.](#nonmembers-4.sentence-2)

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

[5](#nonmembers-5)

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

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