tomaszkam / date

A date and time library based on the C++11/14/17 <chrono> header
Other
0 stars 0 forks source link

[LWG3206] year_­month_­day to sys_days conversion uses not-existing method #12

Closed tomaszkam closed 5 years ago

tomaszkam commented 5 years ago

Original comment:

sysdays doesn't have a day() member; I'm pretty sure the last part meant to call day() on y/m_/last. But is there any particular reason why we use last here? It seems to me that using 1d is equally correct and we can simply say it returns sysdays{y/m/1d} + (d - 1d).

tomaszkam commented 5 years ago

Discussion: The current specification of the year_month_day conversion operator to sys_days, uses to the day method on the sys_days, that does not exist.

In [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().`

Proposed wording: Apply following changes to year_month_day::operator sys_days in [ymd.members]: constexpr operator sys_days() const noexcept;

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.