std::chrono::year_month_day::ok

From cppreference.com
< cpplrm; | chronolrm; | year month day
Date and time utilities
(C++11)
(C++11)
Clocks
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Calendars
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
Time zones
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
C-style date and time
constexpr bool ok() const noexcept;
(since C++20)

Checks if this year_month_day object represents a valid calendar date.

Return value

true if this year_month_day object represents a valid calendar date, that is, the stored year, month, and day values are all valid and the stored day value is within the number of days in the given year and month. Otherwise false.

Possible implementation

constexpr bool std::chrono::year_month_day::ok() const noexcept {
    return year().ok() && month().ok() && day().ok() &&
           day() <= (year()/month()/std::chrono::last).day();
}