From Jason Turner

[time.clock.gps]

Diff to HTML by rtfpessoa

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