# std::chrono::month_weekday::ok

> C++ Atlas: `cppatlas.com/w/cpp/chrono/month_weekday/ok` | Source: https://en.cppreference.com/w/cpp/chrono/month_weekday/ok | Domain: Date and time utilities | Standards: C++20

Checks if the contained month and weekday_indexed objects are valid.

## Official Specification Summary (cppreference)

```cpp
constexpr bool ok() const noexcept; // (since C++20)
```

Checks if the contained `month` and `weekday_indexed` objects are valid.

### Return value

`month().ok() && weekday_indexed().ok()`

### Example

```cpp
#include <cassert>
#include <chrono>

int main()
{
    auto mwdi{std::chrono::March/std::chrono::Friday[1]};
    assert(mwdi.ok());

    mwdi = {std::chrono::month(17)/std::chrono::Friday[1]};
    assert(not mwdi.ok());

    mwdi = {std::chrono::March/std::chrono::Friday[-4]};
    assert(not mwdi.ok());
}
```

---
Attribution: content from https://en.cppreference.com/w/cpp/chrono/month_weekday/ok (cppreference.com), licensed under CC-BY-SA 3.0 and GFDL. Modified: converted to markdown, study notes added. Offline snapshot of 9 February 2025.