Files
2025-10-25 03:02:53 +03:00

5.3 KiB
Raw Permalink Blame History

[time.cal.md]

30 Time library [time]

30.8 The civil calendar [time.cal]

30.8.9 Class month_day [time.cal.md]

30.8.9.1 Overview [time.cal.md.overview]

namespace std::chrono {class month_day { chrono::month m_; // exposition only chrono::day d_; // exposition onlypublic: 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

#

month_day represents a specific day of a specific month, but with an unspecified year.

month_day meets the Cpp17EqualityComparable (Table 28) and Cpp17LessThanComparable (Table 29) requirements.

2

#

month_day is a trivially copyable and standard-layout class type.

30.8.9.2 Member functions [time.cal.md.members]

🔗

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

1

#

Effects: Initializes m_ with m, and d_ with d.

🔗

constexpr chrono::month month() const noexcept;

2

#

Returns: m_.

🔗

constexpr chrono::day day() const noexcept;

3

#

Returns: d_.

🔗

constexpr bool ok() const noexcept;

4

#

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.

When m_ == February, the number of days is considered to be 29.

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

🔗

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

1

#

Returns: x.month() == y.month() && x.day() == y.day().

🔗

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

2

#

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

🔗

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

3

#

Effects: Equivalent to:return os << format(os.getloc(), STATICALLY-WIDEN("{:L}/{}"), md.month(), md.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

#

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].

If the parse fails to decode a valid month_day,is.setstate(ios_base::failbit) is called andmd is not 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.

5

#

Returns: is.