From Jason Turner

[time.clock.tai]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp_2yh0hu_/{from.md → to.md} +141 -0
tmp/tmp_2yh0hu_/{from.md → to.md} RENAMED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Class `tai_clock` <a id="time.clock.tai">[[time.clock.tai]]</a>
2
+
3
+ #### Overview <a id="time.clock.tai.overview">[[time.clock.tai.overview]]</a>
4
+
5
+ ``` cpp
6
+ namespace std::chrono {
7
+ class tai_clock {
8
+ public:
9
+ using rep = a signed arithmetic type;
10
+ using period = ratio<unspecified, unspecified>;
11
+ using duration = chrono::duration<rep, period>;
12
+ using time_point = chrono::time_point<tai_clock>;
13
+ static constexpr bool is_steady = unspecified;
14
+
15
+ static time_point now();
16
+
17
+ template<class Duration>
18
+ static utc_time<common_type_t<Duration, seconds>>
19
+ to_utc(const tai_time<Duration>&) noexcept;
20
+ template<class Duration>
21
+ static tai_time<common_type_t<Duration, seconds>>
22
+ from_utc(const utc_time<Duration>&) noexcept;
23
+ };
24
+ }
25
+ ```
26
+
27
+ The clock `tai_clock` measures seconds since 1958-01-01 00:00:00 and is
28
+ offset 10s ahead of UTC at this date. That is, 1958-01-01 00:00:00 TAI
29
+ is equivalent to 1957-12-31 23:59:50 UTC. Leap seconds are not inserted
30
+ into TAI. Therefore every time a leap second is inserted into UTC, UTC
31
+ shifts another second with respect to TAI. For example by 2000-01-01
32
+ there had been 22 positive and 0 negative leap seconds inserted so
33
+ 2000-01-01 00:00:00 UTC is equivalent to 2000-01-01 00:00:32 TAI (22s
34
+ plus the initial 10s offset).
35
+
36
+ `tai_clock` is not a *Cpp17TrivialClock* unless the implementation can
37
+ guarantee that `tai_clock::now()` does not propagate an exception.
38
+
39
+ [*Note 1*: `noexcept(from_utc(utc_clock::now()))` is
40
+ `false`. — *end note*]
41
+
42
+ #### Member functions <a id="time.clock.tai.members">[[time.clock.tai.members]]</a>
43
+
44
+ ``` cpp
45
+ static time_point now();
46
+ ```
47
+
48
+ *Returns:* `from_utc(utc_clock::now())`, or a more accurate value of
49
+ `tai_time`.
50
+
51
+ ``` cpp
52
+ template<class Duration>
53
+ static utc_time<common_type_t<Duration, seconds>>
54
+ to_utc(const tai_time<Duration>& t) noexcept;
55
+ ```
56
+
57
+ *Returns:*
58
+
59
+ ``` cpp
60
+ utc_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} - 378691210s
61
+ ```
62
+
63
+ [*Note 1*:
64
+
65
+ ``` cpp
66
+ 378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s
67
+ ```
68
+
69
+ — *end note*]
70
+
71
+ ``` cpp
72
+ template<class Duration>
73
+ static tai_time<common_type_t<Duration, seconds>>
74
+ from_utc(const utc_time<Duration>& t) noexcept;
75
+ ```
76
+
77
+ *Returns:*
78
+
79
+ ``` cpp
80
+ tai_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} + 378691210s
81
+ ```
82
+
83
+ [*Note 2*:
84
+
85
+ ``` cpp
86
+ 378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s
87
+ ```
88
+
89
+ — *end note*]
90
+
91
+ #### Non-member functions <a id="time.clock.tai.nonmembers">[[time.clock.tai.nonmembers]]</a>
92
+
93
+ ``` cpp
94
+ template<class charT, class traits, class Duration>
95
+ basic_ostream<charT, traits>&
96
+ operator<<(basic_ostream<charT, traits>& os, const tai_time<Duration>& t);
97
+ ```
98
+
99
+ *Effects:* Equivalent to:
100
+
101
+ ``` cpp
102
+ return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
103
+ ```
104
+
105
+ [*Example 1*:
106
+
107
+ ``` cpp
108
+ auto st = sys_days{2000y/January/1};
109
+ auto tt = clock_cast<tai_clock>(st);
110
+ cout << format("{0:%F %T %Z} == {1:%F %T %Z}\n", st, tt);
111
+ ```
112
+
113
+ Produces this output:
114
+
115
+ ``` text
116
+ 2000-01-01 00:00:00 UTC == 2000-01-01 00:00:32 TAI
117
+ ```
118
+
119
+ — *end example*]
120
+
121
+ ``` cpp
122
+ template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
123
+ basic_istream<charT, traits>&
124
+ from_stream(basic_istream<charT, traits>& is, const charT* fmt,
125
+ tai_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
126
+ minutes* offset = nullptr);
127
+ ```
128
+
129
+ *Effects:* Attempts to parse the input stream `is` into the `tai_time`
130
+ `tp` using the format flags given in the NTCTS `fmt` as specified in
131
+ [[time.parse]]. If the parse fails to decode a valid date,
132
+ `is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
133
+ `%Z` is used and successfully parsed, that value will be assigned to
134
+ `*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
135
+ used and successfully parsed, that value will be assigned to `*offset`
136
+ if `offset` is non-null. Additionally, the parsed offset will be
137
+ subtracted from the successfully parsed timestamp prior to assigning
138
+ that difference to `tp`.
139
+
140
+ *Returns:* `is`.
141
+