From Jason Turner

[time.zone.zonedtime]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp3z2cc2ng/{from.md → to.md} +363 -0
tmp/tmp3z2cc2ng/{from.md → to.md} RENAMED
@@ -0,0 +1,363 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### Class template `zoned_time` <a id="time.zone.zonedtime">[[time.zone.zonedtime]]</a>
2
+
3
+ #### Overview <a id="time.zone.zonedtime.overview">[[time.zone.zonedtime.overview]]</a>
4
+
5
+ ``` cpp
6
+ namespace std::chrono {
7
+ template<class Duration, class TimeZonePtr = const time_zone*>
8
+ class zoned_time {
9
+ public:
10
+ using duration = common_type_t<Duration, seconds>;
11
+
12
+ private:
13
+ TimeZonePtr zone_; // exposition only
14
+ sys_time<duration> tp_; // exposition only
15
+
16
+ using traits = zoned_traits<TimeZonePtr>; // exposition only
17
+
18
+ public:
19
+ zoned_time();
20
+ zoned_time(const zoned_time&) = default;
21
+ zoned_time& operator=(const zoned_time&) = default;
22
+
23
+ zoned_time(const sys_time<Duration>& st);
24
+ explicit zoned_time(TimeZonePtr z);
25
+ explicit zoned_time(string_view name);
26
+
27
+ template<class Duration2>
28
+ zoned_time(const zoned_time<Duration2, TimeZonePtr>& zt);
29
+
30
+ zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
31
+ zoned_time(string_view name, const sys_time<Duration>& st);
32
+
33
+ zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
34
+ zoned_time(string_view name, const local_time<Duration>& tp);
35
+ zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
36
+ zoned_time(string_view name, const local_time<Duration>& tp, choose c);
37
+
38
+ template<class Duration2, class TimeZonePtr2>
39
+ zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt);
40
+ template<class Duration2, class TimeZonePtr2>
41
+ zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
42
+
43
+ template<class Duration2, class TimeZonePtr2>
44
+ zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt);
45
+ template<class Duration2, class TimeZonePtr2>
46
+ zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
47
+
48
+ zoned_time& operator=(const sys_time<Duration>& st);
49
+ zoned_time& operator=(const local_time<Duration>& ut);
50
+
51
+ operator sys_time<duration>() const;
52
+ explicit operator local_time<duration>() const;
53
+
54
+ TimeZonePtr get_time_zone() const;
55
+ local_time<duration> get_local_time() const;
56
+ sys_time<duration> get_sys_time() const;
57
+ sys_info get_info() const;
58
+ };
59
+
60
+ zoned_time() -> zoned_time<seconds>;
61
+
62
+ template<class Duration>
63
+ zoned_time(sys_time<Duration>)
64
+ -> zoned_time<common_type_t<Duration, seconds>>;
65
+
66
+ template<class TimeZonePtrOrName>
67
+ using time-zone-representation = // exposition only
68
+ conditional_t<is_convertible_v<TimeZonePtrOrName, string_view>,
69
+ const time_zone*,
70
+ remove_cvref_t<TimeZonePtrOrName>>;
71
+
72
+ template<class TimeZonePtrOrName>
73
+ zoned_time(TimeZonePtrOrName&&)
74
+ -> zoned_time<seconds, time-zone-representation<TimeZonePtrOrName>>;
75
+
76
+ template<class TimeZonePtrOrName, class Duration>
77
+ zoned_time(TimeZonePtrOrName&&, sys_time<Duration>)
78
+ -> zoned_time<common_type_t<Duration, seconds>,
79
+ time-zone-representation<TimeZonePtrOrName>>;
80
+
81
+ template<class TimeZonePtrOrName, class Duration>
82
+ zoned_time(TimeZonePtrOrName&&, local_time<Duration>,
83
+ choose = choose::earliest)
84
+ -> zoned_time<common_type_t<Duration, seconds>,
85
+ time-zone-representation<TimeZonePtrOrName>>;
86
+
87
+ template<class Duration, class TimeZonePtrOrName, class TimeZonePtr2>
88
+ zoned_time(TimeZonePtrOrName&&, zoned_time<Duration, TimeZonePtr2>,
89
+ choose = choose::earliest)
90
+ -> zoned_time<common_type_t<Duration, seconds>,
91
+ time-zone-representation<TimeZonePtrOrName>>;
92
+ }
93
+ ```
94
+
95
+ `zoned_time` represents a logical pairing of a `time_zone` and a
96
+ `time_point` with precision `Duration`. `zoned_time<Duration>` maintains
97
+ the invariant that it always refers to a valid time zone and represents
98
+ a point in time that exists and is not ambiguous in that time zone.
99
+
100
+ If `Duration` is not a specialization of `chrono::duration`, the program
101
+ is ill-formed.
102
+
103
+ Every constructor of `zoned_time` that accepts a `string_view` as its
104
+ first parameter does not participate in class template argument
105
+ deduction [[over.match.class.deduct]].
106
+
107
+ #### Constructors <a id="time.zone.zonedtime.ctor">[[time.zone.zonedtime.ctor]]</a>
108
+
109
+ ``` cpp
110
+ zoned_time();
111
+ ```
112
+
113
+ *Constraints:* `traits::default_zone()` is a well-formed expression.
114
+
115
+ *Effects:* Initializes `zone_` with `traits::default_zone()` and default
116
+ constructs `tp_`.
117
+
118
+ ``` cpp
119
+ zoned_time(const sys_time<Duration>& st);
120
+ ```
121
+
122
+ *Constraints:* `traits::default_zone()` is a well-formed expression.
123
+
124
+ *Effects:* Initializes `zone_` with `traits::default_zone()` and `tp_`
125
+ with `st`.
126
+
127
+ ``` cpp
128
+ explicit zoned_time(TimeZonePtr z);
129
+ ```
130
+
131
+ *Preconditions:* `z` refers to a time zone.
132
+
133
+ *Effects:* Initializes `zone_` with `std::move(z)` and default
134
+ constructs `tp_`.
135
+
136
+ ``` cpp
137
+ explicit zoned_time(string_view name);
138
+ ```
139
+
140
+ *Constraints:* `traits::locate_zone(string_view{})` is a well-formed
141
+ expression and `zoned_time` is constructible from the return type of
142
+ `traits::locate_zone(string_view{})`.
143
+
144
+ *Effects:* Initializes `zone_` with `traits::locate_zone(name)` and
145
+ default constructs `tp_`.
146
+
147
+ ``` cpp
148
+ template<class Duration2>
149
+ zoned_time(const zoned_time<Duration2, TimeZonePtr>& y);
150
+ ```
151
+
152
+ *Constraints:*
153
+ `is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
154
+
155
+ *Effects:* Initializes `zone_` with `y.zone_` and `tp_` with `y.tp_`.
156
+
157
+ ``` cpp
158
+ zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
159
+ ```
160
+
161
+ *Preconditions:* `z` refers to a time zone.
162
+
163
+ *Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with `st`.
164
+
165
+ ``` cpp
166
+ zoned_time(string_view name, const sys_time<Duration>& st);
167
+ ```
168
+
169
+ *Constraints:* `zoned_time` is constructible from the return type of
170
+ `traits::locate_zone(name)` and `st`.
171
+
172
+ *Effects:* Equivalent to construction with
173
+ `{traits::locate_zone(name), st}`.
174
+
175
+ ``` cpp
176
+ zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
177
+ ```
178
+
179
+ *Preconditions:* `z` refers to a time zone.
180
+
181
+ *Constraints:*
182
+
183
+ ``` cpp
184
+ is_convertible_v<
185
+ decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})),
186
+ sys_time<duration>>
187
+ ```
188
+
189
+ is `true`.
190
+
191
+ *Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
192
+ `zone_->to_sys(tp)`.
193
+
194
+ ``` cpp
195
+ zoned_time(string_view name, const local_time<Duration>& tp);
196
+ ```
197
+
198
+ *Constraints:* `zoned_time` is constructible from the return type of
199
+ `traits::locate_zone(name)` and `tp`.
200
+
201
+ *Effects:* Equivalent to construction with
202
+ `{traits::locate_zone(name), tp}`.
203
+
204
+ ``` cpp
205
+ zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
206
+ ```
207
+
208
+ *Preconditions:* `z` refers to a time zone.
209
+
210
+ *Constraints:*
211
+
212
+ ``` cpp
213
+ is_convertible_v<
214
+ decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)),
215
+ sys_time<duration>>
216
+ ```
217
+
218
+ is `true`.
219
+
220
+ *Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
221
+ `zone_->to_sys(tp, c)`.
222
+
223
+ ``` cpp
224
+ zoned_time(string_view name, const local_time<Duration>& tp, choose c);
225
+ ```
226
+
227
+ *Constraints:* `zoned_time` is constructible from the return type of
228
+ `traits::locate_zone(name)`, `local_time<Duration>`, and `choose`.
229
+
230
+ *Effects:* Equivalent to construction with
231
+ `{traits::locate_zone(name), tp, c}`.
232
+
233
+ ``` cpp
234
+ template<class Duration2, class TimeZonePtr2>
235
+ zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
236
+ ```
237
+
238
+ *Constraints:*
239
+ `is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
240
+
241
+ *Preconditions:* `z` refers to a valid time zone.
242
+
243
+ *Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
244
+ `y.tp_`.
245
+
246
+ ``` cpp
247
+ template<class Duration2, class TimeZonePtr2>
248
+ zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
249
+ ```
250
+
251
+ *Constraints:*
252
+ `is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
253
+
254
+ *Preconditions:* `z` refers to a valid time zone.
255
+
256
+ *Effects:* Equivalent to construction with `{z, y}`.
257
+
258
+ [*Note 1*: The `choose` parameter has no effect. — *end note*]
259
+
260
+ ``` cpp
261
+ template<class Duration2, class TimeZonePtr2>
262
+ zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y);
263
+ ```
264
+
265
+ *Constraints:* `zoned_time` is constructible from the return type of
266
+ `traits::locate_zone(name)` and the type
267
+ `zoned_time<Duration2, TimeZonePtr2>`.
268
+
269
+ *Effects:* Equivalent to construction with
270
+ `{traits::locate_zone(name), y}`.
271
+
272
+ ``` cpp
273
+ template<class Duration2, class TimeZonePtr2>
274
+ zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c);
275
+ ```
276
+
277
+ *Constraints:* `zoned_time` is constructible from the return type of
278
+ `traits::locate_zone(name)`, the type
279
+ `zoned_time<Duration2, TimeZonePtr2>`, and the type `choose`.
280
+
281
+ *Effects:* Equivalent to construction with
282
+ `{traits::locate_zone(name), y, c}`.
283
+
284
+ [*Note 2*: The `choose` parameter has no effect. — *end note*]
285
+
286
+ #### Member functions <a id="time.zone.zonedtime.members">[[time.zone.zonedtime.members]]</a>
287
+
288
+ ``` cpp
289
+ zoned_time& operator=(const sys_time<Duration>& st);
290
+ ```
291
+
292
+ *Effects:* After assignment, `get_sys_time() == st`. This assignment has
293
+ no effect on the return value of `get_time_zone()`.
294
+
295
+ *Returns:* `*this`.
296
+
297
+ ``` cpp
298
+ zoned_time& operator=(const local_time<Duration>& lt);
299
+ ```
300
+
301
+ *Effects:* After assignment, `get_local_time() == lt`. This assignment
302
+ has no effect on the return value of `get_time_zone()`.
303
+
304
+ *Returns:* `*this`.
305
+
306
+ ``` cpp
307
+ operator sys_time<duration>() const;
308
+ ```
309
+
310
+ *Returns:* `get_sys_time()`.
311
+
312
+ ``` cpp
313
+ explicit operator local_time<duration>() const;
314
+ ```
315
+
316
+ *Returns:* `get_local_time()`.
317
+
318
+ ``` cpp
319
+ TimeZonePtr get_time_zone() const;
320
+ ```
321
+
322
+ *Returns:* `zone_`.
323
+
324
+ ``` cpp
325
+ local_time<duration> get_local_time() const;
326
+ ```
327
+
328
+ *Returns:* `zone_->to_local(tp_)`.
329
+
330
+ ``` cpp
331
+ sys_time<duration> get_sys_time() const;
332
+ ```
333
+
334
+ *Returns:* `tp_`.
335
+
336
+ ``` cpp
337
+ sys_info get_info() const;
338
+ ```
339
+
340
+ *Returns:* `zone_->get_info(tp_)`.
341
+
342
+ #### Non-member functions <a id="time.zone.zonedtime.nonmembers">[[time.zone.zonedtime.nonmembers]]</a>
343
+
344
+ ``` cpp
345
+ template<class Duration1, class Duration2, class TimeZonePtr>
346
+ bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
347
+ const zoned_time<Duration2, TimeZonePtr>& y);
348
+ ```
349
+
350
+ *Returns:* `x.zone_ == y.zone_ && x.tp_ == y.tp_`.
351
+
352
+ ``` cpp
353
+ template<class charT, class traits, class Duration, class TimeZonePtr>
354
+ basic_ostream<charT, traits>&
355
+ operator<<(basic_ostream<charT, traits>& os,
356
+ const zoned_time<Duration, TimeZonePtr>& t);
357
+ ```
358
+
359
+ *Effects:* Streams the value returned from `t.get_local_time()` to `os`
360
+ using the format `"%F %T %Z"`.
361
+
362
+ *Returns:* `os`.
363
+