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.

### 3206. `year_month_day` conversion to `sys_days` uses not-existing member function

Section: 29.8.14.2 [time.cal.ymd.members] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-05-19 Last modified: 2021-02-25

Priority: 0

View all issues with C++20 status.

Discussion:

The current specification of the `year_month_day` conversion function to `sys_days`, uses the `day` member function on the `sys_days` (a.k.a. `time_point<system_clock, days>`), that does not exist.

In 29.8.14.2 [time.cal.ymd.members] p18, the expression `sys_days{y_/m_/last}.day()` is ill-formed:

> […] Otherwise, if `y_.ok() && m_.ok()` is `true`, returns a `sys_days` which is offset from `sys_days{y_/m_/last}` by the number of days `d_` is offset from `sys_days{y_/m_/last}.day()`. Otherwise the value returned is unspecified.

[2019-06-08; Priority to 0 and Status to Tentatively Ready after six positive votes on the reflector.]

Proposed resolution:

This wording is relative to N4810.

1. Modify 29.8.14.2 [time.cal.ymd.members] as indicated:

   >     constexpr operator sys_days() const noexcept;

   > > -18- Returns: If `ok()`, returns a `sys_days` holding a count of days from the `sys_days` epoch to `*this` (a negative value if `*this` represents a date prior to the `sys_days` epoch). Otherwise, if `y_.ok() && m_.ok()` is `true`, returns `sys_days{y_/m_/1d} + (d_ - 1d)`a `sys_days` which is offset from `sys_days{y_/m_/last}` by the number of days `d_` is offset from `sys_days{y_/m_/last}.day()`. Otherwise the value returned is unspecified.