tmp/tmpx4i7qkxv/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#### Overview <a id="time.clock.utc.overview">[[time.clock.utc.overview]]</a>
|
| 2 |
+
|
| 3 |
+
``` cpp
|
| 4 |
+
namespace std::chrono {
|
| 5 |
+
class utc_clock {
|
| 6 |
+
public:
|
| 7 |
+
using rep = a signed arithmetic type;
|
| 8 |
+
using period = ratio<unspecified, unspecified>;
|
| 9 |
+
using duration = chrono::duration<rep, period>;
|
| 10 |
+
using time_point = chrono::time_point<utc_clock>;
|
| 11 |
+
static constexpr bool is_steady = unspecified;
|
| 12 |
+
|
| 13 |
+
static time_point now();
|
| 14 |
+
|
| 15 |
+
template<class Duration>
|
| 16 |
+
static sys_time<common_type_t<Duration, seconds>>
|
| 17 |
+
to_sys(const utc_time<Duration>& t);
|
| 18 |
+
template<class Duration>
|
| 19 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 20 |
+
from_sys(const sys_time<Duration>& t);
|
| 21 |
+
};
|
| 22 |
+
}
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
In contrast to `sys_time`, which does not take leap seconds into
|
| 26 |
+
account, `utc_clock` and its associated `time_point`, `utc_time`, count
|
| 27 |
+
time, including leap seconds, since 1970-01-01 00:00:00 UTC.
|
| 28 |
+
|
| 29 |
+
[*Note 1*: The UTC time standard began on 1972-01-01 00:00:10 TAI. To
|
| 30 |
+
measure time since this epoch instead, one can add/subtract the constant
|
| 31 |
+
`sys_days{1972y/1/1} - sys_days{1970y/1/1}` (`63'072'000s`) from the
|
| 32 |
+
`utc_time`. — *end note*]
|
| 33 |
+
|
| 34 |
+
[*Example 1*:
|
| 35 |
+
`clock_cast<utc_clock>(sys_seconds{sys_days{1970y/January/1}}).time_since_epoch()`
|
| 36 |
+
is `0s`.
|
| 37 |
+
`clock_cast<utc_clock>(sys_seconds{sys_days{2000y/January/1}}).time_since_epoch()`
|
| 38 |
+
is `946'684'822s`, which is `10'957 * 86'400s + 22s`.
|
| 39 |
+
— *end example*]
|
| 40 |
+
|
| 41 |
+
`utc_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 42 |
+
guarantee that `utc_clock::now()` does not propagate an exception.
|
| 43 |
+
|
| 44 |
+
[*Note 2*: `noexcept(from_sys(system_clock::now()))` is
|
| 45 |
+
`false`. — *end note*]
|
| 46 |
+
|