-
Notifications
You must be signed in to change notification settings - Fork 7
/
d1466r3.html
917 lines (810 loc) · 23.1 KB
/
d1466r3.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>chrono fixes</title>
<style>
p {text-align:justify}
li {text-align:justify}
blockquote.note
{
background-color:#E0E0E0;
padding-left: 15px;
padding-right: 15px;
padding-top: 1px;
padding-bottom: 1px;
}
ins {color:#00A000}
del {color:#A00000}
code {white-space:pre;}
table, th, td {
border: 1px solid black;
border-collapse: collapse;
padding: 10px;
}
</style>
</head>
<body>
<address align=right>
Document number: d1466r3<br>
<br/>
<br/>
<a href="mailto:[email protected]">Howard E. Hinnant</a><br/>
2019-07-16<br/>
</address>
<hr/>
<h1 align=center>Miscellaneous minor fixes for chrono</h1>
<h2>Contents</h2>
<ul>
<li><a href="#Revision">Revision History</a></li>
<li><a href="#Introduction">Introduction</a></li>
<li><a href="#Wording">Wording</a></li>
</ul>
<a name="Revision"></a><h2>Revision History</h2>
<ul>
<li>
<p>
<b>R3:</b>
<ul>
<li>
Reword the <code>weekday(unsigned)</code> constructor to not use the word "stores."
</li>
<li>
Reword the <code>hh_mm_ss(Duration)</code> constructor to not use the word "stores."
</li>
</ul>
</li>
<li>
<p>
<b><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1466r2.html">R2:</a></b>
<ul>
<li>
Removed superflous and questionably grammatical wording from the <code>hh_mm_ss</code>
constructor <i>Effects</i> clause..
</li>
<li>
Removed <code>noexcept</code> from <code>hh_mm_ss</code> constructor.
</li>
<li>
In the description of <code>hh_mm_ss</code>, allow
<i>subseconds</i> to be based on a non-positive power of 10.
</li>
<li>
Update <code>__cpp_lib_chrono</code>.
</li>
<li>
Reference current working draft
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4810.pdf">N4810</a>
and update section numbers.
</li>
<li>
Remove errant "," in [time.clock.utc.nonmembers].
</li>
<li>
Remove use of removed conversion from <code>weekday</code> to
<code>unsigned</code> in specification.
</li>
<li>
Removed use of the term "broken down".
</li>
<li>
Changed <code>floor</code> to <code>duration_cast</code> in the
<i>Ensures:</i> clause of the <code>hh_mm_ss</code> constructor.
</li>
<li>
Changed <code>make12</code> and <code>make24</code> to use
<code>const hours&</code> parameters instead of <code>hours</code>.
</li>
</ul>
</p>
</li>
<li>
<p>
<b><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1466r1.html">R1:</a></b>
<ul>
<li>
Introduced <code>struct leap_second_info</code>.
</li>
<li>
<code>is_leap_second</code> renamed to <code>get_leap_second_info</code>.
</li>
<li>
Return type of <code>is_leap_second</code> changed from
<code>pair<bool, seconds></code> to <code>leap_second_info</code>.
</li>
<li>
Corrected type-o in author's note concerning <code>weekday</code>.
</li>
<li>
Corrected type-o in <code>weekday::iso_encoding</code> <i>Returns:</i> clause.
</li>
<li>
Removed the insertion of "missing" <code>link</code> comparison operators. They
are implicitly specified by the existing standard.
</li>
<li>
Rename <code>time_of_day</code> to <code>hh_mm_ss</code>.
</li>
<li>
Move <code>make12</code>/<code>make24</code> from <code>hh_mm_ss</code> to
namespace scope.
</li>
<li>
Add <code>fractional_width</code> to <code>hh_mm_ss</code>.
</li>
<li>
Improve <code>hh_mm_ss</code> specification.
</li>
</ul>
</p>
</li>
<li>
<p>
<b><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1466r0.html">R0:</a></b> Original paper.
</li>
</ul>
<a name="Introduction"></a><h2>Introduction</h2>
<p>
This is a collection of minor fixes and upgrades to the <code><chrono></code>
library that have come to my attention since the acceptance of
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0355r7.html">P0355r7</a>.
This paper is written with respect to
<a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/n4810.pdf">N4810</a>.
</p>
<a name="Wording"></a><h2>Wording</h2>
<ol>
<!-- Update __cpp_lib_chrono -->
<li>
Update the value of the <code>__cpp_lib_chrono</code> in table
"Standard library feature-test macros" of [support.limits.general] to reflect date
of approval of this proposal.
</li>
<!-- get_leap_second_info -->
<li>
<blockquote class=note>
<p>
Feedback from the field asks for a way to identify if a <code>utc_time</code> represents
a leap second. This proposed API is the only API that has field experience in providing
that information in a way that is efficient, and provides all information the client
desires when making a query in this area. It is used in the implementation of the
conversion between <code>utc_time</code> and <code>sys_time</code>, and in the parsing
and formatting of <code>utc_time</code>, so is likely to be present in any event. If
we choose to specify it, it can be spelled without underscores, and be available to
clients of <code><chrono></code>.
</p>
</blockquote>
<p>
Insert into the synopsis 27.2 Header <code><chrono></code> synopsis [time.syn]:
</p>
<blockquote>
<pre>
struct leap_second_info;
template <class Duration>
leap_second_info get_leap_second_info(utc_time<Duration> const& ut);
</pre>
</blockquote>
<p>
Insert new paragraphs in 27.7.2.3 Non-member functions [time.clock.utc.nonmembers]:
</p>
<blockquote>
<pre>
struct leap_second_info
{
bool is_leap_second;
seconds elapsed;
};
</pre>
<p>
The type <code>leap_second_info</code> has data members and special
members specified above. It has no base classes or members other than those
specified.
</p>
<pre>
template <class Duration>
leap_second_info
get_leap_second_info(utc_time<Duration> const& ut);
</pre>
<blockquote>
<p>
<i>Returns:</i> A <code>leap_second_info</code> where
<code>is_leap_second</code> is true if <code>ut</code> is during a
leap second insertion, and otherwise false. <code>elapsed</code> is
the number of leap seconds between 1970-01-01 and <code>ut</code>. If
<code>is_leap_second</code> is true, the leap second referred to by
<code>ut</code> is included in the count.
</p>
</blockquote>
</blockquote>
</li>
<!-- %Q %q -->
<li>
<blockquote class=note>
<p>
Feedback from the field asks for a way to customize the spacing between a duration's
value and its unit (e.g. supply a space, or a Unicode custom space between the value
and the unit). This item proposes <code>%Q</code> to represent the durations's value
and <code>%q</code> to represent the duration's unit, for formatting only. Example:
<code>format("%Q %q", 45ms) == "45 ms"</code>.
</p>
</blockquote>
<p>
Add two new rows to Table 87 — Meaning of <code>format</code> conversion
specifiers:
</p>
<blockquote>
<table>
<tr>
<td><code>%Q</code></td>
<td>The duration's numeric value (as if extracted via <code>.count()</code>).</td>
</tr>
<tr>
<td><code>%q</code></td>
<td>The duration's unit suffix as specified in [time.duration.io].</td>
</tr>
</table>
</blockquote>
</li>
<!-- weekday encoding controversy -->
<li>
<blockquote class=note>
<p>
About half of the clients are upset that the currently specified encoding for
<code>weekday</code> implies that Sunday is the first day of the week (consistent
with the current C and C++ specifications for <code>tm.tm_wday</code>), and the
other half of the clients will be upset if the <code>weekday</code> encoding
follows the ISO specification of [1, 7] maps to [Monday, Sunday].
</p>
<p>
This change strikes a compromise in an attempt to please everyone (a nearly
impossible task).
</p>
<ul>
<li>
<p>
The <code>weekday{unsigned}</code> constructor accepts both mappings, which means
that [0, 6] maps to [Sunday, Saturday] <b>and</b> [1, 7] maps to [Monday, Sunday].
This is possible by simply accepting [0, 7] where [1, 6] maps to [Monday, Saturday]
and both 0 and 7 map to Sunday.
</p>
</li>
<li>
<p>
The explicit conversion to <code>unsigned</code> is removed from <code>weekday</code>
and named conversions are inserted in its place: <code>c_encoding()</code> and
<code>iso_encoding()</code>. The client can choose which mapping from <code>weekday</code>
to <code>unsigned</code> he desires by choosing one of these member functions.
</p>
</li>
</ul>
</blockquote>
<p>
Modify 27.8.6.2 [time.cal.wd.members] as indicated:
</p>
<blockquote>
<pre>
constexpr explicit weekday(unsigned wd) noexcept;
</pre>
<blockquote>
<p>
<i>Effects:</i> Constructs an object of type <code>weekday</code> by
initializing <code>wd_</code> with <code>wd<ins> == 7 ? 0 : wd</ins></code>. The value held is unspecified if wd is
not in the range [0, 255].
</p>
</blockquote>
<pre>
<del>constexpr explicit operator unsigned() const noexcept;</del>
</pre>
<blockquote>
<p>
<del><i>Returns:</i> <code>wd_</code>.</del>
</p>
</blockquote>
<pre>
<ins>constexpr unsigned c_encoding() const noexcept;</ins>
</pre>
<blockquote>
<p>
<ins><i>Returns:</i> <code>wd_</code>.</ins>
</p>
</blockquote>
<pre>
<ins>constexpr unsigned iso_encoding() const noexcept;</ins>
</pre>
<blockquote>
<p>
<ins><i>Returns:</i> <code>wd_ == 0u ? 7u : wd_</code>.</ins>
</p>
</blockquote>
</blockquote>
<p>
Modify 27.8.6.3 [time.cal.wd.nonmembers] as indicated:
</p>
<blockquote>
<pre>
constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code><del>unsigned{x} == unsigned{y}</del> <ins>x.wd_ == y.wd_</ins></code>.
</p>
</blockquote>
<pre>
constexpr weekday operator+(const weekday& x, const days& y) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>weekday{modulo(static_cast<long long>(<del>unsigned{</del>x<ins>.wd_</ins><del>}</del>) + y.count(), 7)}</code>.
</p>
</blockquote>
<pre>
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
</pre>
<blockquote>
<p>
<i>Effects:</i> If <code>wd.ok() == true</code> inserts
<code>format(os.getloc(), fmt, wd)</code> where <code>fmt</code> is <code>"%a"</code>
widened to <code>charT</code>. Otherwise inserts
<code>unsigned{wd<ins>.wd_</ins>} << " is not a valid weekday"</code>.
</p>
</blockquote>
</blockquote>
</li>
<!-- hh_mm_ss -->
<li>
<blockquote class=note>
<p>
<code>time_of_day</code> is poorly specified. It suffers from an overly
complicated specification, and at the same time, insufficient functionality from
that specification. Additionally, guidance from the LEWG mailing list indicates
significant dissatisfaction with the name of <code>time_of_day</code> and its
internal state that changes mode between 24h and 12h time. This note changes the
name of <code>time_of_day</code> to <code>hh_mm_ss</code> to bring the semantics
away from holding just a time duration since midnight, and more towards holding
<i>any</i> duration as an <code>{hours, minutes, seconds, subseconds}</code>
data structure. Also the 24h/12h functionality is moved out of this structure
and into namespace-scope functions. And finally this change both simplifies the
specification while providing more pertinent functionality. However the basic
functionality is maintained: <code>hh_mm_ss</code> is an <code>{hours, minutes,
seconds, subseconds}</code> structure which easily converts to and from a
<code>duration</code> and provides easy formatting.
</p>
</blockquote>
<blockquote>
<p>
Modify 27.1 General [time.general]
</p>
<blockquote>
<table>
<caption>Table 85 — Time library summary</caption>
<tr>
<th></th>
<th>Subclause</th>
<th>Header(s)</th>
</tr>
<tr>
<td colspan=3>...</td>
</tr>
<tr>
<td>27.8</td>
<td>Civil calendar</td>
<td></td>
</tr>
<tr>
<td>27.9</td>
<td>Class template <del><code>time_of_day</code></del><ins><code>hh_mm_ss</code></ins></td>
<td></td>
</tr>
<tr>
<td><ins>27.10</ins></td>
<td><ins>12/24 hour functions</ins></td>
<td></td>
</tr>
<tr>
<td><del>27.10</del><ins>27.11</ins></td>
<td>Time zones</td>
<td></td>
</tr>
<tr>
<td colspan=3>...</td>
</tr>
</table>
</blockquote>
<p>
Modify 27.2 Header <code><chrono></code> synopsis [time.syn]
</p>
<blockquote>
<pre>
...
// 27.9, class template <del>time_of_day</del><ins>hh_mm_ss</ins>
template <class Duration> class <del>time_of_day</del><ins>hh_mm_ss</ins>;
<del>template<> class time_of_day<hours>;</del>
<del>template<> class time_of_day<minutes>;</del>
<del>template<> class time_of_day<seconds>;</del>
<del>template<class Rep, class Period> class time_of_day<duration<Rep, Period>>;</del>
<del>template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const time_of_day<hours>& t);
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const time_of_day<minutes>& t);
template<class charT, class traits>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, const time_of_day<seconds>& t);</del>
template<class charT, class traits, class <del>Rep, class Period</del><ins>Duration</ins>>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os,
const <del>time_of_day</del><ins>hh_mm_ss</ins><<ins>D</ins><del>d</del>uration<del><Rep, Period></del>>& t);
<ins>// 27.10, 12/24 hour functions
constexpr bool is_am(const hours& h) noexcept;
constexpr bool is_pm(const hours& h) noexcept;
constexpr hours make12(const hours& h) noexcept;
constexpr hours make24(const hours& h, bool is_pm) noexcept;</ins>
...
</pre>
</blockquote>
<p>
Modify 27.7.1.3 Non-member functions [time.clock.system.nonmembers]
</p>
<blockquote>
<p>
<i>Effects:</i>
</p>
<blockquote>
<p>...</p>
<pre>
os << year_month_day{dp} << ' ' << <del>time_of_day</del><ins>hh_mm_ss</ins>{tp-dp};
</pre>
</blockquote>
</blockquote>
<p>
Replace [time.tod] with [time.hms]:
</p>
<blockquote>
<p>
27.9 Class template <code>hh_mm_ss</code> [time.hms]
</p>
<p>
27.9.1 Overview [time.hms.overview]
</p>
<blockquote><pre>
template <class Duration>
class hh_mm_ss
{
bool is_neg; // exposition only
chrono::hours h; // exposition only
chrono::minutes m; // exposition only
chrono::seconds s; // exposition only
precision ss; // exposition only
public:
static unsigned constexpr fractional_width = <i>see below</i>;
using precision = <i>see below</i>;
constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
constexpr explicit hh_mm_ss(Duration d);
constexpr bool is_negative() const noexcept;
constexpr chrono::hours hours() const noexcept;
constexpr chrono::minutes minutes() const noexcept;
constexpr chrono::seconds seconds() const noexcept;
constexpr precision subseconds() const noexcept;
constexpr explicit operator precision() const noexcept;
constexpr precision to_duration() const noexcept;
};
template <class charT, class traits, class Duration>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms);
</pre></blockquote>
<p>
The <code>hh_mm_ss</code> class template splits a duration into a multi-field time
structure <i>hours:minutes:seconds</i> and possibly <i>subseconds</i>, where <i>subseconds</i>
will be a <code>duration</code> unit based on a non-positive power of 10.
The <code>Duration</code> template parameter dictates the precision to which the time is
split. A <code>hh_mm_ss</code> models negative durations with a distinct
<code>is_negative</code> getter that returns <code>true</code> when the input duration
is negative. The individual duration fields always return non-negative durations even
when <code>is_negative()</code> indicates the structure is representing a negative
duration.
</p>
<p>
If <code>Duration</code> is not an instance of <code>duration</code>, the program
is ill-formed.
</p>
<p>
27.9.2 Members [time.hms.members]
</p>
<pre>
static unsigned constexpr fractional_width = <i>see below</i>;
</pre>
<blockquote>
<p>
<code>fractional_width</code> is the number of fractional decimal digits
represented by <code>precision</code>. <code>fractional_width</code> has the
value of the smallest possible integer in the range [0, 18] such that
<code>precision</code> will exactly represent all values of
<code>Duration</code>. If no such value of <code>fractional_width</code>
exists, then <code>fractional_width</code> is 6.
</p>
<p>
[<i>Example:</i>
</p>
<table>
<tr>
<th><code>Duration</code></th>
<th><code>fractional_width</code></th>
<th>Formatted fractional second<br>output of <code>Duration{1}</code></th>
</tr>
<tr>
<td><code>hours</code>, <code>minutes</code>, and <code>seconds</code></td>
<td><code>0</code></td>
<td></td>
</tr>
<tr>
<td><code>milliseconds</code></td>
<td><code>3</code></td>
<td>.001</td>
</tr>
<tr>
<td><code>microseconds</code></td>
<td><code>6</code></td>
<td>.000001</td>
</tr>
<tr>
<td><code>nanoseconds</code></td>
<td><code>9</code></td>
<td>.000000001</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 2>></code></td>
<td><code>1</code></td>
<td>.5</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 3>></code></td>
<td><code>6</code></td>
<td>.333333</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 4>></code></td>
<td><code>2</code></td>
<td>.25</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 5>></code></td>
<td><code>1</code></td>
<td>.2</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 6>></code></td>
<td><code>6</code></td>
<td>.166666</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 7>></code></td>
<td><code>6</code></td>
<td>.142857</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 8>></code></td>
<td><code>3</code></td>
<td>.125</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 9>></code></td>
<td><code>6</code></td>
<td>.111111</td>
</tr>
<tr>
<td><code>duration<int, ratio<1, 10>></code></td>
<td><code>1</code></td>
<td>.1</td>
</tr>
<tr>
<td><code>duration<int, ratio<756, 625>> //</code> <i>microfortnights</i></td>
<td><code>4</code></td>
<td>.2096</td>
</tr>
</table>
<p>
<i>— end example</i>]
</p>
</blockquote>
<pre>
using precision = <i>see below</i>;
</pre>
<blockquote>
<p>
<code>precision</code> is <code>duration<common_type_t<Duration::rep, seconds::rep>, ratio<1, 10<sup>fractional_width</sup>>></code>.
</p>
</blockquote>
<pre>
constexpr explicit hh_mm_ss(Duration d);
</pre>
<blockquote>
<p>
<i>Effects:</i> constructs an object of type <code>hh_mm_ss</code> which represents
the <code>Duration d</code> with precision <code>precision</code>.
</p>
<blockquote>
<p>
Initializes <code>is_neg</code> with <code>d < Duration::zero()</code>.
</p>
<p>
Initializes <code>h</code> with <code>duration_cast<chrono::hours>(abs(d))</code>.
</p>
<p>
Initializes <code>m</code> with <code>duration_cast<chrono::minutes>(abs(d) - hours())</code>.
</p>
<p>
Initializes <code>s</code> with <code>duration_cast<chrono::seconds>(abs(d) - hours() - minutes())</code>.
</p>
<p>
If
<code>treat_as_floating_point_v<precision::rep></code> is <code>true</code>,
initializes <code>ss</code> with <code>abs(d) - hours() - minutes() - seconds()</code>.
Else initializes <code>ss</code> with <code>duration_cast<precision>(abs(d) - hours() - minutes() - seconds())</code>.
[<i>Note:</i> When <code>precision</code> is <code>seconds</code> with integral
representation, <code>subseconds()</code> always returns <code>0s</code> <i>— end note</i>]
</p>
</blockquote>
<p>
<i>Ensures:</i> If <code>treat_as_floating_point_v<precision::rep></code> is <code>true</code>,
<code>to_duration()</code> returns <code>d</code>, else <code>to_duration()</code>
returns <code>duration_cast<precision>(d)</code>.
</p>
</blockquote>
<pre>
constexpr bool is_negative() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>is_neg</code>.
</p>
</blockquote>
<pre>
constexpr chrono::hours hours() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>h</code>.
</p>
</blockquote>
<pre>
constexpr chrono::minutes minutes() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>m</code>.
</p>
</blockquote>
<pre>
constexpr chrono::seconds seconds() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>s</code>.
</p>
</blockquote>
<pre>
constexpr precision subseconds() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>ss</code>.
</p>
</blockquote>
<pre>
constexpr precision to_duration() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> If <code>is_neg</code>, returns <code>-(h + m + s + ss)</code>,
else returns <code>h + m + s + ss</code>.
</p>
</blockquote>
<pre>
constexpr explicit operator precision() const noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>to_duration()</code>.
</p>
</blockquote>
<p>
27.9.3 Non-members [time.hms.nonmembers]
</p>
<pre>
template <class charT, class traits, class Duration>
basic_ostream<charT, traits>&
operator<<(basic_ostream<charT, traits>& os, hh_mm_ss<Duration> const& hms);
</pre>
<blockquote>
<p>
<i>Effects:</i> Outputs to <code>os</code>
according to the format
<code>"%T"</code> ([time.format]). If <code>hms.is_negative()</code>,
the output is preceded with <code>'-'</code>.
</p>
<p>
<i>Returns:</i> <code>os</code>.
</p>
<p>
[<i>Example:</i>
</p>
<blockquote><pre>
for (auto ms : {-4083007ms, 4083007ms, 65745123ms})
{
hh_mm_ss hms{ms};
cout << hms << '\n';
}
cout << hh_mm_ss{65745s} << '\n';
</pre>
<p>
Produces the output (assuming the "C" locale):
</p>
<pre>
-01:08:03.007
01:08:03.007
18:15:45.123
18:15:45
</pre></blockquote>
<p>
<i>— end example</i>]
</p>
</blockquote>
</blockquote>
<p>
Insert a new section, 27.10 12/24 hour functions [time.12]:
</p>
<blockquote>
<p>
27.10 12/24 hour functions [time.12]
</p>
<p>
These functions aid in translating between a 12h format time of day, and a 24h format
time of day.
</p>
<pre>
constexpr bool is_am(const hours& h) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>0h <= h && h <= 11h</code>.
</p>
</blockquote>
<pre>
constexpr bool is_pm(const hours& h) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> <code>12h <= h && h <= 23h</code>.
</p>
</blockquote>
<pre>
constexpr hours make12(const hours& h) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> The 12-hour equivalent of <code>h</code> in the range
<code>[1h, 12h]</code>. If <code>h</code> is not in the range
<code>[0h, 23h]</code>, the value returned is unspecified.
</p>
</blockquote>
<pre>
constexpr hours make24(const hours& h, bool is_pm) noexcept;
</pre>
<blockquote>
<p>
<i>Returns:</i> If <code>is_pm</code> is <code>false</code>, returns the 24-hour
equivalent of <code>h</code> in the range <code>[0h, 11h]</code>, assuming <code>h</code>
represents an ante meridiem hour. Else returns the 24-hour equivalent of <code>h</code>
in the range <code>[12h, 23h]</code>, assuming <code>h</code> represents a post
meridiem hour. If <code>h</code> is not in the range
<code>[1h, 12h]</code>, the value returned is unspecified.
</p>
</blockquote>
</blockquote>
</blockquote>
</li>
</ol>
</body>
</html>