From Jason Turner

[time.clock.utc.members]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpit_imka6/{from.md → to.md} +52 -0
tmp/tmpit_imka6/{from.md → to.md} RENAMED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #### Member functions <a id="time.clock.utc.members">[[time.clock.utc.members]]</a>
2
+
3
+ ``` cpp
4
+ static time_point now();
5
+ ```
6
+
7
+ *Returns:* `from_sys(system_clock::now())`, or a more accurate value of
8
+ `utc_time`.
9
+
10
+ ``` cpp
11
+ template<class Duration>
12
+ static sys_time<common_type_t<Duration, seconds>>
13
+ to_sys(const utc_time<Duration>& u);
14
+ ```
15
+
16
+ *Returns:* A `sys_time` `t`, such that `from_sys(t) == u` if such a
17
+ mapping exists. Otherwise `u` represents a `time_point` during a
18
+ positive leap second insertion, the conversion counts that leap second
19
+ as not inserted, and the last representable value of `sys_time` prior to
20
+ the insertion of the leap second is returned.
21
+
22
+ ``` cpp
23
+ template<class Duration>
24
+ static utc_time<common_type_t<Duration, seconds>>
25
+ from_sys(const sys_time<Duration>& t);
26
+ ```
27
+
28
+ *Returns:* A `utc_time` `u`, such that
29
+ `u.time_since_epoch() - t.time_since_epoch()` is equal to the sum of
30
+ leap seconds that were inserted between `t` and 1970-01-01. If `t` is
31
+ exactly the date of leap second insertion, then the conversion counts
32
+ that leap second as inserted.
33
+
34
+ [*Example 1*:
35
+
36
+ ``` cpp
37
+ auto t = sys_days{July/1/2015} - 2ns;
38
+ auto u = utc_clock::from_sys(t);
39
+ assert(u.time_since_epoch() - t.time_since_epoch() == 25s);
40
+ t += 1ns;
41
+ u = utc_clock::from_sys(t);
42
+ assert(u.time_since_epoch() - t.time_since_epoch() == 25s);
43
+ t += 1ns;
44
+ u = utc_clock::from_sys(t);
45
+ assert(u.time_since_epoch() - t.time_since_epoch() == 26s);
46
+ t += 1ns;
47
+ u = utc_clock::from_sys(t);
48
+ assert(u.time_since_epoch() - t.time_since_epoch() == 26s);
49
+ ```
50
+
51
+ — *end example*]
52
+