[time.clock.utc.members] (original) (raw)

30 Time library [time]

30.7 Clocks [time.clock]

30.7.3 Class utc_clock [time.clock.utc]

30.7.3.2 Member functions [time.clock.utc.members]

Returns: from_sys(system_clock​::​now()), or a more accurate value of utc_time.

template<class Duration> static sys_time<common_type_t<Duration, seconds>> to_sys(const utc_time<Duration>& u);

Returns: A sys_time t, such that from_sys(t) == u if such a mapping exists.

Otherwise u represents a time_pointduring a positive leap second insertion, the conversion counts that leap second as not inserted, and the last representable value of sys_timeprior to the insertion of the leap second is returned.

template<class Duration> static utc_time<common_type_t<Duration, seconds>> from_sys(const sys_time<Duration>& t);

Returns: A utc_time u, such thatu.time_since_epoch() - t.time_since_epoch()is equal to the sum of leap seconds that were inserted between t and 1970-01-01.

If t is exactly the date of leap second insertion, then the conversion counts that leap second as inserted.

[Example 1: auto t = sys_days{July/1/2015} - 2ns;auto u = utc_clock::from_sys(t); assert(u.time_since_epoch() - t.time_since_epoch() == 25s); t += 1ns; u = utc_clock::from_sys(t); assert(u.time_since_epoch() - t.time_since_epoch() == 25s); t += 1ns; u = utc_clock::from_sys(t); assert(u.time_since_epoch() - t.time_since_epoch() == 26s); t += 1ns; u = utc_clock::from_sys(t); assert(u.time_since_epoch() - t.time_since_epoch() == 26s); — _end example_]