From 609dd499347967a2f6c9f5358ac9451295b7b69b Mon Sep 17 00:00:00 2001 From: Howard Hinnant Date: Tue, 27 Jun 2017 22:15:45 -0400 Subject: [PATCH] Add zoned_time default constructor and, refine conversion from calendar types to sys_days and local_days. --- d0355r4.html | 55 ++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/d0355r4.html b/d0355r4.html index 0ed2350..0b4bce5 100644 --- a/d0355r4.html +++ b/d0355r4.html @@ -60,8 +60,8 @@ Document number: D0355R4
@@ -718,12 +718,6 @@ which is equal to nullptr.

-
  • -

    -Should zoned_time have a default constructor, and if so, what should its -value be? -

    -
  • Proposed Wording

    @@ -6748,15 +6742,18 @@ constexpr year_month_day::operator sys_days() const noexcept;

    Returns: If ok(), returns a sys_days -holding a count of days before or since the -sys_days epoch. Otherwise returns a +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 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().

    -Remarks: A sys_days which is converted to a year_month_day, -shall have the same value when converted back to a sys_days. +Remarks: A sys_days in the range +[days{-12687428}, days{11248737}] which is converted to a +year_month_day, shall have the same value when converted +back to a sys_days.

    [Example: @@ -6777,13 +6774,13 @@ constexpr explicit year_month_day::operator local_days() const noexcept;

    -Requires: ok() == true. +Requires: y_.ok() && m_.ok() == true.

    Effects: Equivalent to:

    -return local_days{static_cast<sys_days>(*this).time_since_epoch()};
    +return local_days{sys_days{*this}.time_since_epoch()};
     
    @@ -7177,8 +7174,7 @@ constexpr year_month_day_last::operator sys_days() const noexcept; Requires: ok() == true.

    -Returns: A sys_days which represents the date represented by -*this. +Effects: Equivalent to: return sys_days{year()/month()/day()};

    @@ -7191,11 +7187,8 @@ constexpr explicit year_month_day_last::operator local_days() const noexcept; Requires: ok() == true.

    -Effects: Equivalent to: +Effects: Equivalent to: return local_days{sys_days{*this}.time_since_epoch()};

    -
    -return local_days{static_cast<sys_days>(*this).time_since_epoch()};
    -
    @@ -7586,11 +7579,8 @@ constexpr explicit year_month_weekday::operator local_days() const noexcept;
     Requires: ok() == true.
     

    -Effects: Equivalent to: +Effects: Equivalent to: return local_days{sys_days{*this}.time_since_epoch()};

    -
    -return local_days{static_cast<sys_days>(*this).time_since_epoch()};
    -
    @@ -7920,11 +7910,8 @@ constexpr explicit year_month_weekday_last::operator local_days() const noexcept
     Requires: ok() == true.
     

    -Effects: Equivalent to: +Effects: Equivalent to: return local_days{sys_days{*this}.time_since_epoch()};

    -
    -return local_days{static_cast<sys_days>(*this).time_since_epoch()};
    -
    @@ -9671,6 +9658,7 @@ private:
         sys_time<duration> tp_;    // exposition only
     
     public:
    +    zoned_time();
         zoned_time(const zoned_time&) = default;
         zoned_time& operator=(const zoned_time&) = default;
     
    @@ -9734,6 +9722,17 @@ to a valid time_zone, and represents a point in time that exists
     and is not ambiguous.
     

    +
    +zoned_time<Duration>::zoned_time();
    +
    +
    +

    +Effects: Constructs a zoned_time zt such that +zt.get_time_zone()->name() == "UTC", and +zt.get_sys_time() == sys_seconds{}. +

    +
    +
     zoned_time<Duration>::zoned_time(const zoned_time&) = default;
     zoned_time<Duration>& zoned_time<Duration>::operator=(const zoned_time&) = default;