This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++20 status.

### 3231. `year_month_day_last::day` specification does not cover `!ok()` values

Section: 27.8.15.2 [time.cal.ymdlast.members] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-06-29 Last modified: 2021-02-25

Priority: 0

View all issues with C++20 status.

Discussion:

The current specification of the `year_month_day_last::day` function does not cover the behaviour in the situation when `year_month_day_last` value is not `ok()`. To illustrate the sentence from 27.8.15.2 [time.cal.ymdlast.members] p13:

> A `day` representing the last day of the (`year`, `month`) pair represented by `*this`.

is unclear in the situation when `month` member has `!ok` value, e.g. what is last day of 14th month of 2019.

The proposed resolution makes the value of `ymdl.day()` (and by consequence conversion to `sys_days`/`local_days`) unspecified if `ymdl.ok()` is `false`. This make is consistent with rest of the library, that produces unspecified values in similiar situation, e.g.: 27.8.14.2 [time.cal.ymd.members] p18, 27.8.16.2 [time.cal.ymwd.members] p19, 27.8.17.2 [time.cal.ymwdlast.members] p14.

[2019-07 Issue Prioritization]

Status to Tentatively Ready after five positive votes on the reflector.

Proposed resolution:

This wording is relative to N4820.

1. Modify 27.8.15.2 [time.cal.ymdlast.members] as indicated:

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

   > > -13- Returns: If `ok()` is `true`, returns a A `day` representing the last day of the (`year, month`) pair represented by `*this`. Otherwise the returned value is unspecified.

   > > -14- [Note: This value may be computed on demand. — end note]