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.
Section: 29.11.7.1 [time.zone.zonedtime.overview] Status: C++20 Submitter: Tomasz Kamiński Opened: 2019-06-30 Last modified: 2021-02-25
Priority: 0
View all other issues in [time.zone.zonedtime.overview].
View all issues with C++20 status.
Discussion:
Currently, the time_zone
is always storing the time with
the precision not coarser that seconds
, as consequence any
instance with the duration with coarser precision with seconds
,
is de-facto equivalent to one instantiated to the duration of seconds.
This is caused by the fact, that time zone offset can be defined up to
seconds precision. To illustrate both of following specialization has
the same behavior (keep seconds
):
zoned_time<minutes> zt(current_zone(), floor<minutes>(system_clock::now()); zoned_time<hours> zt(current_zone(), floor<hours>(system_clock::now()); zoned_time<seconds> zt(current_zone(), floor<seconds>(system_clock::now());
To avoid unnecessary code bloat caused by above, most deduction guides
are instantiating zoned_time
with at least seconds
precision (i.e. zoned_time<seconds>
will be deduced
for all of above):
template<class TimeZonePtr, class Duration> zoned_time(TimeZonePtr, zoned_time<Duration>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>;
However there is single exception:
template<class Duration, class TimeZonePtr, class TimeZonePtr2> zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest) -> zoned_time<Duration, TimeZonePtr>;
This deduction guide should be updated to preserve the consistency of design.
[2019-07 Issue Prioritization]
Status to Tentatively Ready after five positive votes on the reflector.
Proposed resolution:
This wording is relative to N4820.
Modify 29.11.7.1 [time.zone.zonedtime.overview] as indicated:
[…] template<class Duration, class TimeZonePtr, class TimeZonePtr2> zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose = choose::earliest) -> zoned_time<common_type_t<Duration, seconds>, TimeZonePtr>; […]