W3cubDocs

/C++

std::chrono::year_month_day::ok

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();
}

© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
http://en.cppreference.com/w/cpp/chrono/year_month_day/ok