- tmp/tmp81u88no5/{from.md → to.md} +7001 -257
tmp/tmp81u88no5/{from.md → to.md}
RENAMED
|
@@ -1,16 +1,39 @@
|
|
| 1 |
-
#
|
| 2 |
|
| 3 |
-
##
|
| 4 |
|
| 5 |
-
This
|
| 6 |
-
|
| 7 |
-
|
| 8 |
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
``` cpp
|
|
|
|
|
|
|
| 12 |
namespace std {
|
| 13 |
namespace chrono {
|
| 14 |
// [time.duration], class template duration
|
| 15 |
template<class Rep, class Period = ratio<1>> class duration;
|
| 16 |
|
|
@@ -28,213 +51,894 @@ namespace std {
|
|
| 28 |
chrono::time_point<Clock, Duration2>>;
|
| 29 |
|
| 30 |
namespace chrono {
|
| 31 |
// [time.traits], customization traits
|
| 32 |
template<class Rep> struct treat_as_floating_point;
|
|
|
|
|
|
|
|
|
|
| 33 |
template<class Rep> struct duration_values;
|
| 34 |
-
|
| 35 |
-
|
|
|
|
| 36 |
|
| 37 |
// [time.duration.nonmember], duration arithmetic
|
| 38 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 39 |
-
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 40 |
-
|
| 41 |
-
const duration<Rep2, Period2>& rhs);
|
| 42 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 43 |
-
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 44 |
-
|
| 45 |
-
const duration<Rep2, Period2>& rhs);
|
| 46 |
template<class Rep1, class Period, class Rep2>
|
| 47 |
-
duration<common_type_t<Rep1, Rep2>, Period>
|
| 48 |
-
|
| 49 |
template<class Rep1, class Rep2, class Period>
|
| 50 |
-
duration<common_type_t<Rep1, Rep2>, Period>
|
| 51 |
-
|
| 52 |
template<class Rep1, class Period, class Rep2>
|
| 53 |
-
duration<common_type_t<Rep1, Rep2>, Period>
|
| 54 |
-
|
| 55 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 56 |
-
common_type_t<Rep1, Rep2>
|
| 57 |
-
|
| 58 |
-
const duration<Rep2, Period2>& rhs);
|
| 59 |
template<class Rep1, class Period, class Rep2>
|
| 60 |
-
duration<common_type_t<Rep1, Rep2>, Period>
|
| 61 |
-
|
| 62 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 63 |
-
common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 64 |
-
|
| 65 |
-
const duration<Rep2, Period2>& rhs);
|
| 66 |
|
| 67 |
// [time.duration.comparisons], duration comparisons
|
| 68 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 69 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
| 70 |
const duration<Rep2, Period2>& rhs);
|
| 71 |
-
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 72 |
-
constexpr bool operator!=(const duration<Rep1, Period1>& lhs,
|
| 73 |
-
const duration<Rep2, Period2>& rhs);
|
| 74 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 75 |
constexpr bool operator< (const duration<Rep1, Period1>& lhs,
|
| 76 |
const duration<Rep2, Period2>& rhs);
|
| 77 |
-
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 78 |
-
constexpr bool operator<=(const duration<Rep1, Period1>& lhs,
|
| 79 |
-
const duration<Rep2, Period2>& rhs);
|
| 80 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 81 |
constexpr bool operator> (const duration<Rep1, Period1>& lhs,
|
| 82 |
const duration<Rep2, Period2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 83 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 84 |
constexpr bool operator>=(const duration<Rep1, Period1>& lhs,
|
| 85 |
const duration<Rep2, Period2>& rhs);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 86 |
|
| 87 |
-
// [time.duration.cast],
|
| 88 |
template<class ToDuration, class Rep, class Period>
|
| 89 |
constexpr ToDuration duration_cast(const duration<Rep, Period>& d);
|
| 90 |
template<class ToDuration, class Rep, class Period>
|
| 91 |
constexpr ToDuration floor(const duration<Rep, Period>& d);
|
| 92 |
template<class ToDuration, class Rep, class Period>
|
| 93 |
constexpr ToDuration ceil(const duration<Rep, Period>& d);
|
| 94 |
template<class ToDuration, class Rep, class Period>
|
| 95 |
constexpr ToDuration round(const duration<Rep, Period>& d);
|
| 96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 97 |
// convenience typedefs
|
| 98 |
using nanoseconds = duration<signed integer type of at least 64 bits, nano>;
|
| 99 |
using microseconds = duration<signed integer type of at least 55 bits, micro>;
|
| 100 |
using milliseconds = duration<signed integer type of at least 45 bits, milli>;
|
| 101 |
using seconds = duration<signed integer type of at least 35 bits>;
|
| 102 |
using minutes = duration<signed integer type of at least 29 bits, ratio< 60>>;
|
| 103 |
using hours = duration<signed integer type of at least 23 bits, ratio<3600>>;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 104 |
|
| 105 |
// [time.point.nonmember], time_point arithmetic
|
| 106 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 107 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 108 |
-
|
| 109 |
-
const duration<Rep2, Period2>& rhs);
|
| 110 |
template<class Rep1, class Period1, class Clock, class Duration2>
|
| 111 |
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 112 |
-
|
| 113 |
-
const time_point<Clock, Duration2>& rhs);
|
| 114 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 115 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 116 |
-
|
| 117 |
-
const duration<Rep2, Period2>& rhs);
|
| 118 |
template<class Clock, class Duration1, class Duration2>
|
| 119 |
constexpr common_type_t<Duration1, Duration2>
|
| 120 |
operator-(const time_point<Clock, Duration1>& lhs,
|
| 121 |
const time_point<Clock, Duration2>& rhs);
|
| 122 |
|
| 123 |
// [time.point.comparisons], time_point comparisons
|
| 124 |
template<class Clock, class Duration1, class Duration2>
|
| 125 |
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 126 |
const time_point<Clock, Duration2>& rhs);
|
| 127 |
-
template <class Clock, class Duration1, class Duration2>
|
| 128 |
-
constexpr bool operator!=(const time_point<Clock, Duration1>& lhs,
|
| 129 |
-
const time_point<Clock, Duration2>& rhs);
|
| 130 |
template<class Clock, class Duration1, class Duration2>
|
| 131 |
constexpr bool operator< (const time_point<Clock, Duration1>& lhs,
|
| 132 |
const time_point<Clock, Duration2>& rhs);
|
| 133 |
-
template <class Clock, class Duration1, class Duration2>
|
| 134 |
-
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 135 |
-
const time_point<Clock, Duration2>& rhs);
|
| 136 |
template<class Clock, class Duration1, class Duration2>
|
| 137 |
constexpr bool operator> (const time_point<Clock, Duration1>& lhs,
|
| 138 |
const time_point<Clock, Duration2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 139 |
template<class Clock, class Duration1, class Duration2>
|
| 140 |
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 141 |
const time_point<Clock, Duration2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 142 |
|
| 143 |
-
// [time.point.cast],
|
| 144 |
template<class ToDuration, class Clock, class Duration>
|
| 145 |
constexpr time_point<Clock, ToDuration>
|
| 146 |
time_point_cast(const time_point<Clock, Duration>& t);
|
| 147 |
template<class ToDuration, class Clock, class Duration>
|
| 148 |
-
constexpr time_point<Clock, ToDuration>
|
| 149 |
-
floor(const time_point<Clock, Duration>& tp);
|
| 150 |
template<class ToDuration, class Clock, class Duration>
|
| 151 |
-
constexpr time_point<Clock, ToDuration>
|
| 152 |
-
ceil(const time_point<Clock, Duration>& tp);
|
| 153 |
template<class ToDuration, class Clock, class Duration>
|
| 154 |
-
constexpr time_point<Clock, ToDuration>
|
| 155 |
-
round(const time_point<Clock, Duration>& tp);
|
| 156 |
|
| 157 |
// [time.duration.alg], specialized algorithms
|
| 158 |
template<class Rep, class Period>
|
| 159 |
constexpr duration<Rep, Period> abs(duration<Rep, Period> d);
|
| 160 |
|
| 161 |
-
// [time.clock],
|
| 162 |
class system_clock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 163 |
class steady_clock;
|
|
|
|
|
|
|
| 164 |
class high_resolution_clock;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
}
|
| 166 |
|
| 167 |
inline namespace literals {
|
| 168 |
inline namespace chrono_literals {
|
| 169 |
// [time.duration.literals], suffixes for duration literals
|
| 170 |
constexpr chrono::hours operator""h(unsigned long long);
|
| 171 |
constexpr chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double);
|
|
|
|
| 172 |
constexpr chrono::minutes operator""min(unsigned long long);
|
| 173 |
constexpr chrono::duration<unspecified, ratio<60, 1>> operator""min(long double);
|
|
|
|
| 174 |
constexpr chrono::seconds operator""s(unsigned long long);
|
| 175 |
constexpr chrono::duration<unspecified> operator""s(long double);
|
|
|
|
| 176 |
constexpr chrono::milliseconds operator""ms(unsigned long long);
|
| 177 |
constexpr chrono::duration<unspecified, milli> operator""ms(long double);
|
|
|
|
| 178 |
constexpr chrono::microseconds operator""us(unsigned long long);
|
| 179 |
constexpr chrono::duration<unspecified, micro> operator""us(long double);
|
|
|
|
| 180 |
constexpr chrono::nanoseconds operator""ns(unsigned long long);
|
| 181 |
constexpr chrono::duration<unspecified, nano> operator""ns(long double);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
}
|
| 183 |
}
|
| 184 |
|
| 185 |
namespace chrono {
|
| 186 |
using namespace literals::chrono_literals;
|
| 187 |
}
|
| 188 |
}
|
| 189 |
```
|
| 190 |
|
| 191 |
-
##
|
| 192 |
|
| 193 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
| 194 |
function `now()` to get the current `time_point`. The origin of the
|
| 195 |
clock’s `time_point` is referred to as the clock’s *epoch*. A clock
|
| 196 |
-
shall meet the requirements in
|
| 197 |
|
| 198 |
-
In
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
|
| 203 |
[*Note 1*: This means `C1` did not wrap around between `t1` and
|
| 204 |
`t2`. — *end note*]
|
| 205 |
|
| 206 |
[*Note 2*: The relative difference in durations between those reported
|
| 207 |
by a given clock and the SI definition is a measure of the quality of
|
| 208 |
implementation. — *end note*]
|
| 209 |
|
| 210 |
-
A type `TC` meets the
|
| 211 |
|
| 212 |
-
- `TC`
|
| 213 |
-
- the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 214 |
-
|
| 215 |
-
[[
|
| 216 |
-
[[
|
| 217 |
-
[[tab:defaultconstructible]]), `CopyConstructible` (Table
|
| 218 |
-
[[tab:copyconstructible]]), `CopyAssignable` (Table
|
| 219 |
-
[[tab:copyassignable]]), `Destructible` (Table [[tab:destructible]]),
|
| 220 |
-
and the requirements of numeric types ([[numeric.requirements]]).
|
| 221 |
\[*Note 3*: This means, in particular, that operations on these types
|
| 222 |
will not throw exceptions. — *end note*]
|
| 223 |
- lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 224 |
-
are swappable
|
| 225 |
- the function `TC::now()` does not throw exceptions, and
|
| 226 |
-
- the type `TC::time_point::clock` meets the
|
| 227 |
requirements, recursively.
|
| 228 |
|
| 229 |
-
##
|
| 230 |
|
| 231 |
-
###
|
| 232 |
|
| 233 |
``` cpp
|
| 234 |
-
template
|
| 235 |
-
: is_floating_point<Rep> { };
|
| 236 |
```
|
| 237 |
|
| 238 |
The `duration` template uses the `treat_as_floating_point` trait to help
|
| 239 |
determine if a `duration` object can be converted to another `duration`
|
| 240 |
with a different tick `period`. If `treat_as_floating_point_v<Rep>` is
|
|
@@ -247,69 +951,68 @@ class behaves like a floating-point type, and thus allows division of
|
|
| 247 |
one value by another with acceptable loss of precision. If
|
| 248 |
`treat_as_floating_point_v<Rep>` is `false`, `Rep` will be treated as if
|
| 249 |
it behaved like an integral type for the purpose of these
|
| 250 |
conversions. — *end note*]
|
| 251 |
|
| 252 |
-
###
|
| 253 |
|
| 254 |
``` cpp
|
| 255 |
template<class Rep>
|
| 256 |
struct duration_values {
|
| 257 |
public:
|
| 258 |
-
|
| 259 |
-
|
| 260 |
-
|
| 261 |
};
|
| 262 |
```
|
| 263 |
|
| 264 |
The `duration` template uses the `duration_values` trait to construct
|
| 265 |
-
special values of the
|
| 266 |
because the representation might be a class type with behavior which
|
| 267 |
requires some other implementation to return these special values. In
|
| 268 |
that case, the author of that class type should specialize
|
| 269 |
`duration_values` to return the indicated values.
|
| 270 |
|
| 271 |
``` cpp
|
| 272 |
-
static constexpr Rep zero();
|
| 273 |
```
|
| 274 |
|
| 275 |
*Returns:* `Rep(0)`.
|
| 276 |
|
| 277 |
[*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()` may
|
| 278 |
have some other meaning, such as an uninitialized value. — *end note*]
|
| 279 |
|
| 280 |
*Remarks:* The value returned shall be the additive identity.
|
| 281 |
|
| 282 |
``` cpp
|
| 283 |
-
static constexpr Rep min();
|
| 284 |
```
|
| 285 |
|
| 286 |
*Returns:* `numeric_limits<Rep>::lowest()`.
|
| 287 |
|
| 288 |
*Remarks:* The value returned shall compare less than or equal to
|
| 289 |
`zero()`.
|
| 290 |
|
| 291 |
``` cpp
|
| 292 |
-
static constexpr Rep max();
|
| 293 |
```
|
| 294 |
|
| 295 |
*Returns:* `numeric_limits<Rep>::max()`.
|
| 296 |
|
| 297 |
*Remarks:* The value returned shall compare greater than `zero()`.
|
| 298 |
|
| 299 |
-
###
|
| 300 |
|
| 301 |
``` cpp
|
| 302 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 303 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 304 |
using type = chrono::duration<common_type_t<Rep1, Rep2>, see below>;
|
| 305 |
};
|
| 306 |
```
|
| 307 |
|
| 308 |
The `period` of the `duration` indicated by this specialization of
|
| 309 |
-
`common_type`
|
| 310 |
-
`Period2`.
|
| 311 |
|
| 312 |
[*Note 1*: This can be computed by forming a ratio of the greatest
|
| 313 |
common divisor of `Period1::num` and `Period2::num` and the least common
|
| 314 |
multiple of `Period1::den` and `Period2::den`. — *end note*]
|
| 315 |
|
|
@@ -329,26 +1032,53 @@ struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Cloc
|
|
| 329 |
|
| 330 |
The common type of two `time_point` types is a `time_point` with the
|
| 331 |
same clock as the two types and the common type of their two
|
| 332 |
`duration`s.
|
| 333 |
|
| 334 |
-
### Class template `
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 335 |
|
| 336 |
A `duration` type measures time between two points in time
|
| 337 |
(`time_point`s). A `duration` has a representation which holds a count
|
| 338 |
of ticks and a tick period. The tick period is the amount of time which
|
| 339 |
occurs from one tick to the next, in units of seconds. It is expressed
|
| 340 |
as a rational constant using the template `ratio`.
|
| 341 |
|
| 342 |
``` cpp
|
|
|
|
| 343 |
template<class Rep, class Period = ratio<1>>
|
| 344 |
class duration {
|
| 345 |
public:
|
| 346 |
using rep = Rep;
|
| 347 |
using period = typename Period::type;
|
|
|
|
| 348 |
private:
|
| 349 |
rep rep_; // exposition only
|
|
|
|
| 350 |
public:
|
| 351 |
// [time.duration.cons], construct/copy/destroy
|
| 352 |
constexpr duration() = default;
|
| 353 |
template<class Rep2>
|
| 354 |
constexpr explicit duration(const Rep2& r);
|
|
@@ -376,25 +1106,26 @@ public:
|
|
| 376 |
constexpr duration& operator/=(const rep& rhs);
|
| 377 |
constexpr duration& operator%=(const rep& rhs);
|
| 378 |
constexpr duration& operator%=(const duration& rhs);
|
| 379 |
|
| 380 |
// [time.duration.special], special values
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
};
|
|
|
|
| 385 |
```
|
| 386 |
|
| 387 |
`Rep` shall be an arithmetic type or a class emulating an arithmetic
|
| 388 |
type. If `duration` is instantiated with a `duration` type as the
|
| 389 |
argument for the template parameter `Rep`, the program is ill-formed.
|
| 390 |
|
| 391 |
If `Period` is not a specialization of `ratio`, the program is
|
| 392 |
ill-formed. If `Period::num` is not positive, the program is ill-formed.
|
| 393 |
|
| 394 |
-
Members of `duration`
|
| 395 |
-
|
| 396 |
|
| 397 |
The defaulted copy constructor of duration shall be a constexpr function
|
| 398 |
if and only if the required initialization of the member `rep_` for copy
|
| 399 |
and move, respectively, would satisfy the requirements for a constexpr
|
| 400 |
function.
|
|
@@ -408,19 +1139,18 @@ duration<double, ratio<1, 30>> d2; // holds a count with a tick period of $\fra
|
|
| 408 |
// (30 Hz) using a double
|
| 409 |
```
|
| 410 |
|
| 411 |
— *end example*]
|
| 412 |
|
| 413 |
-
###
|
| 414 |
|
| 415 |
``` cpp
|
| 416 |
template<class Rep2>
|
| 417 |
constexpr explicit duration(const Rep2& r);
|
| 418 |
```
|
| 419 |
|
| 420 |
-
*
|
| 421 |
-
unless `Rep2` is implicitly convertible to `rep` and
|
| 422 |
|
| 423 |
- `treat_as_floating_point_v<rep>` is `true` or
|
| 424 |
- `treat_as_floating_point_v<Rep2>` is `false`.
|
| 425 |
|
| 426 |
[*Example 1*:
|
|
@@ -430,21 +1160,18 @@ duration<int, milli> d(3); // OK
|
|
| 430 |
duration<int, milli> d(3.5); // error
|
| 431 |
```
|
| 432 |
|
| 433 |
— *end example*]
|
| 434 |
|
| 435 |
-
*
|
| 436 |
-
|
| 437 |
-
*Postconditions:* `count() == static_cast<rep>(r)`.
|
| 438 |
|
| 439 |
``` cpp
|
| 440 |
template<class Rep2, class Period2>
|
| 441 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 442 |
```
|
| 443 |
|
| 444 |
-
*
|
| 445 |
-
unless no overflow is induced in the conversion and
|
| 446 |
`treat_as_floating_point_v<rep>` is `true` or both
|
| 447 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 448 |
`treat_as_floating_point_v<Rep2>` is `false`.
|
| 449 |
|
| 450 |
[*Note 1*: This requirement prevents implicit truncation error when
|
|
@@ -460,23 +1187,21 @@ duration<int, micro> us = ms; // OK
|
|
| 460 |
duration<int, milli> ms2 = us; // error
|
| 461 |
```
|
| 462 |
|
| 463 |
— *end example*]
|
| 464 |
|
| 465 |
-
*Effects:*
|
| 466 |
-
from
|
| 467 |
-
`duration_cast<duration>(d).count()`.
|
| 468 |
|
| 469 |
-
###
|
| 470 |
|
| 471 |
``` cpp
|
| 472 |
constexpr rep count() const;
|
| 473 |
```
|
| 474 |
|
| 475 |
*Returns:* `rep_`.
|
| 476 |
|
| 477 |
-
###
|
| 478 |
|
| 479 |
``` cpp
|
| 480 |
constexpr common_type_t<duration> operator+() const;
|
| 481 |
```
|
| 482 |
|
|
@@ -490,106 +1215,106 @@ constexpr common_type_t<duration> operator-() const;
|
|
| 490 |
|
| 491 |
``` cpp
|
| 492 |
constexpr duration& operator++();
|
| 493 |
```
|
| 494 |
|
| 495 |
-
*Effects:*
|
| 496 |
|
| 497 |
*Returns:* `*this`.
|
| 498 |
|
| 499 |
``` cpp
|
| 500 |
constexpr duration operator++(int);
|
| 501 |
```
|
| 502 |
|
| 503 |
-
*
|
| 504 |
|
| 505 |
``` cpp
|
| 506 |
constexpr duration& operator--();
|
| 507 |
```
|
| 508 |
|
| 509 |
-
*Effects:*
|
| 510 |
|
| 511 |
*Returns:* `*this`.
|
| 512 |
|
| 513 |
``` cpp
|
| 514 |
constexpr duration operator--(int);
|
| 515 |
```
|
| 516 |
|
| 517 |
-
*
|
| 518 |
|
| 519 |
``` cpp
|
| 520 |
constexpr duration& operator+=(const duration& d);
|
| 521 |
```
|
| 522 |
|
| 523 |
-
*Effects:*
|
| 524 |
|
| 525 |
*Returns:* `*this`.
|
| 526 |
|
| 527 |
``` cpp
|
| 528 |
constexpr duration& operator-=(const duration& d);
|
| 529 |
```
|
| 530 |
|
| 531 |
-
*Effects:*
|
| 532 |
|
| 533 |
*Returns:* `*this`.
|
| 534 |
|
| 535 |
``` cpp
|
| 536 |
constexpr duration& operator*=(const rep& rhs);
|
| 537 |
```
|
| 538 |
|
| 539 |
-
*Effects:*
|
| 540 |
|
| 541 |
*Returns:* `*this`.
|
| 542 |
|
| 543 |
``` cpp
|
| 544 |
constexpr duration& operator/=(const rep& rhs);
|
| 545 |
```
|
| 546 |
|
| 547 |
-
*Effects:*
|
| 548 |
|
| 549 |
*Returns:* `*this`.
|
| 550 |
|
| 551 |
``` cpp
|
| 552 |
constexpr duration& operator%=(const rep& rhs);
|
| 553 |
```
|
| 554 |
|
| 555 |
-
*Effects:*
|
| 556 |
|
| 557 |
*Returns:* `*this`.
|
| 558 |
|
| 559 |
``` cpp
|
| 560 |
constexpr duration& operator%=(const duration& rhs);
|
| 561 |
```
|
| 562 |
|
| 563 |
-
*Effects:*
|
| 564 |
|
| 565 |
*Returns:* `*this`.
|
| 566 |
|
| 567 |
-
###
|
| 568 |
|
| 569 |
``` cpp
|
| 570 |
-
static constexpr duration zero();
|
| 571 |
```
|
| 572 |
|
| 573 |
*Returns:* `duration(duration_values<rep>::zero())`.
|
| 574 |
|
| 575 |
``` cpp
|
| 576 |
-
static constexpr duration min();
|
| 577 |
```
|
| 578 |
|
| 579 |
*Returns:* `duration(duration_values<rep>::min())`.
|
| 580 |
|
| 581 |
``` cpp
|
| 582 |
-
static constexpr duration max();
|
| 583 |
```
|
| 584 |
|
| 585 |
*Returns:* `duration(duration_values<rep>::max())`.
|
| 586 |
|
| 587 |
-
###
|
| 588 |
|
| 589 |
-
In the function descriptions that follow,
|
| 590 |
-
|
| 591 |
|
| 592 |
``` cpp
|
| 593 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 594 |
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 595 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
@@ -609,55 +1334,58 @@ template <class Rep1, class Period1, class Rep2, class Period2>
|
|
| 609 |
template<class Rep1, class Period, class Rep2>
|
| 610 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 611 |
operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 612 |
```
|
| 613 |
|
| 614 |
-
*
|
| 615 |
-
|
| 616 |
|
| 617 |
*Returns:* `CD(CD(d).count() * s)`.
|
| 618 |
|
| 619 |
``` cpp
|
| 620 |
template<class Rep1, class Rep2, class Period>
|
| 621 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 622 |
operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 623 |
```
|
| 624 |
|
| 625 |
-
*
|
| 626 |
-
|
| 627 |
|
| 628 |
*Returns:* `d * s`.
|
| 629 |
|
| 630 |
``` cpp
|
| 631 |
template<class Rep1, class Period, class Rep2>
|
| 632 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 633 |
operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 634 |
```
|
| 635 |
|
| 636 |
-
*
|
| 637 |
-
|
| 638 |
-
is not a specialization of `duration`.
|
| 639 |
|
| 640 |
*Returns:* `CD(CD(d).count() / s)`.
|
| 641 |
|
| 642 |
``` cpp
|
| 643 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 644 |
constexpr common_type_t<Rep1, Rep2>
|
| 645 |
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 646 |
```
|
| 647 |
|
|
|
|
|
|
|
|
|
|
| 648 |
*Returns:* `CD(lhs).count() / CD(rhs).count()`.
|
| 649 |
|
| 650 |
``` cpp
|
| 651 |
template<class Rep1, class Period, class Rep2>
|
| 652 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 653 |
operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 654 |
```
|
| 655 |
|
| 656 |
-
*
|
| 657 |
-
|
| 658 |
-
is not a specialization of `duration`.
|
| 659 |
|
| 660 |
*Returns:* `CD(CD(d).count() % s)`.
|
| 661 |
|
| 662 |
``` cpp
|
| 663 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
|
@@ -665,11 +1393,11 @@ template <class Rep1, class Period1, class Rep2, class Period2>
|
|
| 665 |
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 666 |
```
|
| 667 |
|
| 668 |
*Returns:* `CD(CD(lhs).count() % CD(rhs).count())`.
|
| 669 |
|
| 670 |
-
###
|
| 671 |
|
| 672 |
In the function descriptions that follow, `CT` represents
|
| 673 |
`common_type_t<A, B>`, where `A` and `B` are the types of the two
|
| 674 |
arguments to the function.
|
| 675 |
|
|
@@ -677,65 +1405,65 @@ arguments to the function.
|
|
| 677 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 678 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
| 679 |
const duration<Rep2, Period2>& rhs);
|
| 680 |
```
|
| 681 |
|
| 682 |
-
*Returns:*
|
| 683 |
-
|
| 684 |
-
``` cpp
|
| 685 |
-
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 686 |
-
constexpr bool operator!=(const duration<Rep1, Period1>& lhs,
|
| 687 |
-
const duration<Rep2, Period2>& rhs);
|
| 688 |
-
```
|
| 689 |
-
|
| 690 |
-
*Returns:* `!(lhs == rhs)`.
|
| 691 |
|
| 692 |
``` cpp
|
| 693 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 694 |
constexpr bool operator<(const duration<Rep1, Period1>& lhs,
|
| 695 |
const duration<Rep2, Period2>& rhs);
|
| 696 |
```
|
| 697 |
|
| 698 |
-
*Returns:*
|
| 699 |
-
|
| 700 |
-
``` cpp
|
| 701 |
-
template <class Rep1, class Period1, class Rep2, class Period2>
|
| 702 |
-
constexpr bool operator<=(const duration<Rep1, Period1>& lhs,
|
| 703 |
-
const duration<Rep2, Period2>& rhs);
|
| 704 |
-
```
|
| 705 |
-
|
| 706 |
-
*Returns:* `!(rhs < lhs)`.
|
| 707 |
|
| 708 |
``` cpp
|
| 709 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 710 |
constexpr bool operator>(const duration<Rep1, Period1>& lhs,
|
| 711 |
const duration<Rep2, Period2>& rhs);
|
| 712 |
```
|
| 713 |
|
| 714 |
*Returns:* `rhs < lhs`.
|
| 715 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 716 |
``` cpp
|
| 717 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 718 |
constexpr bool operator>=(const duration<Rep1, Period1>& lhs,
|
| 719 |
const duration<Rep2, Period2>& rhs);
|
| 720 |
```
|
| 721 |
|
| 722 |
*Returns:* `!(lhs < rhs)`.
|
| 723 |
|
| 724 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 725 |
|
| 726 |
``` cpp
|
| 727 |
template<class ToDuration, class Rep, class Period>
|
| 728 |
constexpr ToDuration duration_cast(const duration<Rep, Period>& d);
|
| 729 |
```
|
| 730 |
|
| 731 |
-
*
|
| 732 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 733 |
|
| 734 |
*Returns:* Let `CF` be
|
| 735 |
`ratio_divide<Period, typename ToDuration::period>`, and `CR` be
|
| 736 |
-
`common_type<
|
| 737 |
|
| 738 |
- If `CF::num == 1` and `CF::den == 1`, returns
|
| 739 |
``` cpp
|
| 740 |
ToDuration(static_cast<typename ToDuration::rep>(d.count()))
|
| 741 |
```
|
|
@@ -765,53 +1493,50 @@ the final step. — *end note*]
|
|
| 765 |
``` cpp
|
| 766 |
template<class ToDuration, class Rep, class Period>
|
| 767 |
constexpr ToDuration floor(const duration<Rep, Period>& d);
|
| 768 |
```
|
| 769 |
|
| 770 |
-
*
|
| 771 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 772 |
|
| 773 |
*Returns:* The greatest result `t` representable in `ToDuration` for
|
| 774 |
which `t <= d`.
|
| 775 |
|
| 776 |
``` cpp
|
| 777 |
template<class ToDuration, class Rep, class Period>
|
| 778 |
constexpr ToDuration ceil(const duration<Rep, Period>& d);
|
| 779 |
```
|
| 780 |
|
| 781 |
-
*
|
| 782 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 783 |
|
| 784 |
*Returns:* The least result `t` representable in `ToDuration` for which
|
| 785 |
`t >= d`.
|
| 786 |
|
| 787 |
``` cpp
|
| 788 |
template<class ToDuration, class Rep, class Period>
|
| 789 |
constexpr ToDuration round(const duration<Rep, Period>& d);
|
| 790 |
```
|
| 791 |
|
| 792 |
-
*
|
| 793 |
-
unless `ToDuration` is a specialization of `duration`, and
|
| 794 |
`treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
|
| 795 |
|
| 796 |
*Returns:* The value of `ToDuration` that is closest to `d`. If there
|
| 797 |
are two closest values, then return the value `t` for which
|
| 798 |
`t % 2 == 0`.
|
| 799 |
|
| 800 |
-
###
|
| 801 |
|
| 802 |
-
This
|
| 803 |
literals. The suffixes `h`, `min`, `s`, `ms`, `us`, `ns` denote duration
|
| 804 |
values of the corresponding types `hours`, `minutes`, `seconds`,
|
| 805 |
`milliseconds`, `microseconds`, and `nanoseconds` respectively if they
|
| 806 |
-
are applied to
|
| 807 |
|
| 808 |
-
If any of these suffixes are applied to a floating-point
|
| 809 |
result is a `chrono::duration` literal with an unspecified
|
| 810 |
floating-point representation.
|
| 811 |
|
| 812 |
-
If any of these suffixes are applied to an integer
|
| 813 |
resulting `chrono::duration` value cannot be represented in the result
|
| 814 |
type because of overflow, the program is ill-formed.
|
| 815 |
|
| 816 |
[*Example 1*:
|
| 817 |
|
|
@@ -870,32 +1595,111 @@ constexpr chrono::nanoseconds operator""ns(unsigned long long ns
|
|
| 870 |
constexpr chrono::duration<unspecified, nano> operator""ns(long double nsec);
|
| 871 |
```
|
| 872 |
|
| 873 |
*Returns:* A `duration` literal representing `nsec` nanoseconds.
|
| 874 |
|
| 875 |
-
###
|
| 876 |
|
| 877 |
``` cpp
|
| 878 |
template<class Rep, class Period>
|
| 879 |
constexpr duration<Rep, Period> abs(duration<Rep, Period> d);
|
| 880 |
```
|
| 881 |
|
| 882 |
-
*
|
| 883 |
-
unless `numeric_limits<Rep>::is_signed` is `true`.
|
| 884 |
|
| 885 |
*Returns:* If `d >= d.zero()`, return `d`, otherwise return `-d`.
|
| 886 |
|
| 887 |
-
###
|
| 888 |
|
| 889 |
``` cpp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 890 |
template<class Clock, class Duration = typename Clock::duration>
|
| 891 |
class time_point {
|
| 892 |
public:
|
| 893 |
using clock = Clock;
|
| 894 |
using duration = Duration;
|
| 895 |
using rep = typename duration::rep;
|
| 896 |
using period = typename duration::period;
|
|
|
|
| 897 |
private:
|
| 898 |
duration d_; // exposition only
|
| 899 |
|
| 900 |
public:
|
| 901 |
// [time.point.cons], construct
|
|
@@ -906,102 +1710,133 @@ public:
|
|
| 906 |
|
| 907 |
// [time.point.observer], observer
|
| 908 |
constexpr duration time_since_epoch() const;
|
| 909 |
|
| 910 |
// [time.point.arithmetic], arithmetic
|
|
|
|
|
|
|
|
|
|
|
|
|
| 911 |
constexpr time_point& operator+=(const duration& d);
|
| 912 |
constexpr time_point& operator-=(const duration& d);
|
| 913 |
|
| 914 |
// [time.point.special], special values
|
| 915 |
-
|
| 916 |
-
|
| 917 |
};
|
|
|
|
| 918 |
```
|
| 919 |
|
| 920 |
-
`Clock` shall meet the
|
|
|
|
| 921 |
|
| 922 |
If `Duration` is not an instance of `duration`, the program is
|
| 923 |
ill-formed.
|
| 924 |
|
| 925 |
-
###
|
| 926 |
|
| 927 |
``` cpp
|
| 928 |
constexpr time_point();
|
| 929 |
```
|
| 930 |
|
| 931 |
-
*Effects:*
|
| 932 |
-
|
| 933 |
-
epoch.
|
| 934 |
|
| 935 |
``` cpp
|
| 936 |
constexpr explicit time_point(const duration& d);
|
| 937 |
```
|
| 938 |
|
| 939 |
-
*Effects:*
|
| 940 |
-
|
| 941 |
|
| 942 |
``` cpp
|
| 943 |
template<class Duration2>
|
| 944 |
constexpr time_point(const time_point<clock, Duration2>& t);
|
| 945 |
```
|
| 946 |
|
| 947 |
-
*
|
| 948 |
-
unless `Duration2` is implicitly convertible to `duration`.
|
| 949 |
|
| 950 |
-
*Effects:*
|
| 951 |
-
with `t.time_since_epoch()`.
|
| 952 |
|
| 953 |
-
###
|
| 954 |
|
| 955 |
``` cpp
|
| 956 |
constexpr duration time_since_epoch() const;
|
| 957 |
```
|
| 958 |
|
| 959 |
*Returns:* `d_`.
|
| 960 |
|
| 961 |
-
###
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 962 |
|
| 963 |
``` cpp
|
| 964 |
constexpr time_point& operator+=(const duration& d);
|
| 965 |
```
|
| 966 |
|
| 967 |
-
*Effects:*
|
| 968 |
|
| 969 |
*Returns:* `*this`.
|
| 970 |
|
| 971 |
``` cpp
|
| 972 |
constexpr time_point& operator-=(const duration& d);
|
| 973 |
```
|
| 974 |
|
| 975 |
-
*Effects:*
|
| 976 |
|
| 977 |
*Returns:* `*this`.
|
| 978 |
|
| 979 |
-
###
|
| 980 |
|
| 981 |
``` cpp
|
| 982 |
-
static constexpr time_point min();
|
| 983 |
```
|
| 984 |
|
| 985 |
*Returns:* `time_point(duration::min())`.
|
| 986 |
|
| 987 |
``` cpp
|
| 988 |
-
static constexpr time_point max();
|
| 989 |
```
|
| 990 |
|
| 991 |
*Returns:* `time_point(duration::max())`.
|
| 992 |
|
| 993 |
-
###
|
| 994 |
|
| 995 |
``` cpp
|
| 996 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 997 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 998 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 999 |
```
|
| 1000 |
|
| 1001 |
-
*Returns:*
|
| 1002 |
-
|
| 1003 |
|
| 1004 |
``` cpp
|
| 1005 |
template<class Rep1, class Period1, class Clock, class Duration2>
|
| 1006 |
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 1007 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
|
@@ -1013,159 +1848,167 @@ template <class Rep1, class Period1, class Clock, class Duration2>
|
|
| 1013 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 1014 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 1015 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 1016 |
```
|
| 1017 |
|
| 1018 |
-
*Returns:*
|
| 1019 |
-
|
| 1020 |
|
| 1021 |
``` cpp
|
| 1022 |
template<class Clock, class Duration1, class Duration2>
|
| 1023 |
constexpr common_type_t<Duration1, Duration2>
|
| 1024 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 1025 |
```
|
| 1026 |
|
| 1027 |
*Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
|
| 1028 |
|
| 1029 |
-
###
|
| 1030 |
|
| 1031 |
``` cpp
|
| 1032 |
template<class Clock, class Duration1, class Duration2>
|
| 1033 |
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 1034 |
const time_point<Clock, Duration2>& rhs);
|
| 1035 |
```
|
| 1036 |
|
| 1037 |
*Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
|
| 1038 |
|
| 1039 |
-
``` cpp
|
| 1040 |
-
template <class Clock, class Duration1, class Duration2>
|
| 1041 |
-
constexpr bool operator!=(const time_point<Clock, Duration1>& lhs,
|
| 1042 |
-
const time_point<Clock, Duration2>& rhs);
|
| 1043 |
-
```
|
| 1044 |
-
|
| 1045 |
-
*Returns:* `!(lhs == rhs)`.
|
| 1046 |
-
|
| 1047 |
``` cpp
|
| 1048 |
template<class Clock, class Duration1, class Duration2>
|
| 1049 |
constexpr bool operator<(const time_point<Clock, Duration1>& lhs,
|
| 1050 |
const time_point<Clock, Duration2>& rhs);
|
| 1051 |
```
|
| 1052 |
|
| 1053 |
*Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
|
| 1054 |
|
| 1055 |
-
``` cpp
|
| 1056 |
-
template <class Clock, class Duration1, class Duration2>
|
| 1057 |
-
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 1058 |
-
const time_point<Clock, Duration2>& rhs);
|
| 1059 |
-
```
|
| 1060 |
-
|
| 1061 |
-
*Returns:* `!(rhs < lhs)`.
|
| 1062 |
-
|
| 1063 |
``` cpp
|
| 1064 |
template<class Clock, class Duration1, class Duration2>
|
| 1065 |
constexpr bool operator>(const time_point<Clock, Duration1>& lhs,
|
| 1066 |
const time_point<Clock, Duration2>& rhs);
|
| 1067 |
```
|
| 1068 |
|
| 1069 |
*Returns:* `rhs < lhs`.
|
| 1070 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1071 |
``` cpp
|
| 1072 |
template<class Clock, class Duration1, class Duration2>
|
| 1073 |
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 1074 |
const time_point<Clock, Duration2>& rhs);
|
| 1075 |
```
|
| 1076 |
|
| 1077 |
*Returns:* `!(lhs < rhs)`.
|
| 1078 |
|
| 1079 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1080 |
|
| 1081 |
``` cpp
|
| 1082 |
template<class ToDuration, class Clock, class Duration>
|
| 1083 |
-
constexpr time_point<Clock, ToDuration>
|
| 1084 |
-
time_point_cast(const time_point<Clock, Duration>& t);
|
| 1085 |
```
|
| 1086 |
|
| 1087 |
-
*
|
| 1088 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 1089 |
|
| 1090 |
*Returns:*
|
| 1091 |
|
| 1092 |
``` cpp
|
| 1093 |
time_point<Clock, ToDuration>(duration_cast<ToDuration>(t.time_since_epoch()))
|
| 1094 |
```
|
| 1095 |
|
| 1096 |
``` cpp
|
| 1097 |
template<class ToDuration, class Clock, class Duration>
|
| 1098 |
-
constexpr time_point<Clock, ToDuration>
|
| 1099 |
-
floor(const time_point<Clock, Duration>& tp);
|
| 1100 |
```
|
| 1101 |
|
| 1102 |
-
*
|
| 1103 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 1104 |
|
| 1105 |
*Returns:*
|
| 1106 |
`time_point<Clock, ToDuration>(floor<ToDuration>(tp.time_since_epoch()))`.
|
| 1107 |
|
| 1108 |
``` cpp
|
| 1109 |
template<class ToDuration, class Clock, class Duration>
|
| 1110 |
-
constexpr time_point<Clock, ToDuration>
|
| 1111 |
-
ceil(const time_point<Clock, Duration>& tp);
|
| 1112 |
```
|
| 1113 |
|
| 1114 |
-
*
|
| 1115 |
-
unless `ToDuration` is a specialization of `duration`.
|
| 1116 |
|
| 1117 |
*Returns:*
|
| 1118 |
`time_point<Clock, ToDuration>(ceil<ToDuration>(tp.time_since_epoch()))`.
|
| 1119 |
|
| 1120 |
``` cpp
|
| 1121 |
template<class ToDuration, class Clock, class Duration>
|
| 1122 |
-
constexpr time_point<Clock, ToDuration>
|
| 1123 |
-
round(const time_point<Clock, Duration>& tp);
|
| 1124 |
```
|
| 1125 |
|
| 1126 |
-
*
|
| 1127 |
-
unless `ToDuration` is a specialization of `duration`, and
|
| 1128 |
`treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
|
| 1129 |
|
| 1130 |
*Returns:*
|
| 1131 |
`time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
|
| 1132 |
|
| 1133 |
-
##
|
| 1134 |
|
| 1135 |
-
The types defined in this subclause
|
| 1136 |
-
requirements
|
| 1137 |
|
| 1138 |
-
###
|
| 1139 |
|
| 1140 |
-
|
| 1141 |
-
system-wide realtime clock.
|
| 1142 |
|
| 1143 |
``` cpp
|
|
|
|
| 1144 |
class system_clock {
|
| 1145 |
public:
|
| 1146 |
using rep = see below;
|
| 1147 |
using period = ratio<unspecified, unspecified{}>;
|
| 1148 |
using duration = chrono::duration<rep, period>;
|
| 1149 |
using time_point = chrono::time_point<system_clock>;
|
| 1150 |
static constexpr bool is_steady = unspecified;
|
| 1151 |
|
| 1152 |
static time_point now() noexcept;
|
| 1153 |
|
| 1154 |
-
|
| 1155 |
static time_t to_time_t (const time_point& t) noexcept;
|
| 1156 |
static time_point from_time_t(time_t t) noexcept;
|
| 1157 |
};
|
|
|
|
| 1158 |
```
|
| 1159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1160 |
``` cpp
|
| 1161 |
using system_clock::rep = unspecified;
|
| 1162 |
```
|
| 1163 |
|
| 1164 |
-
*
|
| 1165 |
-
`system_clock::duration::min() < system_clock::duration::zero()`
|
| 1166 |
-
|
| 1167 |
|
| 1168 |
[*Note 1*: This implies that `rep` is a signed type. — *end note*]
|
| 1169 |
|
| 1170 |
``` cpp
|
| 1171 |
static time_t to_time_t(const time_point& t) noexcept;
|
|
@@ -1183,50 +2026,5768 @@ static time_point from_time_t(time_t t) noexcept;
|
|
| 1183 |
*Returns:* A `time_point` object that represents the same point in time
|
| 1184 |
as `t` when both values are restricted to the coarser of the precisions
|
| 1185 |
of `time_t` and `time_point`. It is *implementation-defined* whether
|
| 1186 |
values are rounded or truncated to the required precision.
|
| 1187 |
|
| 1188 |
-
####
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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1192 |
values of `time_point` advance at a steady rate relative to real time.
|
| 1193 |
That is, the clock may not be adjusted.
|
| 1194 |
|
|
|
|
|
|
|
| 1195 |
``` cpp
|
| 1196 |
-
|
|
|
|
| 1197 |
public:
|
| 1198 |
using rep = unspecified;
|
| 1199 |
using period = ratio<unspecified, unspecified{}>;
|
| 1200 |
using duration = chrono::duration<rep, period>;
|
| 1201 |
using time_point = chrono::time_point<unspecified, duration>;
|
| 1202 |
-
|
| 1203 |
|
| 1204 |
static time_point now() noexcept;
|
| 1205 |
};
|
|
|
|
| 1206 |
```
|
| 1207 |
|
| 1208 |
-
#### Class `high_resolution_clock` <a id="time.clock.hires">[[time.clock.hires]]</a>
|
| 1209 |
-
|
| 1210 |
Objects of class `high_resolution_clock` represent clocks with the
|
| 1211 |
shortest tick period. `high_resolution_clock` may be a synonym for
|
| 1212 |
`system_clock` or `steady_clock`.
|
| 1213 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1228 |
|
| 1229 |
``` cpp
|
| 1230 |
#define NULL see [support.types.nullptr]
|
| 1231 |
#define CLOCKS_PER_SEC see below
|
| 1232 |
#define TIME_UTC see below
|
|
@@ -1251,12 +7812,195 @@ namespace std {
|
|
| 1251 |
size_t strftime(char* s, size_t maxsize, const char* format, const struct tm* timeptr);
|
| 1252 |
}
|
| 1253 |
```
|
| 1254 |
|
| 1255 |
The contents of the header `<ctime>` are the same as the C standard
|
| 1256 |
-
library header `<time.h>`. [^
|
| 1257 |
|
| 1258 |
The functions `asctime`, `ctime`, `gmtime`, and `localtime` are not
|
| 1259 |
-
required to avoid data races
|
| 1260 |
|
| 1261 |
-
ISO C
|
| 1262 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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|
+
functions [[ctime.syn]] that provide generally useful time utilities, as
|
| 7 |
+
summarized in [[time.summary]].
|
| 8 |
|
| 9 |
+
**Table: Time library summary** <a id="time.summary">[time.summary]</a>
|
| 10 |
+
|
| 11 |
+
| Subclause | | Header |
|
| 12 |
+
| ------------------ | --------------------------- | ---------- |
|
| 13 |
+
| [[time.clock.req]] | Cpp17Clock requirements | |
|
| 14 |
+
| [[time.traits]] | Time-related traits | `<chrono>` |
|
| 15 |
+
| [[time.duration]] | Class template `duration` | |
|
| 16 |
+
| [[time.point]] | Class template `time_point` | |
|
| 17 |
+
| [[time.clock]] | Clocks | |
|
| 18 |
+
| [[time.cal]] | Civil calendar | |
|
| 19 |
+
| [[time.hms]] | Class template `hh_mm_ss` | |
|
| 20 |
+
| [[time.12]] | 12/24 hour functions | |
|
| 21 |
+
| [[time.zone]] | Time zones | |
|
| 22 |
+
| [[time.format]] | Formatting | |
|
| 23 |
+
| [[time.parse]] | Parsing | |
|
| 24 |
+
| [[ctime.syn]] | C library time utilities | `<ctime>` |
|
| 25 |
+
|
| 26 |
+
|
| 27 |
+
Let *`STATICALLY-WIDEN`*`<charT>("...")` be `"..."` if `charT` is `char`
|
| 28 |
+
and `L"..."` if `charT` is `wchar_t`.
|
| 29 |
+
|
| 30 |
+
## Header `<chrono>` synopsis <a id="time.syn">[[time.syn]]</a>
|
| 31 |
|
| 32 |
``` cpp
|
| 33 |
+
#include <compare> // see [compare.syn]
|
| 34 |
+
|
| 35 |
namespace std {
|
| 36 |
namespace chrono {
|
| 37 |
// [time.duration], class template duration
|
| 38 |
template<class Rep, class Period = ratio<1>> class duration;
|
| 39 |
|
|
|
|
| 51 |
chrono::time_point<Clock, Duration2>>;
|
| 52 |
|
| 53 |
namespace chrono {
|
| 54 |
// [time.traits], customization traits
|
| 55 |
template<class Rep> struct treat_as_floating_point;
|
| 56 |
+
template<class Rep>
|
| 57 |
+
inline constexpr bool treat_as_floating_point_v = treat_as_floating_point<Rep>::value;
|
| 58 |
+
|
| 59 |
template<class Rep> struct duration_values;
|
| 60 |
+
|
| 61 |
+
template<class T> struct is_clock;
|
| 62 |
+
template<class T> inline constexpr bool is_clock_v = is_clock<T>::value;
|
| 63 |
|
| 64 |
// [time.duration.nonmember], duration arithmetic
|
| 65 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 66 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 67 |
+
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 68 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 69 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 70 |
+
operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 71 |
template<class Rep1, class Period, class Rep2>
|
| 72 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 73 |
+
operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 74 |
template<class Rep1, class Rep2, class Period>
|
| 75 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 76 |
+
operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 77 |
template<class Rep1, class Period, class Rep2>
|
| 78 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 79 |
+
operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 80 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 81 |
+
constexpr common_type_t<Rep1, Rep2>
|
| 82 |
+
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 83 |
template<class Rep1, class Period, class Rep2>
|
| 84 |
+
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 85 |
+
operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 86 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 87 |
+
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 88 |
+
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 89 |
|
| 90 |
// [time.duration.comparisons], duration comparisons
|
| 91 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 92 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
| 93 |
const duration<Rep2, Period2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 94 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 95 |
constexpr bool operator< (const duration<Rep1, Period1>& lhs,
|
| 96 |
const duration<Rep2, Period2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 97 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 98 |
constexpr bool operator> (const duration<Rep1, Period1>& lhs,
|
| 99 |
const duration<Rep2, Period2>& rhs);
|
| 100 |
+
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 101 |
+
constexpr bool operator<=(const duration<Rep1, Period1>& lhs,
|
| 102 |
+
const duration<Rep2, Period2>& rhs);
|
| 103 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 104 |
constexpr bool operator>=(const duration<Rep1, Period1>& lhs,
|
| 105 |
const duration<Rep2, Period2>& rhs);
|
| 106 |
+
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 107 |
+
requires see below
|
| 108 |
+
constexpr auto operator<=>(const duration<Rep1, Period1>& lhs,
|
| 109 |
+
const duration<Rep2, Period2>& rhs);
|
| 110 |
|
| 111 |
+
// [time.duration.cast], conversions
|
| 112 |
template<class ToDuration, class Rep, class Period>
|
| 113 |
constexpr ToDuration duration_cast(const duration<Rep, Period>& d);
|
| 114 |
template<class ToDuration, class Rep, class Period>
|
| 115 |
constexpr ToDuration floor(const duration<Rep, Period>& d);
|
| 116 |
template<class ToDuration, class Rep, class Period>
|
| 117 |
constexpr ToDuration ceil(const duration<Rep, Period>& d);
|
| 118 |
template<class ToDuration, class Rep, class Period>
|
| 119 |
constexpr ToDuration round(const duration<Rep, Period>& d);
|
| 120 |
|
| 121 |
+
// [time.duration.io], duration I/O
|
| 122 |
+
template<class charT, class traits, class Rep, class Period>
|
| 123 |
+
basic_ostream<charT, traits>&
|
| 124 |
+
operator<<(basic_ostream<charT, traits>& os,
|
| 125 |
+
const duration<Rep, Period>& d);
|
| 126 |
+
template<class charT, class traits, class Rep, class Period, class Alloc = allocator<charT>>
|
| 127 |
+
basic_istream<charT, traits>&
|
| 128 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 129 |
+
duration<Rep, Period>& d,
|
| 130 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 131 |
+
minutes* offset = nullptr);
|
| 132 |
+
|
| 133 |
// convenience typedefs
|
| 134 |
using nanoseconds = duration<signed integer type of at least 64 bits, nano>;
|
| 135 |
using microseconds = duration<signed integer type of at least 55 bits, micro>;
|
| 136 |
using milliseconds = duration<signed integer type of at least 45 bits, milli>;
|
| 137 |
using seconds = duration<signed integer type of at least 35 bits>;
|
| 138 |
using minutes = duration<signed integer type of at least 29 bits, ratio< 60>>;
|
| 139 |
using hours = duration<signed integer type of at least 23 bits, ratio<3600>>;
|
| 140 |
+
using days = duration<signed integer type of at least 25 bits,
|
| 141 |
+
ratio_multiply<ratio<24>, hours::period>>;
|
| 142 |
+
using weeks = duration<signed integer type of at least 22 bits,
|
| 143 |
+
ratio_multiply<ratio<7>, days::period>>;
|
| 144 |
+
using years = duration<signed integer type of at least 17 bits,
|
| 145 |
+
ratio_multiply<ratio<146097, 400>, days::period>>;
|
| 146 |
+
using months = duration<signed integer type of at least 20 bits,
|
| 147 |
+
ratio_divide<years::period, ratio<12>>>;
|
| 148 |
|
| 149 |
// [time.point.nonmember], time_point arithmetic
|
| 150 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 151 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 152 |
+
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 153 |
template<class Rep1, class Period1, class Clock, class Duration2>
|
| 154 |
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 155 |
+
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
|
|
|
| 156 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 157 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 158 |
+
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 159 |
template<class Clock, class Duration1, class Duration2>
|
| 160 |
constexpr common_type_t<Duration1, Duration2>
|
| 161 |
operator-(const time_point<Clock, Duration1>& lhs,
|
| 162 |
const time_point<Clock, Duration2>& rhs);
|
| 163 |
|
| 164 |
// [time.point.comparisons], time_point comparisons
|
| 165 |
template<class Clock, class Duration1, class Duration2>
|
| 166 |
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 167 |
const time_point<Clock, Duration2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 168 |
template<class Clock, class Duration1, class Duration2>
|
| 169 |
constexpr bool operator< (const time_point<Clock, Duration1>& lhs,
|
| 170 |
const time_point<Clock, Duration2>& rhs);
|
|
|
|
|
|
|
|
|
|
| 171 |
template<class Clock, class Duration1, class Duration2>
|
| 172 |
constexpr bool operator> (const time_point<Clock, Duration1>& lhs,
|
| 173 |
const time_point<Clock, Duration2>& rhs);
|
| 174 |
+
template<class Clock, class Duration1, class Duration2>
|
| 175 |
+
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 176 |
+
const time_point<Clock, Duration2>& rhs);
|
| 177 |
template<class Clock, class Duration1, class Duration2>
|
| 178 |
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 179 |
const time_point<Clock, Duration2>& rhs);
|
| 180 |
+
template<class Clock, class Duration1, three_way_comparable_with<Duration1> Duration2>
|
| 181 |
+
constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
|
| 182 |
+
const time_point<Clock, Duration2>& rhs);
|
| 183 |
|
| 184 |
+
// [time.point.cast], conversions
|
| 185 |
template<class ToDuration, class Clock, class Duration>
|
| 186 |
constexpr time_point<Clock, ToDuration>
|
| 187 |
time_point_cast(const time_point<Clock, Duration>& t);
|
| 188 |
template<class ToDuration, class Clock, class Duration>
|
| 189 |
+
constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp);
|
|
|
|
| 190 |
template<class ToDuration, class Clock, class Duration>
|
| 191 |
+
constexpr time_point<Clock, ToDuration> ceil(const time_point<Clock, Duration>& tp);
|
|
|
|
| 192 |
template<class ToDuration, class Clock, class Duration>
|
| 193 |
+
constexpr time_point<Clock, ToDuration> round(const time_point<Clock, Duration>& tp);
|
|
|
|
| 194 |
|
| 195 |
// [time.duration.alg], specialized algorithms
|
| 196 |
template<class Rep, class Period>
|
| 197 |
constexpr duration<Rep, Period> abs(duration<Rep, Period> d);
|
| 198 |
|
| 199 |
+
// [time.clock.system], class system_clock
|
| 200 |
class system_clock;
|
| 201 |
+
|
| 202 |
+
template<class Duration>
|
| 203 |
+
using sys_time = time_point<system_clock, Duration>;
|
| 204 |
+
using sys_seconds = sys_time<seconds>;
|
| 205 |
+
using sys_days = sys_time<days>;
|
| 206 |
+
|
| 207 |
+
template<class charT, class traits, class Duration>
|
| 208 |
+
basic_ostream<charT, traits>&
|
| 209 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
|
| 210 |
+
|
| 211 |
+
template<class charT, class traits>
|
| 212 |
+
basic_ostream<charT, traits>&
|
| 213 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
|
| 214 |
+
|
| 215 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 216 |
+
basic_istream<charT, traits>&
|
| 217 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 218 |
+
sys_time<Duration>& tp,
|
| 219 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 220 |
+
minutes* offset = nullptr);
|
| 221 |
+
|
| 222 |
+
// [time.clock.utc], class utc_clock
|
| 223 |
+
class utc_clock;
|
| 224 |
+
|
| 225 |
+
template<class Duration>
|
| 226 |
+
using utc_time = time_point<utc_clock, Duration>;
|
| 227 |
+
using utc_seconds = utc_time<seconds>;
|
| 228 |
+
|
| 229 |
+
template<class charT, class traits, class Duration>
|
| 230 |
+
basic_ostream<charT, traits>&
|
| 231 |
+
operator<<(basic_ostream<charT, traits>& os, const utc_time<Duration>& t);
|
| 232 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 233 |
+
basic_istream<charT, traits>&
|
| 234 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 235 |
+
utc_time<Duration>& tp,
|
| 236 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 237 |
+
minutes* offset = nullptr);
|
| 238 |
+
|
| 239 |
+
struct leap_second_info;
|
| 240 |
+
|
| 241 |
+
template<class Duration>
|
| 242 |
+
leap_second_info get_leap_second_info(const utc_time<Duration>& ut);
|
| 243 |
+
|
| 244 |
+
// [time.clock.tai], class tai_clock
|
| 245 |
+
class tai_clock;
|
| 246 |
+
|
| 247 |
+
template<class Duration>
|
| 248 |
+
using tai_time = time_point<tai_clock, Duration>;
|
| 249 |
+
using tai_seconds = tai_time<seconds>;
|
| 250 |
+
|
| 251 |
+
template<class charT, class traits, class Duration>
|
| 252 |
+
basic_ostream<charT, traits>&
|
| 253 |
+
operator<<(basic_ostream<charT, traits>& os, const tai_time<Duration>& t);
|
| 254 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 255 |
+
basic_istream<charT, traits>&
|
| 256 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 257 |
+
tai_time<Duration>& tp,
|
| 258 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 259 |
+
minutes* offset = nullptr);
|
| 260 |
+
|
| 261 |
+
// [time.clock.gps], class gps_clock
|
| 262 |
+
class gps_clock;
|
| 263 |
+
|
| 264 |
+
template<class Duration>
|
| 265 |
+
using gps_time = time_point<gps_clock, Duration>;
|
| 266 |
+
using gps_seconds = gps_time<seconds>;
|
| 267 |
+
|
| 268 |
+
template<class charT, class traits, class Duration>
|
| 269 |
+
basic_ostream<charT, traits>&
|
| 270 |
+
operator<<(basic_ostream<charT, traits>& os, const gps_time<Duration>& t);
|
| 271 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 272 |
+
basic_istream<charT, traits>&
|
| 273 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 274 |
+
gps_time<Duration>& tp,
|
| 275 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 276 |
+
minutes* offset = nullptr);
|
| 277 |
+
|
| 278 |
+
// [time.clock.file], type file_clock
|
| 279 |
+
using file_clock = see below;
|
| 280 |
+
|
| 281 |
+
template<class Duration>
|
| 282 |
+
using file_time = time_point<file_clock, Duration>;
|
| 283 |
+
|
| 284 |
+
template<class charT, class traits, class Duration>
|
| 285 |
+
basic_ostream<charT, traits>&
|
| 286 |
+
operator<<(basic_ostream<charT, traits>& os, const file_time<Duration>& tp);
|
| 287 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 288 |
+
basic_istream<charT, traits>&
|
| 289 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 290 |
+
file_time<Duration>& tp,
|
| 291 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 292 |
+
minutes* offset = nullptr);
|
| 293 |
+
|
| 294 |
+
// [time.clock.steady], class steady_clock
|
| 295 |
class steady_clock;
|
| 296 |
+
|
| 297 |
+
// [time.clock.hires], class high_resolution_clock
|
| 298 |
class high_resolution_clock;
|
| 299 |
+
|
| 300 |
+
// [time.clock.local], local time
|
| 301 |
+
struct local_t {};
|
| 302 |
+
template<class Duration>
|
| 303 |
+
using local_time = time_point<local_t, Duration>;
|
| 304 |
+
using local_seconds = local_time<seconds>;
|
| 305 |
+
using local_days = local_time<days>;
|
| 306 |
+
|
| 307 |
+
template<class charT, class traits, class Duration>
|
| 308 |
+
basic_ostream<charT, traits>&
|
| 309 |
+
operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);
|
| 310 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 311 |
+
basic_istream<charT, traits>&
|
| 312 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 313 |
+
local_time<Duration>& tp,
|
| 314 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 315 |
+
minutes* offset = nullptr);
|
| 316 |
+
|
| 317 |
+
// [time.clock.cast], time_point conversions
|
| 318 |
+
template<class DestClock, class SourceClock>
|
| 319 |
+
struct clock_time_conversion;
|
| 320 |
+
|
| 321 |
+
template<class DestClock, class SourceClock, class Duration>
|
| 322 |
+
auto clock_cast(const time_point<SourceClock, Duration>& t);
|
| 323 |
+
|
| 324 |
+
// [time.cal.last], class last_spec
|
| 325 |
+
struct last_spec;
|
| 326 |
+
|
| 327 |
+
// [time.cal.day], class day
|
| 328 |
+
class day;
|
| 329 |
+
|
| 330 |
+
constexpr bool operator==(const day& x, const day& y) noexcept;
|
| 331 |
+
constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
|
| 332 |
+
|
| 333 |
+
constexpr day operator+(const day& x, const days& y) noexcept;
|
| 334 |
+
constexpr day operator+(const days& x, const day& y) noexcept;
|
| 335 |
+
constexpr day operator-(const day& x, const days& y) noexcept;
|
| 336 |
+
constexpr days operator-(const day& x, const day& y) noexcept;
|
| 337 |
+
|
| 338 |
+
template<class charT, class traits>
|
| 339 |
+
basic_ostream<charT, traits>&
|
| 340 |
+
operator<<(basic_ostream<charT, traits>& os, const day& d);
|
| 341 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 342 |
+
basic_istream<charT, traits>&
|
| 343 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 344 |
+
day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 345 |
+
minutes* offset = nullptr);
|
| 346 |
+
|
| 347 |
+
// [time.cal.month], class month
|
| 348 |
+
class month;
|
| 349 |
+
|
| 350 |
+
constexpr bool operator==(const month& x, const month& y) noexcept;
|
| 351 |
+
constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
|
| 352 |
+
|
| 353 |
+
constexpr month operator+(const month& x, const months& y) noexcept;
|
| 354 |
+
constexpr month operator+(const months& x, const month& y) noexcept;
|
| 355 |
+
constexpr month operator-(const month& x, const months& y) noexcept;
|
| 356 |
+
constexpr months operator-(const month& x, const month& y) noexcept;
|
| 357 |
+
|
| 358 |
+
template<class charT, class traits>
|
| 359 |
+
basic_ostream<charT, traits>&
|
| 360 |
+
operator<<(basic_ostream<charT, traits>& os, const month& m);
|
| 361 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 362 |
+
basic_istream<charT, traits>&
|
| 363 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 364 |
+
month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 365 |
+
minutes* offset = nullptr);
|
| 366 |
+
|
| 367 |
+
// [time.cal.year], class year
|
| 368 |
+
class year;
|
| 369 |
+
|
| 370 |
+
constexpr bool operator==(const year& x, const year& y) noexcept;
|
| 371 |
+
constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
|
| 372 |
+
|
| 373 |
+
constexpr year operator+(const year& x, const years& y) noexcept;
|
| 374 |
+
constexpr year operator+(const years& x, const year& y) noexcept;
|
| 375 |
+
constexpr year operator-(const year& x, const years& y) noexcept;
|
| 376 |
+
constexpr years operator-(const year& x, const year& y) noexcept;
|
| 377 |
+
|
| 378 |
+
template<class charT, class traits>
|
| 379 |
+
basic_ostream<charT, traits>&
|
| 380 |
+
operator<<(basic_ostream<charT, traits>& os, const year& y);
|
| 381 |
+
|
| 382 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 383 |
+
basic_istream<charT, traits>&
|
| 384 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 385 |
+
year& y, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 386 |
+
minutes* offset = nullptr);
|
| 387 |
+
|
| 388 |
+
// [time.cal.wd], class weekday
|
| 389 |
+
class weekday;
|
| 390 |
+
|
| 391 |
+
constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
|
| 392 |
+
|
| 393 |
+
constexpr weekday operator+(const weekday& x, const days& y) noexcept;
|
| 394 |
+
constexpr weekday operator+(const days& x, const weekday& y) noexcept;
|
| 395 |
+
constexpr weekday operator-(const weekday& x, const days& y) noexcept;
|
| 396 |
+
constexpr days operator-(const weekday& x, const weekday& y) noexcept;
|
| 397 |
+
|
| 398 |
+
template<class charT, class traits>
|
| 399 |
+
basic_ostream<charT, traits>&
|
| 400 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
|
| 401 |
+
|
| 402 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 403 |
+
basic_istream<charT, traits>&
|
| 404 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 405 |
+
weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 406 |
+
minutes* offset = nullptr);
|
| 407 |
+
|
| 408 |
+
// [time.cal.wdidx], class weekday_indexed
|
| 409 |
+
class weekday_indexed;
|
| 410 |
+
|
| 411 |
+
constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
| 412 |
+
|
| 413 |
+
template<class charT, class traits>
|
| 414 |
+
basic_ostream<charT, traits>&
|
| 415 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
|
| 416 |
+
|
| 417 |
+
// [time.cal.wdlast], class weekday_last
|
| 418 |
+
class weekday_last;
|
| 419 |
+
|
| 420 |
+
constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
|
| 421 |
+
|
| 422 |
+
template<class charT, class traits>
|
| 423 |
+
basic_ostream<charT, traits>&
|
| 424 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
|
| 425 |
+
|
| 426 |
+
// [time.cal.md], class month_day
|
| 427 |
+
class month_day;
|
| 428 |
+
|
| 429 |
+
constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
|
| 430 |
+
constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
|
| 431 |
+
|
| 432 |
+
template<class charT, class traits>
|
| 433 |
+
basic_ostream<charT, traits>&
|
| 434 |
+
operator<<(basic_ostream<charT, traits>& os, const month_day& md);
|
| 435 |
+
|
| 436 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 437 |
+
basic_istream<charT, traits>&
|
| 438 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 439 |
+
month_day& md, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 440 |
+
minutes* offset = nullptr);
|
| 441 |
+
|
| 442 |
+
// [time.cal.mdlast], class month_day_last
|
| 443 |
+
class month_day_last;
|
| 444 |
+
|
| 445 |
+
constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
|
| 446 |
+
constexpr strong_ordering operator<=>(const month_day_last& x,
|
| 447 |
+
const month_day_last& y) noexcept;
|
| 448 |
+
|
| 449 |
+
template<class charT, class traits>
|
| 450 |
+
basic_ostream<charT, traits>&
|
| 451 |
+
operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
|
| 452 |
+
|
| 453 |
+
// [time.cal.mwd], class month_weekday
|
| 454 |
+
class month_weekday;
|
| 455 |
+
|
| 456 |
+
constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
|
| 457 |
+
|
| 458 |
+
template<class charT, class traits>
|
| 459 |
+
basic_ostream<charT, traits>&
|
| 460 |
+
operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
|
| 461 |
+
|
| 462 |
+
// [time.cal.mwdlast], class month_weekday_last
|
| 463 |
+
class month_weekday_last;
|
| 464 |
+
|
| 465 |
+
constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
|
| 466 |
+
|
| 467 |
+
template<class charT, class traits>
|
| 468 |
+
basic_ostream<charT, traits>&
|
| 469 |
+
operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
|
| 470 |
+
|
| 471 |
+
// [time.cal.ym], class year_month
|
| 472 |
+
class year_month;
|
| 473 |
+
|
| 474 |
+
constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
|
| 475 |
+
constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
|
| 476 |
+
|
| 477 |
+
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
|
| 478 |
+
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
|
| 479 |
+
constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
|
| 480 |
+
constexpr months operator-(const year_month& x, const year_month& y) noexcept;
|
| 481 |
+
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
|
| 482 |
+
constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
|
| 483 |
+
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
|
| 484 |
+
|
| 485 |
+
template<class charT, class traits>
|
| 486 |
+
basic_ostream<charT, traits>&
|
| 487 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
|
| 488 |
+
|
| 489 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 490 |
+
basic_istream<charT, traits>&
|
| 491 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 492 |
+
year_month& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 493 |
+
minutes* offset = nullptr);
|
| 494 |
+
|
| 495 |
+
// [time.cal.ymd], class year_month_day
|
| 496 |
+
class year_month_day;
|
| 497 |
+
|
| 498 |
+
constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
|
| 499 |
+
constexpr strong_ordering operator<=>(const year_month_day& x,
|
| 500 |
+
const year_month_day& y) noexcept;
|
| 501 |
+
|
| 502 |
+
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
|
| 503 |
+
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
|
| 504 |
+
constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
|
| 505 |
+
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
|
| 506 |
+
constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
|
| 507 |
+
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
|
| 508 |
+
|
| 509 |
+
template<class charT, class traits>
|
| 510 |
+
basic_ostream<charT, traits>&
|
| 511 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
|
| 512 |
+
|
| 513 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 514 |
+
basic_istream<charT, traits>&
|
| 515 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 516 |
+
year_month_day& ymd,
|
| 517 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 518 |
+
minutes* offset = nullptr);
|
| 519 |
+
|
| 520 |
+
// [time.cal.ymdlast], class year_month_day_last
|
| 521 |
+
class year_month_day_last;
|
| 522 |
+
|
| 523 |
+
constexpr bool operator==(const year_month_day_last& x,
|
| 524 |
+
const year_month_day_last& y) noexcept;
|
| 525 |
+
constexpr strong_ordering operator<=>(const year_month_day_last& x,
|
| 526 |
+
const year_month_day_last& y) noexcept;
|
| 527 |
+
|
| 528 |
+
constexpr year_month_day_last
|
| 529 |
+
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
| 530 |
+
constexpr year_month_day_last
|
| 531 |
+
operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
|
| 532 |
+
constexpr year_month_day_last
|
| 533 |
+
operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
|
| 534 |
+
constexpr year_month_day_last
|
| 535 |
+
operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
|
| 536 |
+
constexpr year_month_day_last
|
| 537 |
+
operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
|
| 538 |
+
constexpr year_month_day_last
|
| 539 |
+
operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
|
| 540 |
+
|
| 541 |
+
template<class charT, class traits>
|
| 542 |
+
basic_ostream<charT, traits>&
|
| 543 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
|
| 544 |
+
|
| 545 |
+
// [time.cal.ymwd], class year_month_weekday
|
| 546 |
+
class year_month_weekday;
|
| 547 |
+
|
| 548 |
+
constexpr bool operator==(const year_month_weekday& x,
|
| 549 |
+
const year_month_weekday& y) noexcept;
|
| 550 |
+
|
| 551 |
+
constexpr year_month_weekday
|
| 552 |
+
operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
|
| 553 |
+
constexpr year_month_weekday
|
| 554 |
+
operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
|
| 555 |
+
constexpr year_month_weekday
|
| 556 |
+
operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 557 |
+
constexpr year_month_weekday
|
| 558 |
+
operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
|
| 559 |
+
constexpr year_month_weekday
|
| 560 |
+
operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
|
| 561 |
+
constexpr year_month_weekday
|
| 562 |
+
operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 563 |
+
|
| 564 |
+
template<class charT, class traits>
|
| 565 |
+
basic_ostream<charT, traits>&
|
| 566 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwdi);
|
| 567 |
+
|
| 568 |
+
// [time.cal.ymwdlast], class year_month_weekday_last
|
| 569 |
+
class year_month_weekday_last;
|
| 570 |
+
|
| 571 |
+
constexpr bool operator==(const year_month_weekday_last& x,
|
| 572 |
+
const year_month_weekday_last& y) noexcept;
|
| 573 |
+
|
| 574 |
+
constexpr year_month_weekday_last
|
| 575 |
+
operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
| 576 |
+
constexpr year_month_weekday_last
|
| 577 |
+
operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
|
| 578 |
+
constexpr year_month_weekday_last
|
| 579 |
+
operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
| 580 |
+
constexpr year_month_weekday_last
|
| 581 |
+
operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
|
| 582 |
+
constexpr year_month_weekday_last
|
| 583 |
+
operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
| 584 |
+
constexpr year_month_weekday_last
|
| 585 |
+
operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
| 586 |
+
|
| 587 |
+
template<class charT, class traits>
|
| 588 |
+
basic_ostream<charT, traits>&
|
| 589 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
|
| 590 |
+
|
| 591 |
+
// [time.cal.operators], civil calendar conventional syntax operators
|
| 592 |
+
constexpr year_month
|
| 593 |
+
operator/(const year& y, const month& m) noexcept;
|
| 594 |
+
constexpr year_month
|
| 595 |
+
operator/(const year& y, int m) noexcept;
|
| 596 |
+
constexpr month_day
|
| 597 |
+
operator/(const month& m, const day& d) noexcept;
|
| 598 |
+
constexpr month_day
|
| 599 |
+
operator/(const month& m, int d) noexcept;
|
| 600 |
+
constexpr month_day
|
| 601 |
+
operator/(int m, const day& d) noexcept;
|
| 602 |
+
constexpr month_day
|
| 603 |
+
operator/(const day& d, const month& m) noexcept;
|
| 604 |
+
constexpr month_day
|
| 605 |
+
operator/(const day& d, int m) noexcept;
|
| 606 |
+
constexpr month_day_last
|
| 607 |
+
operator/(const month& m, last_spec) noexcept;
|
| 608 |
+
constexpr month_day_last
|
| 609 |
+
operator/(int m, last_spec) noexcept;
|
| 610 |
+
constexpr month_day_last
|
| 611 |
+
operator/(last_spec, const month& m) noexcept;
|
| 612 |
+
constexpr month_day_last
|
| 613 |
+
operator/(last_spec, int m) noexcept;
|
| 614 |
+
constexpr month_weekday
|
| 615 |
+
operator/(const month& m, const weekday_indexed& wdi) noexcept;
|
| 616 |
+
constexpr month_weekday
|
| 617 |
+
operator/(int m, const weekday_indexed& wdi) noexcept;
|
| 618 |
+
constexpr month_weekday
|
| 619 |
+
operator/(const weekday_indexed& wdi, const month& m) noexcept;
|
| 620 |
+
constexpr month_weekday
|
| 621 |
+
operator/(const weekday_indexed& wdi, int m) noexcept;
|
| 622 |
+
constexpr month_weekday_last
|
| 623 |
+
operator/(const month& m, const weekday_last& wdl) noexcept;
|
| 624 |
+
constexpr month_weekday_last
|
| 625 |
+
operator/(int m, const weekday_last& wdl) noexcept;
|
| 626 |
+
constexpr month_weekday_last
|
| 627 |
+
operator/(const weekday_last& wdl, const month& m) noexcept;
|
| 628 |
+
constexpr month_weekday_last
|
| 629 |
+
operator/(const weekday_last& wdl, int m) noexcept;
|
| 630 |
+
constexpr year_month_day
|
| 631 |
+
operator/(const year_month& ym, const day& d) noexcept;
|
| 632 |
+
constexpr year_month_day
|
| 633 |
+
operator/(const year_month& ym, int d) noexcept;
|
| 634 |
+
constexpr year_month_day
|
| 635 |
+
operator/(const year& y, const month_day& md) noexcept;
|
| 636 |
+
constexpr year_month_day
|
| 637 |
+
operator/(int y, const month_day& md) noexcept;
|
| 638 |
+
constexpr year_month_day
|
| 639 |
+
operator/(const month_day& md, const year& y) noexcept;
|
| 640 |
+
constexpr year_month_day
|
| 641 |
+
operator/(const month_day& md, int y) noexcept;
|
| 642 |
+
constexpr year_month_day_last
|
| 643 |
+
operator/(const year_month& ym, last_spec) noexcept;
|
| 644 |
+
constexpr year_month_day_last
|
| 645 |
+
operator/(const year& y, const month_day_last& mdl) noexcept;
|
| 646 |
+
constexpr year_month_day_last
|
| 647 |
+
operator/(int y, const month_day_last& mdl) noexcept;
|
| 648 |
+
constexpr year_month_day_last
|
| 649 |
+
operator/(const month_day_last& mdl, const year& y) noexcept;
|
| 650 |
+
constexpr year_month_day_last
|
| 651 |
+
operator/(const month_day_last& mdl, int y) noexcept;
|
| 652 |
+
constexpr year_month_weekday
|
| 653 |
+
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
|
| 654 |
+
constexpr year_month_weekday
|
| 655 |
+
operator/(const year& y, const month_weekday& mwd) noexcept;
|
| 656 |
+
constexpr year_month_weekday
|
| 657 |
+
operator/(int y, const month_weekday& mwd) noexcept;
|
| 658 |
+
constexpr year_month_weekday
|
| 659 |
+
operator/(const month_weekday& mwd, const year& y) noexcept;
|
| 660 |
+
constexpr year_month_weekday
|
| 661 |
+
operator/(const month_weekday& mwd, int y) noexcept;
|
| 662 |
+
constexpr year_month_weekday_last
|
| 663 |
+
operator/(const year_month& ym, const weekday_last& wdl) noexcept;
|
| 664 |
+
constexpr year_month_weekday_last
|
| 665 |
+
operator/(const year& y, const month_weekday_last& mwdl) noexcept;
|
| 666 |
+
constexpr year_month_weekday_last
|
| 667 |
+
operator/(int y, const month_weekday_last& mwdl) noexcept;
|
| 668 |
+
constexpr year_month_weekday_last
|
| 669 |
+
operator/(const month_weekday_last& mwdl, const year& y) noexcept;
|
| 670 |
+
constexpr year_month_weekday_last
|
| 671 |
+
operator/(const month_weekday_last& mwdl, int y) noexcept;
|
| 672 |
+
|
| 673 |
+
// [time.hms], class template hh_mm_ss
|
| 674 |
+
template<class Duration> class hh_mm_ss;
|
| 675 |
+
|
| 676 |
+
template<class charT, class traits, class Duration>
|
| 677 |
+
basic_ostream<charT, traits>&
|
| 678 |
+
operator<<(basic_ostream<charT, traits>& os, const hh_mm_ss<Duration>& hms);
|
| 679 |
+
|
| 680 |
+
// [time.12], 12/24 hour functions
|
| 681 |
+
constexpr bool is_am(const hours& h) noexcept;
|
| 682 |
+
constexpr bool is_pm(const hours& h) noexcept;
|
| 683 |
+
constexpr hours make12(const hours& h) noexcept;
|
| 684 |
+
constexpr hours make24(const hours& h, bool is_pm) noexcept;
|
| 685 |
+
|
| 686 |
+
// [time.zone.db], time zone database
|
| 687 |
+
struct tzdb;
|
| 688 |
+
class tzdb_list;
|
| 689 |
+
|
| 690 |
+
// [time.zone.db.access], time zone database access
|
| 691 |
+
const tzdb& get_tzdb();
|
| 692 |
+
tzdb_list& get_tzdb_list();
|
| 693 |
+
const time_zone* locate_zone(string_view tz_name);
|
| 694 |
+
const time_zone* current_zone();
|
| 695 |
+
|
| 696 |
+
// [time.zone.db.remote], remote time zone database support
|
| 697 |
+
const tzdb& reload_tzdb();
|
| 698 |
+
string remote_version();
|
| 699 |
+
|
| 700 |
+
// [time.zone.exception], exception classes
|
| 701 |
+
class nonexistent_local_time;
|
| 702 |
+
class ambiguous_local_time;
|
| 703 |
+
|
| 704 |
+
// [time.zone.info], information classes
|
| 705 |
+
struct sys_info;
|
| 706 |
+
template<class charT, class traits>
|
| 707 |
+
basic_ostream<charT, traits>&
|
| 708 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_info& si);
|
| 709 |
+
|
| 710 |
+
struct local_info;
|
| 711 |
+
template<class charT, class traits>
|
| 712 |
+
basic_ostream<charT, traits>&
|
| 713 |
+
operator<<(basic_ostream<charT, traits>& os, const local_info& li);
|
| 714 |
+
|
| 715 |
+
// [time.zone.timezone], class time_zone
|
| 716 |
+
enum class choose {earliest, latest};
|
| 717 |
+
class time_zone;
|
| 718 |
+
|
| 719 |
+
bool operator==(const time_zone& x, const time_zone& y) noexcept;
|
| 720 |
+
strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;
|
| 721 |
+
|
| 722 |
+
// [time.zone.zonedtraits], class template zoned_traits
|
| 723 |
+
template<class T> struct zoned_traits;
|
| 724 |
+
|
| 725 |
+
// [time.zone.zonedtime], class template zoned_time
|
| 726 |
+
template<class Duration, class TimeZonePtr = const time_zone*> class zoned_time;
|
| 727 |
+
|
| 728 |
+
using zoned_seconds = zoned_time<seconds>;
|
| 729 |
+
|
| 730 |
+
template<class Duration1, class Duration2, class TimeZonePtr>
|
| 731 |
+
bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
|
| 732 |
+
const zoned_time<Duration2, TimeZonePtr>& y);
|
| 733 |
+
|
| 734 |
+
template<class charT, class traits, class Duration, class TimeZonePtr>
|
| 735 |
+
basic_ostream<charT, traits>&
|
| 736 |
+
operator<<(basic_ostream<charT, traits>& os,
|
| 737 |
+
const zoned_time<Duration, TimeZonePtr>& t);
|
| 738 |
+
|
| 739 |
+
// [time.zone.leap], leap second support
|
| 740 |
+
class leap_second;
|
| 741 |
+
|
| 742 |
+
bool operator==(const leap_second& x, const leap_second& y);
|
| 743 |
+
strong_ordering operator<=>(const leap_second& x, const leap_second& y);
|
| 744 |
+
|
| 745 |
+
template<class Duration>
|
| 746 |
+
bool operator==(const leap_second& x, const sys_time<Duration>& y);
|
| 747 |
+
template<class Duration>
|
| 748 |
+
bool operator< (const leap_second& x, const sys_time<Duration>& y);
|
| 749 |
+
template<class Duration>
|
| 750 |
+
bool operator< (const sys_time<Duration>& x, const leap_second& y);
|
| 751 |
+
template<class Duration>
|
| 752 |
+
bool operator> (const leap_second& x, const sys_time<Duration>& y);
|
| 753 |
+
template<class Duration>
|
| 754 |
+
bool operator> (const sys_time<Duration>& x, const leap_second& y);
|
| 755 |
+
template<class Duration>
|
| 756 |
+
bool operator<=(const leap_second& x, const sys_time<Duration>& y);
|
| 757 |
+
template<class Duration>
|
| 758 |
+
bool operator<=(const sys_time<Duration>& x, const leap_second& y);
|
| 759 |
+
template<class Duration>
|
| 760 |
+
bool operator>=(const leap_second& x, const sys_time<Duration>& y);
|
| 761 |
+
template<class Duration>
|
| 762 |
+
bool operator>=(const sys_time<Duration>& x, const leap_second& y);
|
| 763 |
+
template<class Duration>
|
| 764 |
+
requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
|
| 765 |
+
constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y);
|
| 766 |
+
|
| 767 |
+
// [time.zone.link], class time_zone_link
|
| 768 |
+
class time_zone_link;
|
| 769 |
+
|
| 770 |
+
bool operator==(const time_zone_link& x, const time_zone_link& y);
|
| 771 |
+
strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);
|
| 772 |
+
|
| 773 |
+
// [time.format], formatting
|
| 774 |
+
template<class Duration> struct local-time-format-t; // exposition only
|
| 775 |
+
template<class Duration>
|
| 776 |
+
local-time-format-t<Duration>
|
| 777 |
+
local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
|
| 778 |
+
const seconds* offset_sec = nullptr);
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
template<class Rep, class Period, class charT>
|
| 782 |
+
struct formatter<chrono::duration<Rep, Period>, charT>;
|
| 783 |
+
template<class Duration, class charT>
|
| 784 |
+
struct formatter<chrono::sys_time<Duration>, charT>;
|
| 785 |
+
template<class Duration, class charT>
|
| 786 |
+
struct formatter<chrono::utc_time<Duration>, charT>;
|
| 787 |
+
template<class Duration, class charT>
|
| 788 |
+
struct formatter<chrono::tai_time<Duration>, charT>;
|
| 789 |
+
template<class Duration, class charT>
|
| 790 |
+
struct formatter<chrono::gps_time<Duration>, charT>;
|
| 791 |
+
template<class Duration, class charT>
|
| 792 |
+
struct formatter<chrono::file_time<Duration>, charT>;
|
| 793 |
+
template<class Duration, class charT>
|
| 794 |
+
struct formatter<chrono::local_time<Duration>, charT>;
|
| 795 |
+
template<class Duration, class charT>
|
| 796 |
+
struct formatter<chrono::local-time-format-t<Duration>, charT>;
|
| 797 |
+
template<class charT> struct formatter<chrono::day, charT>;
|
| 798 |
+
template<class charT> struct formatter<chrono::month, charT>;
|
| 799 |
+
template<class charT> struct formatter<chrono::year, charT>;
|
| 800 |
+
template<class charT> struct formatter<chrono::weekday, charT>;
|
| 801 |
+
template<class charT> struct formatter<chrono::weekday_indexed, charT>;
|
| 802 |
+
template<class charT> struct formatter<chrono::weekday_last, charT>;
|
| 803 |
+
template<class charT> struct formatter<chrono::month_day, charT>;
|
| 804 |
+
template<class charT> struct formatter<chrono::month_day_last, charT>;
|
| 805 |
+
template<class charT> struct formatter<chrono::month_weekday, charT>;
|
| 806 |
+
template<class charT> struct formatter<chrono::month_weekday_last, charT>;
|
| 807 |
+
template<class charT> struct formatter<chrono::year_month, charT>;
|
| 808 |
+
template<class charT> struct formatter<chrono::year_month_day, charT>;
|
| 809 |
+
template<class charT> struct formatter<chrono::year_month_day_last, charT>;
|
| 810 |
+
template<class charT> struct formatter<chrono::year_month_weekday, charT>;
|
| 811 |
+
template<class charT> struct formatter<chrono::year_month_weekday_last, charT>;
|
| 812 |
+
template<class Rep, class Period, class charT>
|
| 813 |
+
struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>;
|
| 814 |
+
template<class charT> struct formatter<chrono::sys_info, charT>;
|
| 815 |
+
template<class charT> struct formatter<chrono::local_info, charT>;
|
| 816 |
+
template<class Duration, class TimeZonePtr, class charT>
|
| 817 |
+
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>;
|
| 818 |
+
|
| 819 |
+
namespace chrono {
|
| 820 |
+
// [time.parse], parsing
|
| 821 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 822 |
+
unspecified
|
| 823 |
+
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp);
|
| 824 |
+
|
| 825 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 826 |
+
unspecified
|
| 827 |
+
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
| 828 |
+
basic_string<charT, traits, Alloc>& abbrev);
|
| 829 |
+
|
| 830 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 831 |
+
unspecified
|
| 832 |
+
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
| 833 |
+
minutes& offset);
|
| 834 |
+
|
| 835 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 836 |
+
unspecified
|
| 837 |
+
parse(const basic_string<charT, traits, Alloc>& format, Parsable& tp,
|
| 838 |
+
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 839 |
+
|
| 840 |
+
// calendrical constants
|
| 841 |
+
inline constexpr last_spec last{};
|
| 842 |
+
|
| 843 |
+
inline constexpr weekday Sunday{0};
|
| 844 |
+
inline constexpr weekday Monday{1};
|
| 845 |
+
inline constexpr weekday Tuesday{2};
|
| 846 |
+
inline constexpr weekday Wednesday{3};
|
| 847 |
+
inline constexpr weekday Thursday{4};
|
| 848 |
+
inline constexpr weekday Friday{5};
|
| 849 |
+
inline constexpr weekday Saturday{6};
|
| 850 |
+
|
| 851 |
+
inline constexpr month January{1};
|
| 852 |
+
inline constexpr month February{2};
|
| 853 |
+
inline constexpr month March{3};
|
| 854 |
+
inline constexpr month April{4};
|
| 855 |
+
inline constexpr month May{5};
|
| 856 |
+
inline constexpr month June{6};
|
| 857 |
+
inline constexpr month July{7};
|
| 858 |
+
inline constexpr month August{8};
|
| 859 |
+
inline constexpr month September{9};
|
| 860 |
+
inline constexpr month October{10};
|
| 861 |
+
inline constexpr month November{11};
|
| 862 |
+
inline constexpr month December{12};
|
| 863 |
}
|
| 864 |
|
| 865 |
inline namespace literals {
|
| 866 |
inline namespace chrono_literals {
|
| 867 |
// [time.duration.literals], suffixes for duration literals
|
| 868 |
constexpr chrono::hours operator""h(unsigned long long);
|
| 869 |
constexpr chrono::duration<unspecified, ratio<3600, 1>> operator""h(long double);
|
| 870 |
+
|
| 871 |
constexpr chrono::minutes operator""min(unsigned long long);
|
| 872 |
constexpr chrono::duration<unspecified, ratio<60, 1>> operator""min(long double);
|
| 873 |
+
|
| 874 |
constexpr chrono::seconds operator""s(unsigned long long);
|
| 875 |
constexpr chrono::duration<unspecified> operator""s(long double);
|
| 876 |
+
|
| 877 |
constexpr chrono::milliseconds operator""ms(unsigned long long);
|
| 878 |
constexpr chrono::duration<unspecified, milli> operator""ms(long double);
|
| 879 |
+
|
| 880 |
constexpr chrono::microseconds operator""us(unsigned long long);
|
| 881 |
constexpr chrono::duration<unspecified, micro> operator""us(long double);
|
| 882 |
+
|
| 883 |
constexpr chrono::nanoseconds operator""ns(unsigned long long);
|
| 884 |
constexpr chrono::duration<unspecified, nano> operator""ns(long double);
|
| 885 |
+
|
| 886 |
+
// [time.cal.day.nonmembers], non-member functions
|
| 887 |
+
constexpr chrono::day operator""d(unsigned long long d) noexcept;
|
| 888 |
+
|
| 889 |
+
// [time.cal.year.nonmembers], non-member functions
|
| 890 |
+
constexpr chrono::year operator""y(unsigned long long y) noexcept;
|
| 891 |
}
|
| 892 |
}
|
| 893 |
|
| 894 |
namespace chrono {
|
| 895 |
using namespace literals::chrono_literals;
|
| 896 |
}
|
| 897 |
}
|
| 898 |
```
|
| 899 |
|
| 900 |
+
## *Cpp17Clock* requirements <a id="time.clock.req">[[time.clock.req]]</a>
|
| 901 |
|
| 902 |
A clock is a bundle consisting of a `duration`, a `time_point`, and a
|
| 903 |
function `now()` to get the current `time_point`. The origin of the
|
| 904 |
clock’s `time_point` is referred to as the clock’s *epoch*. A clock
|
| 905 |
+
shall meet the requirements in [[time.clock]].
|
| 906 |
|
| 907 |
+
In [[time.clock]] `C1` and `C2` denote clock types. `t1` and `t2` are
|
| 908 |
+
values returned by `C1::now()` where the call returning `t1` happens
|
| 909 |
+
before [[intro.multithread]] the call returning `t2` and both of these
|
| 910 |
+
calls occur before `C1::time_point::max()`.
|
| 911 |
|
| 912 |
[*Note 1*: This means `C1` did not wrap around between `t1` and
|
| 913 |
`t2`. — *end note*]
|
| 914 |
|
| 915 |
[*Note 2*: The relative difference in durations between those reported
|
| 916 |
by a given clock and the SI definition is a measure of the quality of
|
| 917 |
implementation. — *end note*]
|
| 918 |
|
| 919 |
+
A type `TC` meets the *Cpp17TrivialClock* requirements if:
|
| 920 |
|
| 921 |
+
- `TC` meets the *Cpp17Clock* requirements [[time.clock.req]],
|
| 922 |
+
- the types `TC::rep`, `TC::duration`, and `TC::time_point` meet the
|
| 923 |
+
*Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
|
| 924 |
+
*Cpp17LessThanComparable* ([[cpp17.lessthancomparable]]) requirements
|
| 925 |
+
and the requirements of numeric types [[numeric.requirements]].
|
|
|
|
|
|
|
|
|
|
|
|
|
| 926 |
\[*Note 3*: This means, in particular, that operations on these types
|
| 927 |
will not throw exceptions. — *end note*]
|
| 928 |
- lvalues of the types `TC::rep`, `TC::duration`, and `TC::time_point`
|
| 929 |
+
are swappable [[swappable.requirements]],
|
| 930 |
- the function `TC::now()` does not throw exceptions, and
|
| 931 |
+
- the type `TC::time_point::clock` meets the *Cpp17TrivialClock*
|
| 932 |
requirements, recursively.
|
| 933 |
|
| 934 |
+
## Time-related traits <a id="time.traits">[[time.traits]]</a>
|
| 935 |
|
| 936 |
+
### `treat_as_floating_point` <a id="time.traits.is.fp">[[time.traits.is.fp]]</a>
|
| 937 |
|
| 938 |
``` cpp
|
| 939 |
+
template<class Rep> struct treat_as_floating_point : is_floating_point<Rep> { };
|
|
|
|
| 940 |
```
|
| 941 |
|
| 942 |
The `duration` template uses the `treat_as_floating_point` trait to help
|
| 943 |
determine if a `duration` object can be converted to another `duration`
|
| 944 |
with a different tick `period`. If `treat_as_floating_point_v<Rep>` is
|
|
|
|
| 951 |
one value by another with acceptable loss of precision. If
|
| 952 |
`treat_as_floating_point_v<Rep>` is `false`, `Rep` will be treated as if
|
| 953 |
it behaved like an integral type for the purpose of these
|
| 954 |
conversions. — *end note*]
|
| 955 |
|
| 956 |
+
### `duration_values` <a id="time.traits.duration.values">[[time.traits.duration.values]]</a>
|
| 957 |
|
| 958 |
``` cpp
|
| 959 |
template<class Rep>
|
| 960 |
struct duration_values {
|
| 961 |
public:
|
| 962 |
+
static constexpr Rep zero() noexcept;
|
| 963 |
+
static constexpr Rep min() noexcept;
|
| 964 |
+
static constexpr Rep max() noexcept;
|
| 965 |
};
|
| 966 |
```
|
| 967 |
|
| 968 |
The `duration` template uses the `duration_values` trait to construct
|
| 969 |
+
special values of the duration’s representation (`Rep`). This is done
|
| 970 |
because the representation might be a class type with behavior which
|
| 971 |
requires some other implementation to return these special values. In
|
| 972 |
that case, the author of that class type should specialize
|
| 973 |
`duration_values` to return the indicated values.
|
| 974 |
|
| 975 |
``` cpp
|
| 976 |
+
static constexpr Rep zero() noexcept;
|
| 977 |
```
|
| 978 |
|
| 979 |
*Returns:* `Rep(0)`.
|
| 980 |
|
| 981 |
[*Note 1*: `Rep(0)` is specified instead of `Rep()` because `Rep()` may
|
| 982 |
have some other meaning, such as an uninitialized value. — *end note*]
|
| 983 |
|
| 984 |
*Remarks:* The value returned shall be the additive identity.
|
| 985 |
|
| 986 |
``` cpp
|
| 987 |
+
static constexpr Rep min() noexcept;
|
| 988 |
```
|
| 989 |
|
| 990 |
*Returns:* `numeric_limits<Rep>::lowest()`.
|
| 991 |
|
| 992 |
*Remarks:* The value returned shall compare less than or equal to
|
| 993 |
`zero()`.
|
| 994 |
|
| 995 |
``` cpp
|
| 996 |
+
static constexpr Rep max() noexcept;
|
| 997 |
```
|
| 998 |
|
| 999 |
*Returns:* `numeric_limits<Rep>::max()`.
|
| 1000 |
|
| 1001 |
*Remarks:* The value returned shall compare greater than `zero()`.
|
| 1002 |
|
| 1003 |
+
### Specializations of `common_type` <a id="time.traits.specializations">[[time.traits.specializations]]</a>
|
| 1004 |
|
| 1005 |
``` cpp
|
| 1006 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1007 |
struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> {
|
| 1008 |
using type = chrono::duration<common_type_t<Rep1, Rep2>, see below>;
|
| 1009 |
};
|
| 1010 |
```
|
| 1011 |
|
| 1012 |
The `period` of the `duration` indicated by this specialization of
|
| 1013 |
+
`common_type` is the greatest common divisor of `Period1` and `Period2`.
|
|
|
|
| 1014 |
|
| 1015 |
[*Note 1*: This can be computed by forming a ratio of the greatest
|
| 1016 |
common divisor of `Period1::num` and `Period2::num` and the least common
|
| 1017 |
multiple of `Period1::den` and `Period2::den`. — *end note*]
|
| 1018 |
|
|
|
|
| 1032 |
|
| 1033 |
The common type of two `time_point` types is a `time_point` with the
|
| 1034 |
same clock as the two types and the common type of their two
|
| 1035 |
`duration`s.
|
| 1036 |
|
| 1037 |
+
### Class template `is_clock` <a id="time.traits.is.clock">[[time.traits.is.clock]]</a>
|
| 1038 |
+
|
| 1039 |
+
``` cpp
|
| 1040 |
+
template<class T> struct is_clock;
|
| 1041 |
+
```
|
| 1042 |
+
|
| 1043 |
+
`is_clock` is a *Cpp17UnaryTypeTrait* [[meta.rqmts]] with a base
|
| 1044 |
+
characteristic of `true_type` if `T` meets the *Cpp17Clock* requirements
|
| 1045 |
+
[[time.clock.req]], otherwise `false_type`. For the purposes of the
|
| 1046 |
+
specification of this trait, the extent to which an implementation
|
| 1047 |
+
determines that a type cannot meet the *Cpp17Clock* requirements is
|
| 1048 |
+
unspecified, except that as a minimum a type `T` shall not qualify as a
|
| 1049 |
+
*Cpp17Clock* unless it meets all of the following conditions:
|
| 1050 |
+
|
| 1051 |
+
- the *qualified-id*s `T::rep`, `T::period`, `T::duration`, and
|
| 1052 |
+
`T::time_point` are valid and each denotes a type [[temp.deduct]],
|
| 1053 |
+
- the expression `T::is_steady` is well-formed when treated as an
|
| 1054 |
+
unevaluated operand,
|
| 1055 |
+
- the expression `T::now()` is well-formed when treated as an
|
| 1056 |
+
unevaluated operand.
|
| 1057 |
+
|
| 1058 |
+
The behavior of a program that adds specializations for `is_clock` is
|
| 1059 |
+
undefined.
|
| 1060 |
+
|
| 1061 |
+
## Class template `duration` <a id="time.duration">[[time.duration]]</a>
|
| 1062 |
|
| 1063 |
A `duration` type measures time between two points in time
|
| 1064 |
(`time_point`s). A `duration` has a representation which holds a count
|
| 1065 |
of ticks and a tick period. The tick period is the amount of time which
|
| 1066 |
occurs from one tick to the next, in units of seconds. It is expressed
|
| 1067 |
as a rational constant using the template `ratio`.
|
| 1068 |
|
| 1069 |
``` cpp
|
| 1070 |
+
namespace std::chrono {
|
| 1071 |
template<class Rep, class Period = ratio<1>>
|
| 1072 |
class duration {
|
| 1073 |
public:
|
| 1074 |
using rep = Rep;
|
| 1075 |
using period = typename Period::type;
|
| 1076 |
+
|
| 1077 |
private:
|
| 1078 |
rep rep_; // exposition only
|
| 1079 |
+
|
| 1080 |
public:
|
| 1081 |
// [time.duration.cons], construct/copy/destroy
|
| 1082 |
constexpr duration() = default;
|
| 1083 |
template<class Rep2>
|
| 1084 |
constexpr explicit duration(const Rep2& r);
|
|
|
|
| 1106 |
constexpr duration& operator/=(const rep& rhs);
|
| 1107 |
constexpr duration& operator%=(const rep& rhs);
|
| 1108 |
constexpr duration& operator%=(const duration& rhs);
|
| 1109 |
|
| 1110 |
// [time.duration.special], special values
|
| 1111 |
+
static constexpr duration zero() noexcept;
|
| 1112 |
+
static constexpr duration min() noexcept;
|
| 1113 |
+
static constexpr duration max() noexcept;
|
| 1114 |
};
|
| 1115 |
+
}
|
| 1116 |
```
|
| 1117 |
|
| 1118 |
`Rep` shall be an arithmetic type or a class emulating an arithmetic
|
| 1119 |
type. If `duration` is instantiated with a `duration` type as the
|
| 1120 |
argument for the template parameter `Rep`, the program is ill-formed.
|
| 1121 |
|
| 1122 |
If `Period` is not a specialization of `ratio`, the program is
|
| 1123 |
ill-formed. If `Period::num` is not positive, the program is ill-formed.
|
| 1124 |
|
| 1125 |
+
Members of `duration` do not throw exceptions other than those thrown by
|
| 1126 |
+
the indicated operations on their representations.
|
| 1127 |
|
| 1128 |
The defaulted copy constructor of duration shall be a constexpr function
|
| 1129 |
if and only if the required initialization of the member `rep_` for copy
|
| 1130 |
and move, respectively, would satisfy the requirements for a constexpr
|
| 1131 |
function.
|
|
|
|
| 1139 |
// (30 Hz) using a double
|
| 1140 |
```
|
| 1141 |
|
| 1142 |
— *end example*]
|
| 1143 |
|
| 1144 |
+
### Constructors <a id="time.duration.cons">[[time.duration.cons]]</a>
|
| 1145 |
|
| 1146 |
``` cpp
|
| 1147 |
template<class Rep2>
|
| 1148 |
constexpr explicit duration(const Rep2& r);
|
| 1149 |
```
|
| 1150 |
|
| 1151 |
+
*Constraints:* `is_convertible_v<const Rep2&, rep>` is `true` and
|
|
|
|
| 1152 |
|
| 1153 |
- `treat_as_floating_point_v<rep>` is `true` or
|
| 1154 |
- `treat_as_floating_point_v<Rep2>` is `false`.
|
| 1155 |
|
| 1156 |
[*Example 1*:
|
|
|
|
| 1160 |
duration<int, milli> d(3.5); // error
|
| 1161 |
```
|
| 1162 |
|
| 1163 |
— *end example*]
|
| 1164 |
|
| 1165 |
+
*Ensures:* `count() == static_cast<rep>(r)`.
|
|
|
|
|
|
|
| 1166 |
|
| 1167 |
``` cpp
|
| 1168 |
template<class Rep2, class Period2>
|
| 1169 |
constexpr duration(const duration<Rep2, Period2>& d);
|
| 1170 |
```
|
| 1171 |
|
| 1172 |
+
*Constraints:* No overflow is induced in the conversion and
|
|
|
|
| 1173 |
`treat_as_floating_point_v<rep>` is `true` or both
|
| 1174 |
`ratio_divide<Period2, period>::den` is `1` and
|
| 1175 |
`treat_as_floating_point_v<Rep2>` is `false`.
|
| 1176 |
|
| 1177 |
[*Note 1*: This requirement prevents implicit truncation error when
|
|
|
|
| 1187 |
duration<int, milli> ms2 = us; // error
|
| 1188 |
```
|
| 1189 |
|
| 1190 |
— *end example*]
|
| 1191 |
|
| 1192 |
+
*Effects:* Initializes `rep_` with `duration_cast<duration>(d).count()`.
|
|
|
|
|
|
|
| 1193 |
|
| 1194 |
+
### Observer <a id="time.duration.observer">[[time.duration.observer]]</a>
|
| 1195 |
|
| 1196 |
``` cpp
|
| 1197 |
constexpr rep count() const;
|
| 1198 |
```
|
| 1199 |
|
| 1200 |
*Returns:* `rep_`.
|
| 1201 |
|
| 1202 |
+
### Arithmetic <a id="time.duration.arithmetic">[[time.duration.arithmetic]]</a>
|
| 1203 |
|
| 1204 |
``` cpp
|
| 1205 |
constexpr common_type_t<duration> operator+() const;
|
| 1206 |
```
|
| 1207 |
|
|
|
|
| 1215 |
|
| 1216 |
``` cpp
|
| 1217 |
constexpr duration& operator++();
|
| 1218 |
```
|
| 1219 |
|
| 1220 |
+
*Effects:* Equivalent to: `++rep_`.
|
| 1221 |
|
| 1222 |
*Returns:* `*this`.
|
| 1223 |
|
| 1224 |
``` cpp
|
| 1225 |
constexpr duration operator++(int);
|
| 1226 |
```
|
| 1227 |
|
| 1228 |
+
*Effects:* Equivalent to: `return duration(rep_++);`
|
| 1229 |
|
| 1230 |
``` cpp
|
| 1231 |
constexpr duration& operator--();
|
| 1232 |
```
|
| 1233 |
|
| 1234 |
+
*Effects:* Equivalent to: `–rep_`.
|
| 1235 |
|
| 1236 |
*Returns:* `*this`.
|
| 1237 |
|
| 1238 |
``` cpp
|
| 1239 |
constexpr duration operator--(int);
|
| 1240 |
```
|
| 1241 |
|
| 1242 |
+
*Effects:* Equivalent to: `return duration(rep_--);`
|
| 1243 |
|
| 1244 |
``` cpp
|
| 1245 |
constexpr duration& operator+=(const duration& d);
|
| 1246 |
```
|
| 1247 |
|
| 1248 |
+
*Effects:* Equivalent to: `rep_ += d.count()`.
|
| 1249 |
|
| 1250 |
*Returns:* `*this`.
|
| 1251 |
|
| 1252 |
``` cpp
|
| 1253 |
constexpr duration& operator-=(const duration& d);
|
| 1254 |
```
|
| 1255 |
|
| 1256 |
+
*Effects:* Equivalent to: `rep_ -= d.count()`.
|
| 1257 |
|
| 1258 |
*Returns:* `*this`.
|
| 1259 |
|
| 1260 |
``` cpp
|
| 1261 |
constexpr duration& operator*=(const rep& rhs);
|
| 1262 |
```
|
| 1263 |
|
| 1264 |
+
*Effects:* Equivalent to: `rep_ *= rhs`.
|
| 1265 |
|
| 1266 |
*Returns:* `*this`.
|
| 1267 |
|
| 1268 |
``` cpp
|
| 1269 |
constexpr duration& operator/=(const rep& rhs);
|
| 1270 |
```
|
| 1271 |
|
| 1272 |
+
*Effects:* Equivalent to: `rep_ /= rhs`.
|
| 1273 |
|
| 1274 |
*Returns:* `*this`.
|
| 1275 |
|
| 1276 |
``` cpp
|
| 1277 |
constexpr duration& operator%=(const rep& rhs);
|
| 1278 |
```
|
| 1279 |
|
| 1280 |
+
*Effects:* Equivalent to: `rep_ %= rhs`.
|
| 1281 |
|
| 1282 |
*Returns:* `*this`.
|
| 1283 |
|
| 1284 |
``` cpp
|
| 1285 |
constexpr duration& operator%=(const duration& rhs);
|
| 1286 |
```
|
| 1287 |
|
| 1288 |
+
*Effects:* Equivalent to: `rep_ %= rhs.count()`.
|
| 1289 |
|
| 1290 |
*Returns:* `*this`.
|
| 1291 |
|
| 1292 |
+
### Special values <a id="time.duration.special">[[time.duration.special]]</a>
|
| 1293 |
|
| 1294 |
``` cpp
|
| 1295 |
+
static constexpr duration zero() noexcept;
|
| 1296 |
```
|
| 1297 |
|
| 1298 |
*Returns:* `duration(duration_values<rep>::zero())`.
|
| 1299 |
|
| 1300 |
``` cpp
|
| 1301 |
+
static constexpr duration min() noexcept;
|
| 1302 |
```
|
| 1303 |
|
| 1304 |
*Returns:* `duration(duration_values<rep>::min())`.
|
| 1305 |
|
| 1306 |
``` cpp
|
| 1307 |
+
static constexpr duration max() noexcept;
|
| 1308 |
```
|
| 1309 |
|
| 1310 |
*Returns:* `duration(duration_values<rep>::max())`.
|
| 1311 |
|
| 1312 |
+
### Non-member arithmetic <a id="time.duration.nonmember">[[time.duration.nonmember]]</a>
|
| 1313 |
|
| 1314 |
+
In the function descriptions that follow, unless stated otherwise, let
|
| 1315 |
+
`CD` represent the return type of the function.
|
| 1316 |
|
| 1317 |
``` cpp
|
| 1318 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1319 |
constexpr common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>
|
| 1320 |
operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
|
|
|
| 1334 |
template<class Rep1, class Period, class Rep2>
|
| 1335 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 1336 |
operator*(const duration<Rep1, Period>& d, const Rep2& s);
|
| 1337 |
```
|
| 1338 |
|
| 1339 |
+
*Constraints:*
|
| 1340 |
+
`is_convertible_v<const Rep2&, common_type_t<Rep1, Rep2>>` is `true`.
|
| 1341 |
|
| 1342 |
*Returns:* `CD(CD(d).count() * s)`.
|
| 1343 |
|
| 1344 |
``` cpp
|
| 1345 |
template<class Rep1, class Rep2, class Period>
|
| 1346 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 1347 |
operator*(const Rep1& s, const duration<Rep2, Period>& d);
|
| 1348 |
```
|
| 1349 |
|
| 1350 |
+
*Constraints:*
|
| 1351 |
+
`is_convertible_v<const Rep1&, common_type_t<Rep1, Rep2>>` is `true`.
|
| 1352 |
|
| 1353 |
*Returns:* `d * s`.
|
| 1354 |
|
| 1355 |
``` cpp
|
| 1356 |
template<class Rep1, class Period, class Rep2>
|
| 1357 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 1358 |
operator/(const duration<Rep1, Period>& d, const Rep2& s);
|
| 1359 |
```
|
| 1360 |
|
| 1361 |
+
*Constraints:*
|
| 1362 |
+
`is_convertible_v<const Rep2&, common_type_t<Rep1, Rep2>>` is `true` and
|
| 1363 |
+
`Rep2` is not a specialization of `duration`.
|
| 1364 |
|
| 1365 |
*Returns:* `CD(CD(d).count() / s)`.
|
| 1366 |
|
| 1367 |
``` cpp
|
| 1368 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1369 |
constexpr common_type_t<Rep1, Rep2>
|
| 1370 |
operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 1371 |
```
|
| 1372 |
|
| 1373 |
+
Let `CD` be
|
| 1374 |
+
`common_type_t<duration<Rep1, Period1>, duration<Rep2, Period2>>`.
|
| 1375 |
+
|
| 1376 |
*Returns:* `CD(lhs).count() / CD(rhs).count()`.
|
| 1377 |
|
| 1378 |
``` cpp
|
| 1379 |
template<class Rep1, class Period, class Rep2>
|
| 1380 |
constexpr duration<common_type_t<Rep1, Rep2>, Period>
|
| 1381 |
operator%(const duration<Rep1, Period>& d, const Rep2& s);
|
| 1382 |
```
|
| 1383 |
|
| 1384 |
+
*Constraints:*
|
| 1385 |
+
`is_convertible_v<const Rep2&, common_type_t<Rep1, Rep2>>` is `true` and
|
| 1386 |
+
`Rep2` is not a specialization of `duration`.
|
| 1387 |
|
| 1388 |
*Returns:* `CD(CD(d).count() % s)`.
|
| 1389 |
|
| 1390 |
``` cpp
|
| 1391 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
|
|
|
| 1393 |
operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 1394 |
```
|
| 1395 |
|
| 1396 |
*Returns:* `CD(CD(lhs).count() % CD(rhs).count())`.
|
| 1397 |
|
| 1398 |
+
### Comparisons <a id="time.duration.comparisons">[[time.duration.comparisons]]</a>
|
| 1399 |
|
| 1400 |
In the function descriptions that follow, `CT` represents
|
| 1401 |
`common_type_t<A, B>`, where `A` and `B` are the types of the two
|
| 1402 |
arguments to the function.
|
| 1403 |
|
|
|
|
| 1405 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1406 |
constexpr bool operator==(const duration<Rep1, Period1>& lhs,
|
| 1407 |
const duration<Rep2, Period2>& rhs);
|
| 1408 |
```
|
| 1409 |
|
| 1410 |
+
*Returns:* `CT(lhs).count() == CT(rhs).count()`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1411 |
|
| 1412 |
``` cpp
|
| 1413 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1414 |
constexpr bool operator<(const duration<Rep1, Period1>& lhs,
|
| 1415 |
const duration<Rep2, Period2>& rhs);
|
| 1416 |
```
|
| 1417 |
|
| 1418 |
+
*Returns:* `CT(lhs).count() < CT(rhs).count()`.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1419 |
|
| 1420 |
``` cpp
|
| 1421 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1422 |
constexpr bool operator>(const duration<Rep1, Period1>& lhs,
|
| 1423 |
const duration<Rep2, Period2>& rhs);
|
| 1424 |
```
|
| 1425 |
|
| 1426 |
*Returns:* `rhs < lhs`.
|
| 1427 |
|
| 1428 |
+
``` cpp
|
| 1429 |
+
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1430 |
+
constexpr bool operator<=(const duration<Rep1, Period1>& lhs,
|
| 1431 |
+
const duration<Rep2, Period2>& rhs);
|
| 1432 |
+
```
|
| 1433 |
+
|
| 1434 |
+
*Returns:* `!(rhs < lhs)`.
|
| 1435 |
+
|
| 1436 |
``` cpp
|
| 1437 |
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1438 |
constexpr bool operator>=(const duration<Rep1, Period1>& lhs,
|
| 1439 |
const duration<Rep2, Period2>& rhs);
|
| 1440 |
```
|
| 1441 |
|
| 1442 |
*Returns:* `!(lhs < rhs)`.
|
| 1443 |
|
| 1444 |
+
``` cpp
|
| 1445 |
+
template<class Rep1, class Period1, class Rep2, class Period2>
|
| 1446 |
+
requires three_way_comparable<typename CT::rep>
|
| 1447 |
+
constexpr auto operator<=>(const duration<Rep1, Period1>& lhs,
|
| 1448 |
+
const duration<Rep2, Period2>& rhs);
|
| 1449 |
+
```
|
| 1450 |
+
|
| 1451 |
+
*Returns:* `CT(lhs).count() <=> CT(rhs).count()`.
|
| 1452 |
+
|
| 1453 |
+
### Conversions <a id="time.duration.cast">[[time.duration.cast]]</a>
|
| 1454 |
|
| 1455 |
``` cpp
|
| 1456 |
template<class ToDuration, class Rep, class Period>
|
| 1457 |
constexpr ToDuration duration_cast(const duration<Rep, Period>& d);
|
| 1458 |
```
|
| 1459 |
|
| 1460 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1461 |
|
| 1462 |
*Returns:* Let `CF` be
|
| 1463 |
`ratio_divide<Period, typename ToDuration::period>`, and `CR` be
|
| 1464 |
+
`common_type<typename ToDuration::rep, Rep, intmax_t>::type`.
|
| 1465 |
|
| 1466 |
- If `CF::num == 1` and `CF::den == 1`, returns
|
| 1467 |
``` cpp
|
| 1468 |
ToDuration(static_cast<typename ToDuration::rep>(d.count()))
|
| 1469 |
```
|
|
|
|
| 1493 |
``` cpp
|
| 1494 |
template<class ToDuration, class Rep, class Period>
|
| 1495 |
constexpr ToDuration floor(const duration<Rep, Period>& d);
|
| 1496 |
```
|
| 1497 |
|
| 1498 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1499 |
|
| 1500 |
*Returns:* The greatest result `t` representable in `ToDuration` for
|
| 1501 |
which `t <= d`.
|
| 1502 |
|
| 1503 |
``` cpp
|
| 1504 |
template<class ToDuration, class Rep, class Period>
|
| 1505 |
constexpr ToDuration ceil(const duration<Rep, Period>& d);
|
| 1506 |
```
|
| 1507 |
|
| 1508 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1509 |
|
| 1510 |
*Returns:* The least result `t` representable in `ToDuration` for which
|
| 1511 |
`t >= d`.
|
| 1512 |
|
| 1513 |
``` cpp
|
| 1514 |
template<class ToDuration, class Rep, class Period>
|
| 1515 |
constexpr ToDuration round(const duration<Rep, Period>& d);
|
| 1516 |
```
|
| 1517 |
|
| 1518 |
+
*Constraints:* `ToDuration` is a specialization of `duration` and
|
|
|
|
| 1519 |
`treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
|
| 1520 |
|
| 1521 |
*Returns:* The value of `ToDuration` that is closest to `d`. If there
|
| 1522 |
are two closest values, then return the value `t` for which
|
| 1523 |
`t % 2 == 0`.
|
| 1524 |
|
| 1525 |
+
### Suffixes for duration literals <a id="time.duration.literals">[[time.duration.literals]]</a>
|
| 1526 |
|
| 1527 |
+
This subclause describes literal suffixes for constructing duration
|
| 1528 |
literals. The suffixes `h`, `min`, `s`, `ms`, `us`, `ns` denote duration
|
| 1529 |
values of the corresponding types `hours`, `minutes`, `seconds`,
|
| 1530 |
`milliseconds`, `microseconds`, and `nanoseconds` respectively if they
|
| 1531 |
+
are applied to *integer-literal*s.
|
| 1532 |
|
| 1533 |
+
If any of these suffixes are applied to a *floating-point-literal* the
|
| 1534 |
result is a `chrono::duration` literal with an unspecified
|
| 1535 |
floating-point representation.
|
| 1536 |
|
| 1537 |
+
If any of these suffixes are applied to an *integer-literal* and the
|
| 1538 |
resulting `chrono::duration` value cannot be represented in the result
|
| 1539 |
type because of overflow, the program is ill-formed.
|
| 1540 |
|
| 1541 |
[*Example 1*:
|
| 1542 |
|
|
|
|
| 1595 |
constexpr chrono::duration<unspecified, nano> operator""ns(long double nsec);
|
| 1596 |
```
|
| 1597 |
|
| 1598 |
*Returns:* A `duration` literal representing `nsec` nanoseconds.
|
| 1599 |
|
| 1600 |
+
### Algorithms <a id="time.duration.alg">[[time.duration.alg]]</a>
|
| 1601 |
|
| 1602 |
``` cpp
|
| 1603 |
template<class Rep, class Period>
|
| 1604 |
constexpr duration<Rep, Period> abs(duration<Rep, Period> d);
|
| 1605 |
```
|
| 1606 |
|
| 1607 |
+
*Constraints:* `numeric_limits<Rep>::is_signed` is `true`.
|
|
|
|
| 1608 |
|
| 1609 |
*Returns:* If `d >= d.zero()`, return `d`, otherwise return `-d`.
|
| 1610 |
|
| 1611 |
+
### I/O <a id="time.duration.io">[[time.duration.io]]</a>
|
| 1612 |
|
| 1613 |
``` cpp
|
| 1614 |
+
template<class charT, class traits, class Rep, class Period>
|
| 1615 |
+
basic_ostream<charT, traits>&
|
| 1616 |
+
operator<<(basic_ostream<charT, traits>& os, const duration<Rep, Period>& d);
|
| 1617 |
+
```
|
| 1618 |
+
|
| 1619 |
+
*Effects:* Inserts the duration `d` onto the stream `os` as if it were
|
| 1620 |
+
implemented as follows:
|
| 1621 |
+
|
| 1622 |
+
``` cpp
|
| 1623 |
+
basic_ostringstream<charT, traits> s;
|
| 1624 |
+
s.flags(os.flags());
|
| 1625 |
+
s.imbue(os.getloc());
|
| 1626 |
+
s.precision(os.precision());
|
| 1627 |
+
s << d.count() << units-suffix;
|
| 1628 |
+
return os << s.str();
|
| 1629 |
+
```
|
| 1630 |
+
|
| 1631 |
+
where *`units-suffix`* depends on the type `Period::type` as follows:
|
| 1632 |
+
|
| 1633 |
+
- If `Period::type` is `atto`, *`units-suffix`* is `"as"`.
|
| 1634 |
+
- Otherwise, if `Period::type` is `femto`, *`units-suffix`* is `"fs"`.
|
| 1635 |
+
- Otherwise, if `Period::type` is `pico`, *`units-suffix`* is `"ps"`.
|
| 1636 |
+
- Otherwise, if `Period::type` is `nano`, *`units-suffix`* is `"ns"`.
|
| 1637 |
+
- Otherwise, if `Period::type` is `micro`, it is
|
| 1638 |
+
*implementation-defined* whether *`units-suffix`* is `"`\textmu`s"`
|
| 1639 |
+
(`"\u00b5\u0073"`) or `"us"`.
|
| 1640 |
+
- Otherwise, if `Period::type` is `milli`, *`units-suffix`* is `"ms"`.
|
| 1641 |
+
- Otherwise, if `Period::type` is `centi`, *`units-suffix`* is `"cs"`.
|
| 1642 |
+
- Otherwise, if `Period::type` is `deci`, *`units-suffix`* is `"ds"`.
|
| 1643 |
+
- Otherwise, if `Period::type` is `ratio<1>`, *`units-suffix`* is `"s"`.
|
| 1644 |
+
- Otherwise, if `Period::type` is `deca`, *`units-suffix`* is `"das"`.
|
| 1645 |
+
- Otherwise, if `Period::type` is `hecto`, *`units-suffix`* is `"hs"`.
|
| 1646 |
+
- Otherwise, if `Period::type` is `kilo`, *`units-suffix`* is `"ks"`.
|
| 1647 |
+
- Otherwise, if `Period::type` is `mega`, *`units-suffix`* is `"Ms"`.
|
| 1648 |
+
- Otherwise, if `Period::type` is `giga`, *`units-suffix`* is `"Gs"`.
|
| 1649 |
+
- Otherwise, if `Period::type` is `tera`, *`units-suffix`* is `"Ts"`.
|
| 1650 |
+
- Otherwise, if `Period::type` is `peta`, *`units-suffix`* is `"Ps"`.
|
| 1651 |
+
- Otherwise, if `Period::type` is `exa`, *`units-suffix`* is `"Es"`.
|
| 1652 |
+
- Otherwise, if `Period::type` is `ratio<60>`, *`units-suffix`* is
|
| 1653 |
+
`"min"`.
|
| 1654 |
+
- Otherwise, if `Period::type` is `ratio<3600>`, *`units-suffix`* is
|
| 1655 |
+
`"h"`.
|
| 1656 |
+
- Otherwise, if `Period::type` is `ratio<86400>`, *`units-suffix`* is
|
| 1657 |
+
`"d"`.
|
| 1658 |
+
- Otherwise, if `Period::type::den == 1`, *`units-suffix`* is
|
| 1659 |
+
`"[`*`num`*`]s"`.
|
| 1660 |
+
- Otherwise, *`units-suffix`* is `"[`*`num`*`/`*`den`*`]s"`.
|
| 1661 |
+
|
| 1662 |
+
In the list above, the use of *`num`* and *`den`* refer to the static
|
| 1663 |
+
data members of `Period::type`, which are converted to arrays of `charT`
|
| 1664 |
+
using a decimal conversion with no leading zeroes.
|
| 1665 |
+
|
| 1666 |
+
*Returns:* `os`.
|
| 1667 |
+
|
| 1668 |
+
``` cpp
|
| 1669 |
+
template<class charT, class traits, class Rep, class Period, class Alloc = allocator<charT>>
|
| 1670 |
+
basic_istream<charT, traits>&
|
| 1671 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 1672 |
+
duration<Rep, Period>& d,
|
| 1673 |
+
basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 1674 |
+
minutes* offset = nullptr);
|
| 1675 |
+
```
|
| 1676 |
+
|
| 1677 |
+
*Effects:* Attempts to parse the input stream `is` into the duration `d`
|
| 1678 |
+
using the format flags given in the NTCTS `fmt` as specified in
|
| 1679 |
+
[[time.parse]]. If the parse parses everything specified by the parsing
|
| 1680 |
+
format flags without error, and yet none of the flags impacts a
|
| 1681 |
+
duration, `d` will be assigned a zero value. If `%Z` is used and
|
| 1682 |
+
successfully parsed, that value will be assigned to `*abbrev` if
|
| 1683 |
+
`abbrev` is non-null. If `%z` (or a modified variant) is used and
|
| 1684 |
+
successfully parsed, that value will be assigned to `*offset` if
|
| 1685 |
+
`offset` is non-null.
|
| 1686 |
+
|
| 1687 |
+
*Returns:* `is`.
|
| 1688 |
+
|
| 1689 |
+
## Class template `time_point` <a id="time.point">[[time.point]]</a>
|
| 1690 |
+
|
| 1691 |
+
``` cpp
|
| 1692 |
+
namespace std::chrono {
|
| 1693 |
template<class Clock, class Duration = typename Clock::duration>
|
| 1694 |
class time_point {
|
| 1695 |
public:
|
| 1696 |
using clock = Clock;
|
| 1697 |
using duration = Duration;
|
| 1698 |
using rep = typename duration::rep;
|
| 1699 |
using period = typename duration::period;
|
| 1700 |
+
|
| 1701 |
private:
|
| 1702 |
duration d_; // exposition only
|
| 1703 |
|
| 1704 |
public:
|
| 1705 |
// [time.point.cons], construct
|
|
|
|
| 1710 |
|
| 1711 |
// [time.point.observer], observer
|
| 1712 |
constexpr duration time_since_epoch() const;
|
| 1713 |
|
| 1714 |
// [time.point.arithmetic], arithmetic
|
| 1715 |
+
constexpr time_point& operator++();
|
| 1716 |
+
constexpr time_point operator++(int);
|
| 1717 |
+
constexpr time_point& operator--();
|
| 1718 |
+
constexpr time_point operator--(int);
|
| 1719 |
constexpr time_point& operator+=(const duration& d);
|
| 1720 |
constexpr time_point& operator-=(const duration& d);
|
| 1721 |
|
| 1722 |
// [time.point.special], special values
|
| 1723 |
+
static constexpr time_point min() noexcept;
|
| 1724 |
+
static constexpr time_point max() noexcept;
|
| 1725 |
};
|
| 1726 |
+
}
|
| 1727 |
```
|
| 1728 |
|
| 1729 |
+
`Clock` shall either meet the *Cpp17Clock* requirements
|
| 1730 |
+
[[time.clock.req]] or be the type `local_t`.
|
| 1731 |
|
| 1732 |
If `Duration` is not an instance of `duration`, the program is
|
| 1733 |
ill-formed.
|
| 1734 |
|
| 1735 |
+
### Constructors <a id="time.point.cons">[[time.point.cons]]</a>
|
| 1736 |
|
| 1737 |
``` cpp
|
| 1738 |
constexpr time_point();
|
| 1739 |
```
|
| 1740 |
|
| 1741 |
+
*Effects:* Initializes `d_` with `duration::zero()`. Such a `time_point`
|
| 1742 |
+
object represents the epoch.
|
|
|
|
| 1743 |
|
| 1744 |
``` cpp
|
| 1745 |
constexpr explicit time_point(const duration& d);
|
| 1746 |
```
|
| 1747 |
|
| 1748 |
+
*Effects:* Initializes `d_` with `d`. Such a `time_point` object
|
| 1749 |
+
represents the epoch `+ d`.
|
| 1750 |
|
| 1751 |
``` cpp
|
| 1752 |
template<class Duration2>
|
| 1753 |
constexpr time_point(const time_point<clock, Duration2>& t);
|
| 1754 |
```
|
| 1755 |
|
| 1756 |
+
*Constraints:* `is_convertible_v<Duration2, duration>` is `true`.
|
|
|
|
| 1757 |
|
| 1758 |
+
*Effects:* Initializes `d_` with `t.time_since_epoch()`.
|
|
|
|
| 1759 |
|
| 1760 |
+
### Observer <a id="time.point.observer">[[time.point.observer]]</a>
|
| 1761 |
|
| 1762 |
``` cpp
|
| 1763 |
constexpr duration time_since_epoch() const;
|
| 1764 |
```
|
| 1765 |
|
| 1766 |
*Returns:* `d_`.
|
| 1767 |
|
| 1768 |
+
### Arithmetic <a id="time.point.arithmetic">[[time.point.arithmetic]]</a>
|
| 1769 |
+
|
| 1770 |
+
``` cpp
|
| 1771 |
+
constexpr time_point& operator++();
|
| 1772 |
+
```
|
| 1773 |
+
|
| 1774 |
+
*Effects:* Equivalent to: `++d_`.
|
| 1775 |
+
|
| 1776 |
+
*Returns:* `*this`.
|
| 1777 |
+
|
| 1778 |
+
``` cpp
|
| 1779 |
+
constexpr time_point operator++(int);
|
| 1780 |
+
```
|
| 1781 |
+
|
| 1782 |
+
*Effects:* Equivalent to: `return time_point{d_++};`
|
| 1783 |
+
|
| 1784 |
+
``` cpp
|
| 1785 |
+
constexpr time_point& operator--();
|
| 1786 |
+
```
|
| 1787 |
+
|
| 1788 |
+
*Effects:* Equivalent to: `–d_`.
|
| 1789 |
+
|
| 1790 |
+
*Returns:* `*this`.
|
| 1791 |
+
|
| 1792 |
+
``` cpp
|
| 1793 |
+
constexpr time_point operator--(int);
|
| 1794 |
+
```
|
| 1795 |
+
|
| 1796 |
+
*Effects:* Equivalent to: `return time_point{d_--};`
|
| 1797 |
|
| 1798 |
``` cpp
|
| 1799 |
constexpr time_point& operator+=(const duration& d);
|
| 1800 |
```
|
| 1801 |
|
| 1802 |
+
*Effects:* Equivalent to: `d_ += d`.
|
| 1803 |
|
| 1804 |
*Returns:* `*this`.
|
| 1805 |
|
| 1806 |
``` cpp
|
| 1807 |
constexpr time_point& operator-=(const duration& d);
|
| 1808 |
```
|
| 1809 |
|
| 1810 |
+
*Effects:* Equivalent to: `d_ -= d`.
|
| 1811 |
|
| 1812 |
*Returns:* `*this`.
|
| 1813 |
|
| 1814 |
+
### Special values <a id="time.point.special">[[time.point.special]]</a>
|
| 1815 |
|
| 1816 |
``` cpp
|
| 1817 |
+
static constexpr time_point min() noexcept;
|
| 1818 |
```
|
| 1819 |
|
| 1820 |
*Returns:* `time_point(duration::min())`.
|
| 1821 |
|
| 1822 |
``` cpp
|
| 1823 |
+
static constexpr time_point max() noexcept;
|
| 1824 |
```
|
| 1825 |
|
| 1826 |
*Returns:* `time_point(duration::max())`.
|
| 1827 |
|
| 1828 |
+
### Non-member arithmetic <a id="time.point.nonmember">[[time.point.nonmember]]</a>
|
| 1829 |
|
| 1830 |
``` cpp
|
| 1831 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 1832 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 1833 |
operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 1834 |
```
|
| 1835 |
|
| 1836 |
+
*Returns:* `CT(lhs.time_since_epoch() + rhs)`, where `CT` is the type of
|
| 1837 |
+
the return value.
|
| 1838 |
|
| 1839 |
``` cpp
|
| 1840 |
template<class Rep1, class Period1, class Clock, class Duration2>
|
| 1841 |
constexpr time_point<Clock, common_type_t<duration<Rep1, Period1>, Duration2>>
|
| 1842 |
operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
|
|
|
|
| 1848 |
template<class Clock, class Duration1, class Rep2, class Period2>
|
| 1849 |
constexpr time_point<Clock, common_type_t<Duration1, duration<Rep2, Period2>>>
|
| 1850 |
operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
|
| 1851 |
```
|
| 1852 |
|
| 1853 |
+
*Returns:* `CT(lhs.time_since_epoch() - rhs)`, where `CT` is the type of
|
| 1854 |
+
the return value.
|
| 1855 |
|
| 1856 |
``` cpp
|
| 1857 |
template<class Clock, class Duration1, class Duration2>
|
| 1858 |
constexpr common_type_t<Duration1, Duration2>
|
| 1859 |
operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
|
| 1860 |
```
|
| 1861 |
|
| 1862 |
*Returns:* `lhs.time_since_epoch() - rhs.time_since_epoch()`.
|
| 1863 |
|
| 1864 |
+
### Comparisons <a id="time.point.comparisons">[[time.point.comparisons]]</a>
|
| 1865 |
|
| 1866 |
``` cpp
|
| 1867 |
template<class Clock, class Duration1, class Duration2>
|
| 1868 |
constexpr bool operator==(const time_point<Clock, Duration1>& lhs,
|
| 1869 |
const time_point<Clock, Duration2>& rhs);
|
| 1870 |
```
|
| 1871 |
|
| 1872 |
*Returns:* `lhs.time_since_epoch() == rhs.time_since_epoch()`.
|
| 1873 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1874 |
``` cpp
|
| 1875 |
template<class Clock, class Duration1, class Duration2>
|
| 1876 |
constexpr bool operator<(const time_point<Clock, Duration1>& lhs,
|
| 1877 |
const time_point<Clock, Duration2>& rhs);
|
| 1878 |
```
|
| 1879 |
|
| 1880 |
*Returns:* `lhs.time_since_epoch() < rhs.time_since_epoch()`.
|
| 1881 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1882 |
``` cpp
|
| 1883 |
template<class Clock, class Duration1, class Duration2>
|
| 1884 |
constexpr bool operator>(const time_point<Clock, Duration1>& lhs,
|
| 1885 |
const time_point<Clock, Duration2>& rhs);
|
| 1886 |
```
|
| 1887 |
|
| 1888 |
*Returns:* `rhs < lhs`.
|
| 1889 |
|
| 1890 |
+
``` cpp
|
| 1891 |
+
template<class Clock, class Duration1, class Duration2>
|
| 1892 |
+
constexpr bool operator<=(const time_point<Clock, Duration1>& lhs,
|
| 1893 |
+
const time_point<Clock, Duration2>& rhs);
|
| 1894 |
+
```
|
| 1895 |
+
|
| 1896 |
+
*Returns:* `!(rhs < lhs)`.
|
| 1897 |
+
|
| 1898 |
``` cpp
|
| 1899 |
template<class Clock, class Duration1, class Duration2>
|
| 1900 |
constexpr bool operator>=(const time_point<Clock, Duration1>& lhs,
|
| 1901 |
const time_point<Clock, Duration2>& rhs);
|
| 1902 |
```
|
| 1903 |
|
| 1904 |
*Returns:* `!(lhs < rhs)`.
|
| 1905 |
|
| 1906 |
+
``` cpp
|
| 1907 |
+
template<class Clock, class Duration1,
|
| 1908 |
+
three_way_comparable_with<Duration1> Duration2>
|
| 1909 |
+
constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
|
| 1910 |
+
const time_point<Clock, Duration2>& rhs);
|
| 1911 |
+
```
|
| 1912 |
+
|
| 1913 |
+
*Returns:* `lhs.time_since_epoch() <=> rhs.time_since_epoch()`.
|
| 1914 |
+
|
| 1915 |
+
### Conversions <a id="time.point.cast">[[time.point.cast]]</a>
|
| 1916 |
|
| 1917 |
``` cpp
|
| 1918 |
template<class ToDuration, class Clock, class Duration>
|
| 1919 |
+
constexpr time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
|
|
|
|
| 1920 |
```
|
| 1921 |
|
| 1922 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1923 |
|
| 1924 |
*Returns:*
|
| 1925 |
|
| 1926 |
``` cpp
|
| 1927 |
time_point<Clock, ToDuration>(duration_cast<ToDuration>(t.time_since_epoch()))
|
| 1928 |
```
|
| 1929 |
|
| 1930 |
``` cpp
|
| 1931 |
template<class ToDuration, class Clock, class Duration>
|
| 1932 |
+
constexpr time_point<Clock, ToDuration> floor(const time_point<Clock, Duration>& tp);
|
|
|
|
| 1933 |
```
|
| 1934 |
|
| 1935 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1936 |
|
| 1937 |
*Returns:*
|
| 1938 |
`time_point<Clock, ToDuration>(floor<ToDuration>(tp.time_since_epoch()))`.
|
| 1939 |
|
| 1940 |
``` cpp
|
| 1941 |
template<class ToDuration, class Clock, class Duration>
|
| 1942 |
+
constexpr time_point<Clock, ToDuration> ceil(const time_point<Clock, Duration>& tp);
|
|
|
|
| 1943 |
```
|
| 1944 |
|
| 1945 |
+
*Constraints:* `ToDuration` is a specialization of `duration`.
|
|
|
|
| 1946 |
|
| 1947 |
*Returns:*
|
| 1948 |
`time_point<Clock, ToDuration>(ceil<ToDuration>(tp.time_since_epoch()))`.
|
| 1949 |
|
| 1950 |
``` cpp
|
| 1951 |
template<class ToDuration, class Clock, class Duration>
|
| 1952 |
+
constexpr time_point<Clock, ToDuration> round(const time_point<Clock, Duration>& tp);
|
|
|
|
| 1953 |
```
|
| 1954 |
|
| 1955 |
+
*Constraints:* `ToDuration` is a specialization of `duration`, and
|
|
|
|
| 1956 |
`treat_as_floating_point_v<typename ToDuration::rep>` is `false`.
|
| 1957 |
|
| 1958 |
*Returns:*
|
| 1959 |
`time_point<Clock, ToDuration>(round<ToDuration>(tp.time_since_epoch()))`.
|
| 1960 |
|
| 1961 |
+
## Clocks <a id="time.clock">[[time.clock]]</a>
|
| 1962 |
|
| 1963 |
+
The types defined in this subclause meet the *Cpp17TrivialClock*
|
| 1964 |
+
requirements [[time.clock.req]] unless otherwise specified.
|
| 1965 |
|
| 1966 |
+
### Class `system_clock` <a id="time.clock.system">[[time.clock.system]]</a>
|
| 1967 |
|
| 1968 |
+
#### Overview <a id="time.clock.system.overview">[[time.clock.system.overview]]</a>
|
|
|
|
| 1969 |
|
| 1970 |
``` cpp
|
| 1971 |
+
namespace std::chrono {
|
| 1972 |
class system_clock {
|
| 1973 |
public:
|
| 1974 |
using rep = see below;
|
| 1975 |
using period = ratio<unspecified, unspecified{}>;
|
| 1976 |
using duration = chrono::duration<rep, period>;
|
| 1977 |
using time_point = chrono::time_point<system_clock>;
|
| 1978 |
static constexpr bool is_steady = unspecified;
|
| 1979 |
|
| 1980 |
static time_point now() noexcept;
|
| 1981 |
|
| 1982 |
+
// mapping to/from C type time_t
|
| 1983 |
static time_t to_time_t (const time_point& t) noexcept;
|
| 1984 |
static time_point from_time_t(time_t t) noexcept;
|
| 1985 |
};
|
| 1986 |
+
}
|
| 1987 |
```
|
| 1988 |
|
| 1989 |
+
Objects of type `system_clock` represent wall clock time from the
|
| 1990 |
+
system-wide realtime clock. Objects of type `sys_time<Duration>` measure
|
| 1991 |
+
time since 1970-01-01 00:00:00 UTC excluding leap seconds. This measure
|
| 1992 |
+
is commonly referred to as *Unix time*. This measure facilitates an
|
| 1993 |
+
efficient mapping between `sys_time` and calendar types [[time.cal]].
|
| 1994 |
+
|
| 1995 |
+
[*Example 1*:
|
| 1996 |
+
`sys_seconds{sys_days{1970y/January/1}}.time_since_epoch()` is `0s`.
|
| 1997 |
+
`sys_seconds{sys_days{2000y/January/1}}.time_since_epoch()` is
|
| 1998 |
+
`946'684'800s`, which is `10'957 * 86'400s`.
|
| 1999 |
+
— *end example*]
|
| 2000 |
+
|
| 2001 |
+
#### Members <a id="time.clock.system.members">[[time.clock.system.members]]</a>
|
| 2002 |
+
|
| 2003 |
``` cpp
|
| 2004 |
using system_clock::rep = unspecified;
|
| 2005 |
```
|
| 2006 |
|
| 2007 |
+
*Constraints:*
|
| 2008 |
+
`system_clock::duration::min() < system_clock::duration::zero()` is
|
| 2009 |
+
`true`.
|
| 2010 |
|
| 2011 |
[*Note 1*: This implies that `rep` is a signed type. — *end note*]
|
| 2012 |
|
| 2013 |
``` cpp
|
| 2014 |
static time_t to_time_t(const time_point& t) noexcept;
|
|
|
|
| 2026 |
*Returns:* A `time_point` object that represents the same point in time
|
| 2027 |
as `t` when both values are restricted to the coarser of the precisions
|
| 2028 |
of `time_t` and `time_point`. It is *implementation-defined* whether
|
| 2029 |
values are rounded or truncated to the required precision.
|
| 2030 |
|
| 2031 |
+
#### Non-member functions <a id="time.clock.system.nonmembers">[[time.clock.system.nonmembers]]</a>
|
| 2032 |
+
|
| 2033 |
+
``` cpp
|
| 2034 |
+
template<class charT, class traits, class Duration>
|
| 2035 |
+
basic_ostream<charT, traits>&
|
| 2036 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
|
| 2037 |
+
```
|
| 2038 |
+
|
| 2039 |
+
*Constraints:* `treat_as_floating_point_v<typename Duration::rep>` is
|
| 2040 |
+
`false`, and `Duration{1} < days{1}` is `true`.
|
| 2041 |
+
|
| 2042 |
+
*Effects:* Equivalent to:
|
| 2043 |
+
|
| 2044 |
+
``` cpp
|
| 2045 |
+
auto const dp = floor<days>(tp);
|
| 2046 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{} {}"),
|
| 2047 |
+
year_month_day{dp}, hh_mm_ss{tp-dp});
|
| 2048 |
+
```
|
| 2049 |
+
|
| 2050 |
+
[*Example 1*:
|
| 2051 |
+
|
| 2052 |
+
``` cpp
|
| 2053 |
+
cout << sys_seconds{0s} << '\n'; // 1970-01-01 00:00:00
|
| 2054 |
+
cout << sys_seconds{946'684'800s} << '\n'; // 2000-01-01 00:00:00
|
| 2055 |
+
cout << sys_seconds{946'688'523s} << '\n'; // 2000-01-01 01:02:03
|
| 2056 |
+
```
|
| 2057 |
+
|
| 2058 |
+
— *end example*]
|
| 2059 |
+
|
| 2060 |
+
``` cpp
|
| 2061 |
+
template<class charT, class traits>
|
| 2062 |
+
basic_ostream<charT, traits>&
|
| 2063 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
|
| 2064 |
+
```
|
| 2065 |
+
|
| 2066 |
+
*Effects:* `os << year_month_day{dp}`.
|
| 2067 |
+
|
| 2068 |
+
*Returns:* `os`.
|
| 2069 |
+
|
| 2070 |
+
``` cpp
|
| 2071 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2072 |
+
basic_istream<charT, traits>&
|
| 2073 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2074 |
+
sys_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2075 |
+
minutes* offset = nullptr);
|
| 2076 |
+
```
|
| 2077 |
+
|
| 2078 |
+
*Effects:* Attempts to parse the input stream `is` into the `sys_time`
|
| 2079 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2080 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2081 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2082 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2083 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2084 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2085 |
+
if `offset` is non-null. Additionally, the parsed offset will be
|
| 2086 |
+
subtracted from the successfully parsed timestamp prior to assigning
|
| 2087 |
+
that difference to `tp`.
|
| 2088 |
+
|
| 2089 |
+
*Returns:* `is`.
|
| 2090 |
+
|
| 2091 |
+
### Class `utc_clock` <a id="time.clock.utc">[[time.clock.utc]]</a>
|
| 2092 |
+
|
| 2093 |
+
#### Overview <a id="time.clock.utc.overview">[[time.clock.utc.overview]]</a>
|
| 2094 |
+
|
| 2095 |
+
``` cpp
|
| 2096 |
+
namespace std::chrono {
|
| 2097 |
+
class utc_clock {
|
| 2098 |
+
public:
|
| 2099 |
+
using rep = a signed arithmetic type;
|
| 2100 |
+
using period = ratio<unspecified, unspecified>;
|
| 2101 |
+
using duration = chrono::duration<rep, period>;
|
| 2102 |
+
using time_point = chrono::time_point<utc_clock>;
|
| 2103 |
+
static constexpr bool is_steady = unspecified;
|
| 2104 |
+
|
| 2105 |
+
static time_point now();
|
| 2106 |
+
|
| 2107 |
+
template<class Duration>
|
| 2108 |
+
static sys_time<common_type_t<Duration, seconds>>
|
| 2109 |
+
to_sys(const utc_time<Duration>& t);
|
| 2110 |
+
template<class Duration>
|
| 2111 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2112 |
+
from_sys(const sys_time<Duration>& t);
|
| 2113 |
+
};
|
| 2114 |
+
}
|
| 2115 |
+
```
|
| 2116 |
+
|
| 2117 |
+
In contrast to `sys_time`, which does not take leap seconds into
|
| 2118 |
+
account, `utc_clock` and its associated `time_point`, `utc_time`, count
|
| 2119 |
+
time, including leap seconds, since 1970-01-01 00:00:00 UTC.
|
| 2120 |
+
|
| 2121 |
+
[*Note 1*: The UTC time standard began on 1972-01-01 00:00:10 TAI. To
|
| 2122 |
+
measure time since this epoch instead, one can add/subtract the constant
|
| 2123 |
+
`sys_days{1972y/1/1} - sys_days{1970y/1/1}` (`63'072'000s`) from the
|
| 2124 |
+
`utc_time`. — *end note*]
|
| 2125 |
+
|
| 2126 |
+
[*Example 1*:
|
| 2127 |
+
`clock_cast<utc_clock>(sys_seconds{sys_days{1970y/January/1}}).time_since_epoch()`
|
| 2128 |
+
is `0s`.
|
| 2129 |
+
`clock_cast<utc_clock>(sys_seconds{sys_days{2000y/January/1}}).time_since_epoch()`
|
| 2130 |
+
is `946'684'822s`, which is `10'957 * 86'400s + 22s`.
|
| 2131 |
+
— *end example*]
|
| 2132 |
+
|
| 2133 |
+
`utc_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 2134 |
+
guarantee that `utc_clock::now()` does not propagate an exception.
|
| 2135 |
+
|
| 2136 |
+
[*Note 2*: `noexcept(from_sys(system_clock::now()))` is
|
| 2137 |
+
`false`. — *end note*]
|
| 2138 |
+
|
| 2139 |
+
#### Member functions <a id="time.clock.utc.members">[[time.clock.utc.members]]</a>
|
| 2140 |
+
|
| 2141 |
+
``` cpp
|
| 2142 |
+
static time_point now();
|
| 2143 |
+
```
|
| 2144 |
+
|
| 2145 |
+
*Returns:* `from_sys(system_clock::now())`, or a more accurate value of
|
| 2146 |
+
`utc_time`.
|
| 2147 |
+
|
| 2148 |
+
``` cpp
|
| 2149 |
+
template<class Duration>
|
| 2150 |
+
static sys_time<common_type_t<Duration, seconds>>
|
| 2151 |
+
to_sys(const utc_time<Duration>& u);
|
| 2152 |
+
```
|
| 2153 |
+
|
| 2154 |
+
*Returns:* A `sys_time` `t`, such that `from_sys(t) == u` if such a
|
| 2155 |
+
mapping exists. Otherwise `u` represents a `time_point` during a
|
| 2156 |
+
positive leap second insertion, the conversion counts that leap second
|
| 2157 |
+
as not inserted, and the last representable value of `sys_time` prior to
|
| 2158 |
+
the insertion of the leap second is returned.
|
| 2159 |
+
|
| 2160 |
+
``` cpp
|
| 2161 |
+
template<class Duration>
|
| 2162 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2163 |
+
from_sys(const sys_time<Duration>& t);
|
| 2164 |
+
```
|
| 2165 |
+
|
| 2166 |
+
*Returns:* A `utc_time` `u`, such that
|
| 2167 |
+
`u.time_since_epoch() - t.time_since_epoch()` is equal to the sum of
|
| 2168 |
+
leap seconds that were inserted between `t` and 1970-01-01. If `t` is
|
| 2169 |
+
exactly the date of leap second insertion, then the conversion counts
|
| 2170 |
+
that leap second as inserted.
|
| 2171 |
+
|
| 2172 |
+
[*Example 1*:
|
| 2173 |
+
|
| 2174 |
+
``` cpp
|
| 2175 |
+
auto t = sys_days{July/1/2015} - 2ns;
|
| 2176 |
+
auto u = utc_clock::from_sys(t);
|
| 2177 |
+
assert(u.time_since_epoch() - t.time_since_epoch() == 25s);
|
| 2178 |
+
t += 1ns;
|
| 2179 |
+
u = utc_clock::from_sys(t);
|
| 2180 |
+
assert(u.time_since_epoch() - t.time_since_epoch() == 25s);
|
| 2181 |
+
t += 1ns;
|
| 2182 |
+
u = utc_clock::from_sys(t);
|
| 2183 |
+
assert(u.time_since_epoch() - t.time_since_epoch() == 26s);
|
| 2184 |
+
t += 1ns;
|
| 2185 |
+
u = utc_clock::from_sys(t);
|
| 2186 |
+
assert(u.time_since_epoch() - t.time_since_epoch() == 26s);
|
| 2187 |
+
```
|
| 2188 |
+
|
| 2189 |
+
— *end example*]
|
| 2190 |
+
|
| 2191 |
+
#### Non-member functions <a id="time.clock.utc.nonmembers">[[time.clock.utc.nonmembers]]</a>
|
| 2192 |
+
|
| 2193 |
+
``` cpp
|
| 2194 |
+
template<class charT, class traits, class Duration>
|
| 2195 |
+
basic_ostream<charT, traits>&
|
| 2196 |
+
operator<<(basic_ostream<charT, traits>& os, const utc_time<Duration>& t);
|
| 2197 |
+
```
|
| 2198 |
+
|
| 2199 |
+
*Effects:* Equivalent to:
|
| 2200 |
+
|
| 2201 |
+
``` cpp
|
| 2202 |
+
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2203 |
+
```
|
| 2204 |
+
|
| 2205 |
+
[*Example 1*:
|
| 2206 |
+
|
| 2207 |
+
``` cpp
|
| 2208 |
+
auto t = sys_days{July/1/2015} - 500ms;
|
| 2209 |
+
auto u = clock_cast<utc_clock>(t);
|
| 2210 |
+
for (auto i = 0; i < 8; ++i, u += 250ms)
|
| 2211 |
+
cout << u << " UTC\n";
|
| 2212 |
+
```
|
| 2213 |
+
|
| 2214 |
+
Produces this output:
|
| 2215 |
+
|
| 2216 |
+
``` text
|
| 2217 |
+
2015-06-30 23:59:59.500 UTC
|
| 2218 |
+
2015-06-30 23:59:59.750 UTC
|
| 2219 |
+
2015-06-30 23:59:60.000 UTC
|
| 2220 |
+
2015-06-30 23:59:60.250 UTC
|
| 2221 |
+
2015-06-30 23:59:60.500 UTC
|
| 2222 |
+
2015-06-30 23:59:60.750 UTC
|
| 2223 |
+
2015-07-01 00:00:00.000 UTC
|
| 2224 |
+
2015-07-01 00:00:00.250 UTC
|
| 2225 |
+
```
|
| 2226 |
+
|
| 2227 |
+
— *end example*]
|
| 2228 |
+
|
| 2229 |
+
``` cpp
|
| 2230 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2231 |
+
basic_istream<charT, traits>&
|
| 2232 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2233 |
+
utc_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2234 |
+
minutes* offset = nullptr);
|
| 2235 |
+
```
|
| 2236 |
+
|
| 2237 |
+
*Effects:* Attempts to parse the input stream `is` into the `utc_time`
|
| 2238 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2239 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2240 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2241 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2242 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2243 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2244 |
+
if `offset` is non-null. Additionally, the parsed offset will be
|
| 2245 |
+
subtracted from the successfully parsed timestamp prior to assigning
|
| 2246 |
+
that difference to `tp`.
|
| 2247 |
+
|
| 2248 |
+
*Returns:* `is`.
|
| 2249 |
+
|
| 2250 |
+
``` cpp
|
| 2251 |
+
struct leap_second_info {
|
| 2252 |
+
bool is_leap_second;
|
| 2253 |
+
seconds elapsed;
|
| 2254 |
+
};
|
| 2255 |
+
```
|
| 2256 |
+
|
| 2257 |
+
The type `leap_second_info` has data members and special members
|
| 2258 |
+
specified above. It has no base classes or members other than those
|
| 2259 |
+
specified.
|
| 2260 |
+
|
| 2261 |
+
``` cpp
|
| 2262 |
+
template<class Duration>
|
| 2263 |
+
leap_second_info get_leap_second_info(const utc_time<Duration>& ut);
|
| 2264 |
+
```
|
| 2265 |
+
|
| 2266 |
+
*Returns:* A `leap_second_info` `lsi`, where `lsi.is_leap_second` is
|
| 2267 |
+
`true` if `ut` is during a positive leap second insertion, and otherwise
|
| 2268 |
+
`false`. `lsi.elapsed` is the sum of leap seconds between 1970-01-01 and
|
| 2269 |
+
`ut`. If `lsi.is_leap_second` is `true`, the leap second referred to by
|
| 2270 |
+
`ut` is included in the sum.
|
| 2271 |
+
|
| 2272 |
+
### Class `tai_clock` <a id="time.clock.tai">[[time.clock.tai]]</a>
|
| 2273 |
+
|
| 2274 |
+
#### Overview <a id="time.clock.tai.overview">[[time.clock.tai.overview]]</a>
|
| 2275 |
+
|
| 2276 |
+
``` cpp
|
| 2277 |
+
namespace std::chrono {
|
| 2278 |
+
class tai_clock {
|
| 2279 |
+
public:
|
| 2280 |
+
using rep = a signed arithmetic type;
|
| 2281 |
+
using period = ratio<unspecified, unspecified>;
|
| 2282 |
+
using duration = chrono::duration<rep, period>;
|
| 2283 |
+
using time_point = chrono::time_point<tai_clock>;
|
| 2284 |
+
static constexpr bool is_steady = unspecified;
|
| 2285 |
+
|
| 2286 |
+
static time_point now();
|
| 2287 |
+
|
| 2288 |
+
template<class Duration>
|
| 2289 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2290 |
+
to_utc(const tai_time<Duration>&) noexcept;
|
| 2291 |
+
template<class Duration>
|
| 2292 |
+
static tai_time<common_type_t<Duration, seconds>>
|
| 2293 |
+
from_utc(const utc_time<Duration>&) noexcept;
|
| 2294 |
+
};
|
| 2295 |
+
}
|
| 2296 |
+
```
|
| 2297 |
+
|
| 2298 |
+
The clock `tai_clock` measures seconds since 1958-01-01 00:00:00 and is
|
| 2299 |
+
offset 10s ahead of UTC at this date. That is, 1958-01-01 00:00:00 TAI
|
| 2300 |
+
is equivalent to 1957-12-31 23:59:50 UTC. Leap seconds are not inserted
|
| 2301 |
+
into TAI. Therefore every time a leap second is inserted into UTC, UTC
|
| 2302 |
+
shifts another second with respect to TAI. For example by 2000-01-01
|
| 2303 |
+
there had been 22 positive and 0 negative leap seconds inserted so
|
| 2304 |
+
2000-01-01 00:00:00 UTC is equivalent to 2000-01-01 00:00:32 TAI (22s
|
| 2305 |
+
plus the initial 10s offset).
|
| 2306 |
+
|
| 2307 |
+
`tai_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 2308 |
+
guarantee that `tai_clock::now()` does not propagate an exception.
|
| 2309 |
+
|
| 2310 |
+
[*Note 1*: `noexcept(from_utc(utc_clock::now()))` is
|
| 2311 |
+
`false`. — *end note*]
|
| 2312 |
+
|
| 2313 |
+
#### Member functions <a id="time.clock.tai.members">[[time.clock.tai.members]]</a>
|
| 2314 |
+
|
| 2315 |
+
``` cpp
|
| 2316 |
+
static time_point now();
|
| 2317 |
+
```
|
| 2318 |
+
|
| 2319 |
+
*Returns:* `from_utc(utc_clock::now())`, or a more accurate value of
|
| 2320 |
+
`tai_time`.
|
| 2321 |
+
|
| 2322 |
+
``` cpp
|
| 2323 |
+
template<class Duration>
|
| 2324 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2325 |
+
to_utc(const tai_time<Duration>& t) noexcept;
|
| 2326 |
+
```
|
| 2327 |
+
|
| 2328 |
+
*Returns:*
|
| 2329 |
+
|
| 2330 |
+
``` cpp
|
| 2331 |
+
utc_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} - 378691210s
|
| 2332 |
+
```
|
| 2333 |
+
|
| 2334 |
+
[*Note 1*:
|
| 2335 |
+
|
| 2336 |
+
``` cpp
|
| 2337 |
+
378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s
|
| 2338 |
+
```
|
| 2339 |
+
|
| 2340 |
+
— *end note*]
|
| 2341 |
+
|
| 2342 |
+
``` cpp
|
| 2343 |
+
template<class Duration>
|
| 2344 |
+
static tai_time<common_type_t<Duration, seconds>>
|
| 2345 |
+
from_utc(const utc_time<Duration>& t) noexcept;
|
| 2346 |
+
```
|
| 2347 |
+
|
| 2348 |
+
*Returns:*
|
| 2349 |
+
|
| 2350 |
+
``` cpp
|
| 2351 |
+
tai_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} + 378691210s
|
| 2352 |
+
```
|
| 2353 |
+
|
| 2354 |
+
[*Note 2*:
|
| 2355 |
+
|
| 2356 |
+
``` cpp
|
| 2357 |
+
378691210s == sys_days{1970y/January/1} - sys_days{1958y/January/1} + 10s
|
| 2358 |
+
```
|
| 2359 |
+
|
| 2360 |
+
— *end note*]
|
| 2361 |
+
|
| 2362 |
+
#### Non-member functions <a id="time.clock.tai.nonmembers">[[time.clock.tai.nonmembers]]</a>
|
| 2363 |
+
|
| 2364 |
+
``` cpp
|
| 2365 |
+
template<class charT, class traits, class Duration>
|
| 2366 |
+
basic_ostream<charT, traits>&
|
| 2367 |
+
operator<<(basic_ostream<charT, traits>& os, const tai_time<Duration>& t);
|
| 2368 |
+
```
|
| 2369 |
+
|
| 2370 |
+
*Effects:* Equivalent to:
|
| 2371 |
+
|
| 2372 |
+
``` cpp
|
| 2373 |
+
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2374 |
+
```
|
| 2375 |
+
|
| 2376 |
+
[*Example 1*:
|
| 2377 |
+
|
| 2378 |
+
``` cpp
|
| 2379 |
+
auto st = sys_days{2000y/January/1};
|
| 2380 |
+
auto tt = clock_cast<tai_clock>(st);
|
| 2381 |
+
cout << format("{0:%F %T %Z} == {1:%F %T %Z}\n", st, tt);
|
| 2382 |
+
```
|
| 2383 |
+
|
| 2384 |
+
Produces this output:
|
| 2385 |
+
|
| 2386 |
+
``` text
|
| 2387 |
+
2000-01-01 00:00:00 UTC == 2000-01-01 00:00:32 TAI
|
| 2388 |
+
```
|
| 2389 |
+
|
| 2390 |
+
— *end example*]
|
| 2391 |
+
|
| 2392 |
+
``` cpp
|
| 2393 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2394 |
+
basic_istream<charT, traits>&
|
| 2395 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2396 |
+
tai_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2397 |
+
minutes* offset = nullptr);
|
| 2398 |
+
```
|
| 2399 |
+
|
| 2400 |
+
*Effects:* Attempts to parse the input stream `is` into the `tai_time`
|
| 2401 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2402 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2403 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2404 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2405 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2406 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2407 |
+
if `offset` is non-null. Additionally, the parsed offset will be
|
| 2408 |
+
subtracted from the successfully parsed timestamp prior to assigning
|
| 2409 |
+
that difference to `tp`.
|
| 2410 |
+
|
| 2411 |
+
*Returns:* `is`.
|
| 2412 |
+
|
| 2413 |
+
### Class `gps_clock` <a id="time.clock.gps">[[time.clock.gps]]</a>
|
| 2414 |
+
|
| 2415 |
+
#### Overview <a id="time.clock.gps.overview">[[time.clock.gps.overview]]</a>
|
| 2416 |
+
|
| 2417 |
+
``` cpp
|
| 2418 |
+
namespace std::chrono {
|
| 2419 |
+
class gps_clock {
|
| 2420 |
+
public:
|
| 2421 |
+
using rep = a signed arithmetic type;
|
| 2422 |
+
using period = ratio<unspecified, unspecified>;
|
| 2423 |
+
using duration = chrono::duration<rep, period>;
|
| 2424 |
+
using time_point = chrono::time_point<gps_clock>;
|
| 2425 |
+
static constexpr bool is_steady = unspecified;
|
| 2426 |
+
|
| 2427 |
+
static time_point now();
|
| 2428 |
+
|
| 2429 |
+
template<class Duration>
|
| 2430 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2431 |
+
to_utc(const gps_time<Duration>&) noexcept;
|
| 2432 |
+
template<class Duration>
|
| 2433 |
+
static gps_time<common_type_t<Duration, seconds>>
|
| 2434 |
+
from_utc(const utc_time<Duration>&) noexcept;
|
| 2435 |
+
};
|
| 2436 |
+
}
|
| 2437 |
+
```
|
| 2438 |
+
|
| 2439 |
+
The clock `gps_clock` measures seconds since the first Sunday of
|
| 2440 |
+
January, 1980 00:00:00 UTC. Leap seconds are not inserted into GPS.
|
| 2441 |
+
Therefore every time a leap second is inserted into UTC, UTC shifts
|
| 2442 |
+
another second with respect to GPS. Aside from the offset from
|
| 2443 |
+
`1958y/January/1` to `1980y/January/Sunday[1]`, GPS is behind TAI by 19s
|
| 2444 |
+
due to the 10s offset between 1958 and 1970 and the additional 9 leap
|
| 2445 |
+
seconds inserted between 1970 and 1980.
|
| 2446 |
+
|
| 2447 |
+
`gps_clock` is not a *Cpp17TrivialClock* unless the implementation can
|
| 2448 |
+
guarantee that `gps_clock::now()` does not propagate an exception.
|
| 2449 |
+
|
| 2450 |
+
[*Note 1*: `noexcept(from_utc(utc_clock::now()))` is
|
| 2451 |
+
`false`. — *end note*]
|
| 2452 |
+
|
| 2453 |
+
#### Member functions <a id="time.clock.gps.members">[[time.clock.gps.members]]</a>
|
| 2454 |
+
|
| 2455 |
+
``` cpp
|
| 2456 |
+
static time_point now();
|
| 2457 |
+
```
|
| 2458 |
+
|
| 2459 |
+
*Returns:* `from_utc(utc_clock::now())`, or a more accurate value of
|
| 2460 |
+
`gps_time`.
|
| 2461 |
+
|
| 2462 |
+
``` cpp
|
| 2463 |
+
template<class Duration>
|
| 2464 |
+
static utc_time<common_type_t<Duration, seconds>>
|
| 2465 |
+
to_utc(const gps_time<Duration>& t) noexcept;
|
| 2466 |
+
```
|
| 2467 |
+
|
| 2468 |
+
*Returns:*
|
| 2469 |
+
|
| 2470 |
+
``` cpp
|
| 2471 |
+
gps_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} + 315964809s
|
| 2472 |
+
```
|
| 2473 |
+
|
| 2474 |
+
[*Note 1*:
|
| 2475 |
+
|
| 2476 |
+
``` cpp
|
| 2477 |
+
315964809s == sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1} + 9s
|
| 2478 |
+
```
|
| 2479 |
+
|
| 2480 |
+
— *end note*]
|
| 2481 |
+
|
| 2482 |
+
``` cpp
|
| 2483 |
+
template<class Duration>
|
| 2484 |
+
static gps_time<common_type_t<Duration, seconds>>
|
| 2485 |
+
from_utc(const utc_time<Duration>& t) noexcept;
|
| 2486 |
+
```
|
| 2487 |
+
|
| 2488 |
+
*Returns:*
|
| 2489 |
+
|
| 2490 |
+
``` cpp
|
| 2491 |
+
gps_time<common_type_t<Duration, seconds>>{t.time_since_epoch()} - 315964809s
|
| 2492 |
+
```
|
| 2493 |
+
|
| 2494 |
+
[*Note 2*:
|
| 2495 |
+
|
| 2496 |
+
``` cpp
|
| 2497 |
+
315964809s == sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1} + 9s
|
| 2498 |
+
```
|
| 2499 |
+
|
| 2500 |
+
— *end note*]
|
| 2501 |
+
|
| 2502 |
+
#### Non-member functions <a id="time.clock.gps.nonmembers">[[time.clock.gps.nonmembers]]</a>
|
| 2503 |
+
|
| 2504 |
+
``` cpp
|
| 2505 |
+
template<class charT, class traits, class Duration>
|
| 2506 |
+
basic_ostream<charT, traits>&
|
| 2507 |
+
operator<<(basic_ostream<charT, traits>& os, const gps_time<Duration>& t);
|
| 2508 |
+
```
|
| 2509 |
+
|
| 2510 |
+
*Effects:* Equivalent to:
|
| 2511 |
+
|
| 2512 |
+
``` cpp
|
| 2513 |
+
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2514 |
+
```
|
| 2515 |
+
|
| 2516 |
+
[*Example 1*:
|
| 2517 |
+
|
| 2518 |
+
``` cpp
|
| 2519 |
+
auto st = sys_days{2000y/January/1};
|
| 2520 |
+
auto gt = clock_cast<gps_clock>(st);
|
| 2521 |
+
cout << format("{0:%F %T %Z} == {1:%F %T %Z}\n", st, gt);
|
| 2522 |
+
```
|
| 2523 |
+
|
| 2524 |
+
Produces this output:
|
| 2525 |
+
|
| 2526 |
+
``` text
|
| 2527 |
+
2000-01-01 00:00:00 UTC == 2000-01-01 00:00:13 GPS
|
| 2528 |
+
```
|
| 2529 |
+
|
| 2530 |
+
— *end example*]
|
| 2531 |
+
|
| 2532 |
+
``` cpp
|
| 2533 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2534 |
+
basic_istream<charT, traits>&
|
| 2535 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2536 |
+
gps_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2537 |
+
minutes* offset = nullptr);
|
| 2538 |
+
```
|
| 2539 |
+
|
| 2540 |
+
*Effects:* Attempts to parse the input stream `is` into the `gps_time`
|
| 2541 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2542 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2543 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2544 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2545 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2546 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2547 |
+
if `offset` is non-null. Additionally, the parsed offset will be
|
| 2548 |
+
subtracted from the successfully parsed timestamp prior to assigning
|
| 2549 |
+
that difference to `tp`.
|
| 2550 |
+
|
| 2551 |
+
*Returns:* `is`.
|
| 2552 |
+
|
| 2553 |
+
### Type `file_clock` <a id="time.clock.file">[[time.clock.file]]</a>
|
| 2554 |
+
|
| 2555 |
+
#### Overview <a id="time.clock.file.overview">[[time.clock.file.overview]]</a>
|
| 2556 |
+
|
| 2557 |
+
``` cpp
|
| 2558 |
+
namespace std::chrono {
|
| 2559 |
+
using file_clock = see below;
|
| 2560 |
+
}
|
| 2561 |
+
```
|
| 2562 |
+
|
| 2563 |
+
`file_clock` is an alias for a type meeting the *Cpp17TrivialClock*
|
| 2564 |
+
requirements [[time.clock.req]], and using a signed arithmetic type for
|
| 2565 |
+
`file_clock::rep`. `file_clock` is used to create the `time_point`
|
| 2566 |
+
system used for `file_time_type` [[filesystems]]. Its epoch is
|
| 2567 |
+
unspecified, and `noexcept(file_clock::now())` is `true`.
|
| 2568 |
+
|
| 2569 |
+
[*Note 1*: The type that `file_clock` denotes may be in a different
|
| 2570 |
+
namespace than `std::chrono`, such as `std::filesystem`. — *end note*]
|
| 2571 |
+
|
| 2572 |
+
#### Member functions <a id="time.clock.file.members">[[time.clock.file.members]]</a>
|
| 2573 |
+
|
| 2574 |
+
The type denoted by `file_clock` provides precisely one of the following
|
| 2575 |
+
two sets of static member functions:
|
| 2576 |
+
|
| 2577 |
+
``` cpp
|
| 2578 |
+
template<class Duration>
|
| 2579 |
+
static sys_time<see below>
|
| 2580 |
+
to_sys(const file_time<Duration>&);
|
| 2581 |
+
template<class Duration>
|
| 2582 |
+
static file_time<see below>
|
| 2583 |
+
from_sys(const sys_time<Duration>&);
|
| 2584 |
+
```
|
| 2585 |
+
|
| 2586 |
+
or:
|
| 2587 |
+
|
| 2588 |
+
``` cpp
|
| 2589 |
+
template<class Duration>
|
| 2590 |
+
static utc_time<see below>
|
| 2591 |
+
to_utc(const file_time<Duration>&);
|
| 2592 |
+
template<class Duration>
|
| 2593 |
+
static file_time<see below>
|
| 2594 |
+
from_utc(const utc_time<Duration>&);
|
| 2595 |
+
```
|
| 2596 |
+
|
| 2597 |
+
These member functions shall provide `time_point` conversions consistent
|
| 2598 |
+
with those specified by `utc_clock`, `tai_clock`, and `gps_clock`. The
|
| 2599 |
+
`Duration` of the resultant `time_point` is computed from the `Duration`
|
| 2600 |
+
of the input `time_point`.
|
| 2601 |
+
|
| 2602 |
+
#### Non-member functions <a id="time.clock.file.nonmembers">[[time.clock.file.nonmembers]]</a>
|
| 2603 |
+
|
| 2604 |
+
``` cpp
|
| 2605 |
+
template<class charT, class traits, class Duration>
|
| 2606 |
+
basic_ostream<charT, traits>&
|
| 2607 |
+
operator<<(basic_ostream<charT, traits>& os, const file_time<Duration>& t);
|
| 2608 |
+
```
|
| 2609 |
+
|
| 2610 |
+
*Effects:* Equivalent to:
|
| 2611 |
+
|
| 2612 |
+
``` cpp
|
| 2613 |
+
return os << format(STATICALLY-WIDEN<charT>("{:%F %T}"), t);
|
| 2614 |
+
```
|
| 2615 |
+
|
| 2616 |
+
``` cpp
|
| 2617 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2618 |
+
basic_istream<charT, traits>&
|
| 2619 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2620 |
+
file_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2621 |
+
minutes* offset = nullptr);
|
| 2622 |
+
```
|
| 2623 |
+
|
| 2624 |
+
*Effects:* Attempts to parse the input stream `is` into the `file_time`
|
| 2625 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2626 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2627 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2628 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2629 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2630 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2631 |
+
if `offset` is non-null. Additionally, the parsed offset will be
|
| 2632 |
+
subtracted from the successfully parsed timestamp prior to assigning
|
| 2633 |
+
that difference to `tp`.
|
| 2634 |
+
|
| 2635 |
+
*Returns:* `is`.
|
| 2636 |
+
|
| 2637 |
+
### Class `steady_clock` <a id="time.clock.steady">[[time.clock.steady]]</a>
|
| 2638 |
+
|
| 2639 |
+
``` cpp
|
| 2640 |
+
namespace std::chrono {
|
| 2641 |
+
class steady_clock {
|
| 2642 |
+
public:
|
| 2643 |
+
using rep = unspecified;
|
| 2644 |
+
using period = ratio<unspecified, unspecified{}>;
|
| 2645 |
+
using duration = chrono::duration<rep, period>;
|
| 2646 |
+
using time_point = chrono::time_point<unspecified, duration>;
|
| 2647 |
+
static constexpr bool is_steady = true;
|
| 2648 |
+
|
| 2649 |
+
static time_point now() noexcept;
|
| 2650 |
+
};
|
| 2651 |
+
}
|
| 2652 |
+
```
|
| 2653 |
|
| 2654 |
Objects of class `steady_clock` represent clocks for which values of
|
| 2655 |
`time_point` never decrease as physical time advances and for which
|
| 2656 |
values of `time_point` advance at a steady rate relative to real time.
|
| 2657 |
That is, the clock may not be adjusted.
|
| 2658 |
|
| 2659 |
+
### Class `high_resolution_clock` <a id="time.clock.hires">[[time.clock.hires]]</a>
|
| 2660 |
+
|
| 2661 |
``` cpp
|
| 2662 |
+
namespace std::chrono {
|
| 2663 |
+
class high_resolution_clock {
|
| 2664 |
public:
|
| 2665 |
using rep = unspecified;
|
| 2666 |
using period = ratio<unspecified, unspecified{}>;
|
| 2667 |
using duration = chrono::duration<rep, period>;
|
| 2668 |
using time_point = chrono::time_point<unspecified, duration>;
|
| 2669 |
+
static constexpr bool is_steady = unspecified;
|
| 2670 |
|
| 2671 |
static time_point now() noexcept;
|
| 2672 |
};
|
| 2673 |
+
}
|
| 2674 |
```
|
| 2675 |
|
|
|
|
|
|
|
| 2676 |
Objects of class `high_resolution_clock` represent clocks with the
|
| 2677 |
shortest tick period. `high_resolution_clock` may be a synonym for
|
| 2678 |
`system_clock` or `steady_clock`.
|
| 2679 |
|
| 2680 |
+
### Local time <a id="time.clock.local">[[time.clock.local]]</a>
|
| 2681 |
+
|
| 2682 |
+
The family of time points denoted by `local_time<Duration>` are based on
|
| 2683 |
+
the pseudo clock `local_t`. `local_t` has no member `now()` and thus
|
| 2684 |
+
does not meet the clock requirements. Nevertheless
|
| 2685 |
+
`local_time<Duration>` serves the vital role of representing local time
|
| 2686 |
+
with respect to a not-yet-specified time zone. Aside from being able to
|
| 2687 |
+
get the current time, the complete `time_point` algebra is available for
|
| 2688 |
+
`local_time<Duration>` (just as for `sys_time<Duration>`).
|
| 2689 |
+
|
| 2690 |
+
``` cpp
|
| 2691 |
+
template<class charT, class traits, class Duration>
|
| 2692 |
+
basic_ostream<charT, traits>&
|
| 2693 |
+
operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& lt);
|
| 2694 |
+
```
|
| 2695 |
+
|
| 2696 |
+
*Effects:*
|
| 2697 |
+
|
| 2698 |
+
``` cpp
|
| 2699 |
+
os << sys_time<Duration>{lt.time_since_epoch()};
|
| 2700 |
+
```
|
| 2701 |
+
|
| 2702 |
+
*Returns:* `os`.
|
| 2703 |
+
|
| 2704 |
+
``` cpp
|
| 2705 |
+
template<class charT, class traits, class Duration, class Alloc = allocator<charT>>
|
| 2706 |
+
basic_istream<charT, traits>&
|
| 2707 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 2708 |
+
local_time<Duration>& tp, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 2709 |
+
minutes* offset = nullptr);
|
| 2710 |
+
```
|
| 2711 |
+
|
| 2712 |
+
*Effects:* Attempts to parse the input stream `is` into the `local_time`
|
| 2713 |
+
`tp` using the format flags given in the NTCTS `fmt` as specified in
|
| 2714 |
+
[[time.parse]]. If the parse fails to decode a valid date,
|
| 2715 |
+
`is.setstate(ios_base::failbit)` is called and `tp` is not modified. If
|
| 2716 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 2717 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 2718 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 2719 |
+
if `offset` is non-null.
|
| 2720 |
+
|
| 2721 |
+
*Returns:* `is`.
|
| 2722 |
+
|
| 2723 |
+
### `time_point` conversions <a id="time.clock.cast">[[time.clock.cast]]</a>
|
| 2724 |
+
|
| 2725 |
+
#### Class template `clock_time_conversion` <a id="time.clock.conv">[[time.clock.conv]]</a>
|
| 2726 |
+
|
| 2727 |
+
``` cpp
|
| 2728 |
+
namespace std::chrono {
|
| 2729 |
+
template<class DestClock, class SourceClock>
|
| 2730 |
+
struct clock_time_conversion {};
|
| 2731 |
+
}
|
| 2732 |
+
```
|
| 2733 |
+
|
| 2734 |
+
`clock_time_conversion` serves as a trait which can be used to specify
|
| 2735 |
+
how to convert a source `time_point` of type
|
| 2736 |
+
`time_point<SourceClock, Duration>` to a destination `time_point` of
|
| 2737 |
+
type `time_point<DestClock, Duration>` via a specialization:
|
| 2738 |
+
`clock_time_conversion<DestClock, SourceClock>`. A specialization of
|
| 2739 |
+
`clock_time_conversion<DestClock, SourceClock>` shall provide a
|
| 2740 |
+
const-qualified `operator()` that takes a parameter of type
|
| 2741 |
+
`time_point<SourceClock, Duration>` and returns a
|
| 2742 |
+
`time_point<DestClock, OtherDuration>` representing an equivalent point
|
| 2743 |
+
in time. `OtherDuration` is a `chrono::duration` whose specialization is
|
| 2744 |
+
computed from the input `Duration` in a manner which can vary for each
|
| 2745 |
+
`clock_time_conversion` specialization. A program may specialize
|
| 2746 |
+
`clock_time_conversion` if at least one of the template parameters is a
|
| 2747 |
+
user-defined clock type.
|
| 2748 |
+
|
| 2749 |
+
Several specializations are provided by the implementation, as described
|
| 2750 |
+
in [[time.clock.cast.id]], [[time.clock.cast.sys.utc]],
|
| 2751 |
+
[[time.clock.cast.sys]], and [[time.clock.cast.utc]].
|
| 2752 |
+
|
| 2753 |
+
#### Identity conversions <a id="time.clock.cast.id">[[time.clock.cast.id]]</a>
|
| 2754 |
+
|
| 2755 |
+
``` cpp
|
| 2756 |
+
template<class Clock>
|
| 2757 |
+
struct clock_time_conversion<Clock, Clock> {
|
| 2758 |
+
template<class Duration>
|
| 2759 |
+
time_point<Clock, Duration>
|
| 2760 |
+
operator()(const time_point<Clock, Duration>& t) const;
|
| 2761 |
+
};
|
| 2762 |
+
```
|
| 2763 |
+
|
| 2764 |
+
``` cpp
|
| 2765 |
+
template<class Duration>
|
| 2766 |
+
time_point<Clock, Duration>
|
| 2767 |
+
operator()(const time_point<Clock, Duration>& t) const;
|
| 2768 |
+
```
|
| 2769 |
+
|
| 2770 |
+
*Returns:* `t`.
|
| 2771 |
+
|
| 2772 |
+
``` cpp
|
| 2773 |
+
template<>
|
| 2774 |
+
struct clock_time_conversion<system_clock, system_clock> {
|
| 2775 |
+
template<class Duration>
|
| 2776 |
+
sys_time<Duration>
|
| 2777 |
+
operator()(const sys_time<Duration>& t) const;
|
| 2778 |
+
};
|
| 2779 |
+
```
|
| 2780 |
+
|
| 2781 |
+
``` cpp
|
| 2782 |
+
template<class Duration>
|
| 2783 |
+
sys_time<Duration>
|
| 2784 |
+
operator()(const sys_time<Duration>& t) const;
|
| 2785 |
+
```
|
| 2786 |
+
|
| 2787 |
+
*Returns:* `t`.
|
| 2788 |
+
|
| 2789 |
+
``` cpp
|
| 2790 |
+
template<>
|
| 2791 |
+
struct clock_time_conversion<utc_clock, utc_clock> {
|
| 2792 |
+
template<class Duration>
|
| 2793 |
+
utc_time<Duration>
|
| 2794 |
+
operator()(const utc_time<Duration>& t) const;
|
| 2795 |
+
};
|
| 2796 |
+
```
|
| 2797 |
+
|
| 2798 |
+
``` cpp
|
| 2799 |
+
template<class Duration>
|
| 2800 |
+
utc_time<Duration>
|
| 2801 |
+
operator()(const utc_time<Duration>& t) const;
|
| 2802 |
+
```
|
| 2803 |
+
|
| 2804 |
+
*Returns:* `t`.
|
| 2805 |
+
|
| 2806 |
+
#### Conversions between `system_clock` and `utc_clock` <a id="time.clock.cast.sys.utc">[[time.clock.cast.sys.utc]]</a>
|
| 2807 |
+
|
| 2808 |
+
``` cpp
|
| 2809 |
+
template<>
|
| 2810 |
+
struct clock_time_conversion<utc_clock, system_clock> {
|
| 2811 |
+
template<class Duration>
|
| 2812 |
+
utc_time<common_type_t<Duration, seconds>>
|
| 2813 |
+
operator()(const sys_time<Duration>& t) const;
|
| 2814 |
+
};
|
| 2815 |
+
```
|
| 2816 |
+
|
| 2817 |
+
``` cpp
|
| 2818 |
+
template<class Duration>
|
| 2819 |
+
utc_time<common_type_t<Duration, seconds>>
|
| 2820 |
+
operator()(const sys_time<Duration>& t) const;
|
| 2821 |
+
```
|
| 2822 |
+
|
| 2823 |
+
*Returns:* `utc_clock::from_sys(t)`.
|
| 2824 |
+
|
| 2825 |
+
``` cpp
|
| 2826 |
+
template<>
|
| 2827 |
+
struct clock_time_conversion<system_clock, utc_clock> {
|
| 2828 |
+
template<class Duration>
|
| 2829 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 2830 |
+
operator()(const utc_time<Duration>& t) const;
|
| 2831 |
+
};
|
| 2832 |
+
```
|
| 2833 |
+
|
| 2834 |
+
``` cpp
|
| 2835 |
+
template<class Duration>
|
| 2836 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 2837 |
+
operator()(const utc_time<Duration>& t) const;
|
| 2838 |
+
```
|
| 2839 |
+
|
| 2840 |
+
*Returns:* `utc_clock::to_sys(t)`.
|
| 2841 |
+
|
| 2842 |
+
#### Conversions between `system_clock` and other clocks <a id="time.clock.cast.sys">[[time.clock.cast.sys]]</a>
|
| 2843 |
+
|
| 2844 |
+
``` cpp
|
| 2845 |
+
template<class SourceClock>
|
| 2846 |
+
struct clock_time_conversion<system_clock, SourceClock> {
|
| 2847 |
+
template<class Duration>
|
| 2848 |
+
auto operator()(const time_point<SourceClock, Duration>& t) const
|
| 2849 |
+
-> decltype(SourceClock::to_sys(t));
|
| 2850 |
+
};
|
| 2851 |
+
```
|
| 2852 |
+
|
| 2853 |
+
``` cpp
|
| 2854 |
+
template<class Duration>
|
| 2855 |
+
auto operator()(const time_point<SourceClock, Duration>& t) const
|
| 2856 |
+
-> decltype(SourceClock::to_sys(t));
|
| 2857 |
+
```
|
| 2858 |
+
|
| 2859 |
+
*Constraints:* `SourceClock::to_sys(t)` is well-formed.
|
| 2860 |
+
|
| 2861 |
+
*Mandates:* `SourceClock::to_sys(t)` returns a `sys_time<Duration>`,
|
| 2862 |
+
where `Duration` is a valid `chrono::duration` specialization.
|
| 2863 |
+
|
| 2864 |
+
*Returns:* `SourceClock::to_sys(t)`.
|
| 2865 |
+
|
| 2866 |
+
``` cpp
|
| 2867 |
+
template<class DestClock>
|
| 2868 |
+
struct clock_time_conversion<DestClock, system_clock> {
|
| 2869 |
+
template<class Duration>
|
| 2870 |
+
auto operator()(const sys_time<Duration>& t) const
|
| 2871 |
+
-> decltype(DestClock::from_sys(t));
|
| 2872 |
+
};
|
| 2873 |
+
```
|
| 2874 |
+
|
| 2875 |
+
``` cpp
|
| 2876 |
+
template<class Duration>
|
| 2877 |
+
auto operator()(const sys_time<Duration>& t) const
|
| 2878 |
+
-> decltype(DestClock::from_sys(t));
|
| 2879 |
+
```
|
| 2880 |
+
|
| 2881 |
+
*Constraints:* `DestClock::from_sys(t)` is well-formed.
|
| 2882 |
+
|
| 2883 |
+
*Mandates:* `DestClock::from_sys(t)` returns a
|
| 2884 |
+
`time_point<DestClock, Duration>`, where `Duration` is a valid
|
| 2885 |
+
`chrono::duration` specialization.
|
| 2886 |
+
|
| 2887 |
+
*Returns:* `DestClock::from_sys(t)`.
|
| 2888 |
+
|
| 2889 |
+
#### Conversions between `utc_clock` and other clocks <a id="time.clock.cast.utc">[[time.clock.cast.utc]]</a>
|
| 2890 |
+
|
| 2891 |
+
``` cpp
|
| 2892 |
+
template<class SourceClock>
|
| 2893 |
+
struct clock_time_conversion<utc_clock, SourceClock> {
|
| 2894 |
+
template<class Duration>
|
| 2895 |
+
auto operator()(const time_point<SourceClock, Duration>& t) const
|
| 2896 |
+
-> decltype(SourceClock::to_utc(t));
|
| 2897 |
+
};
|
| 2898 |
+
```
|
| 2899 |
+
|
| 2900 |
+
``` cpp
|
| 2901 |
+
template<class Duration>
|
| 2902 |
+
auto operator()(const time_point<SourceClock, Duration>& t) const
|
| 2903 |
+
-> decltype(SourceClock::to_utc(t));
|
| 2904 |
+
```
|
| 2905 |
+
|
| 2906 |
+
*Constraints:* `SourceClock::to_utc(t)` is well-formed.
|
| 2907 |
+
|
| 2908 |
+
*Mandates:* `SourceClock::to_utc(t)` returns a `utc_time<Duration>`,
|
| 2909 |
+
where `Duration` is a valid `chrono::duration` specialization.
|
| 2910 |
+
|
| 2911 |
+
*Returns:* `SourceClock::to_utc(t)`.
|
| 2912 |
+
|
| 2913 |
+
``` cpp
|
| 2914 |
+
template<class DestClock>
|
| 2915 |
+
struct clock_time_conversion<DestClock, utc_clock> {
|
| 2916 |
+
template<class Duration>
|
| 2917 |
+
auto operator()(const utc_time<Duration>& t) const
|
| 2918 |
+
-> decltype(DestClock::from_utc(t));
|
| 2919 |
+
};
|
| 2920 |
+
```
|
| 2921 |
+
|
| 2922 |
+
``` cpp
|
| 2923 |
+
template<class Duration>
|
| 2924 |
+
auto operator()(const utc_time<Duration>& t) const
|
| 2925 |
+
-> decltype(DestClock::from_utc(t));
|
| 2926 |
+
```
|
| 2927 |
+
|
| 2928 |
+
*Constraints:* `DestClock::from_utc(t)` is well-formed.
|
| 2929 |
+
|
| 2930 |
+
*Mandates:* `DestClock::from_utc(t)` returns a
|
| 2931 |
+
`time_point<DestClock, Duration>`, where `Duration` is a valid
|
| 2932 |
+
`chrono::duration` specialization.
|
| 2933 |
+
|
| 2934 |
+
*Returns:* `DestClock::from_utc(t)`.
|
| 2935 |
+
|
| 2936 |
+
#### Function template `clock_cast` <a id="time.clock.cast.fn">[[time.clock.cast.fn]]</a>
|
| 2937 |
+
|
| 2938 |
+
``` cpp
|
| 2939 |
+
template<class DestClock, class SourceClock, class Duration>
|
| 2940 |
+
auto clock_cast(const time_point<SourceClock, Duration>& t);
|
| 2941 |
+
```
|
| 2942 |
+
|
| 2943 |
+
*Constraints:* At least one of the following clock time conversion
|
| 2944 |
+
expressions is well-formed:
|
| 2945 |
+
|
| 2946 |
+
- ``` cpp
|
| 2947 |
+
clock_time_conversion<DestClock, SourceClock>{}(t)
|
| 2948 |
+
```
|
| 2949 |
+
|
| 2950 |
+
- ``` cpp
|
| 2951 |
+
clock_time_conversion<DestClock, system_clock>{}(
|
| 2952 |
+
clock_time_conversion<system_clock, SourceClock>{}(t))
|
| 2953 |
+
```
|
| 2954 |
+
|
| 2955 |
+
- ``` cpp
|
| 2956 |
+
clock_time_conversion<DestClock, utc_clock>{}(
|
| 2957 |
+
clock_time_conversion<utc_clock, SourceClock>{}(t))
|
| 2958 |
+
```
|
| 2959 |
+
|
| 2960 |
+
- ``` cpp
|
| 2961 |
+
clock_time_conversion<DestClock, utc_clock>{}(
|
| 2962 |
+
clock_time_conversion<utc_clock, system_clock>{}(
|
| 2963 |
+
clock_time_conversion<system_clock, SourceClock>{}(t)))
|
| 2964 |
+
```
|
| 2965 |
+
|
| 2966 |
+
- ``` cpp
|
| 2967 |
+
clock_time_conversion<DestClock, system_clock>{}(
|
| 2968 |
+
clock_time_conversion<system_clock, utc_clock>{}(
|
| 2969 |
+
clock_time_conversion<utc_clock, SourceClock>{}(t)))
|
| 2970 |
+
```
|
| 2971 |
+
|
| 2972 |
+
A clock time conversion expression is considered better than another
|
| 2973 |
+
clock time conversion expression if it involves fewer `operator()` calls
|
| 2974 |
+
on `clock_time_conversion` specializations.
|
| 2975 |
+
|
| 2976 |
+
*Mandates:* Among the well-formed clock time conversion expressions from
|
| 2977 |
+
the above list, there is a unique best expression.
|
| 2978 |
+
|
| 2979 |
+
*Returns:* The best well-formed clock time conversion expression in the
|
| 2980 |
+
above list.
|
| 2981 |
+
|
| 2982 |
+
## The civil calendar <a id="time.cal">[[time.cal]]</a>
|
| 2983 |
+
|
| 2984 |
+
### In general <a id="time.cal.general">[[time.cal.general]]</a>
|
| 2985 |
+
|
| 2986 |
+
The types in [[time.cal]] describe the civil (Gregorian) calendar and
|
| 2987 |
+
its relationship to `sys_days` and `local_days`.
|
| 2988 |
+
|
| 2989 |
+
### Class `last_spec` <a id="time.cal.last">[[time.cal.last]]</a>
|
| 2990 |
+
|
| 2991 |
+
``` cpp
|
| 2992 |
+
namespace std::chrono {
|
| 2993 |
+
struct last_spec {
|
| 2994 |
+
explicit last_spec() = default;
|
| 2995 |
+
};
|
| 2996 |
+
}
|
| 2997 |
+
```
|
| 2998 |
+
|
| 2999 |
+
The type `last_spec` is used in conjunction with other calendar types to
|
| 3000 |
+
specify the last in a sequence. For example, depending on context, it
|
| 3001 |
+
can represent the last day of a month, or the last day of the week of a
|
| 3002 |
+
month.
|
| 3003 |
+
|
| 3004 |
+
### Class `day` <a id="time.cal.day">[[time.cal.day]]</a>
|
| 3005 |
+
|
| 3006 |
+
#### Overview <a id="time.cal.day.overview">[[time.cal.day.overview]]</a>
|
| 3007 |
+
|
| 3008 |
+
``` cpp
|
| 3009 |
+
namespace std::chrono {
|
| 3010 |
+
class day {
|
| 3011 |
+
unsigned char d_; // exposition only
|
| 3012 |
+
public:
|
| 3013 |
+
day() = default;
|
| 3014 |
+
constexpr explicit day(unsigned d) noexcept;
|
| 3015 |
+
|
| 3016 |
+
constexpr day& operator++() noexcept;
|
| 3017 |
+
constexpr day operator++(int) noexcept;
|
| 3018 |
+
constexpr day& operator--() noexcept;
|
| 3019 |
+
constexpr day operator--(int) noexcept;
|
| 3020 |
+
|
| 3021 |
+
constexpr day& operator+=(const days& d) noexcept;
|
| 3022 |
+
constexpr day& operator-=(const days& d) noexcept;
|
| 3023 |
+
|
| 3024 |
+
constexpr explicit operator unsigned() const noexcept;
|
| 3025 |
+
constexpr bool ok() const noexcept;
|
| 3026 |
+
};
|
| 3027 |
+
}
|
| 3028 |
+
```
|
| 3029 |
+
|
| 3030 |
+
`day` represents a day of a month. It normally holds values in the range
|
| 3031 |
+
1 to 31, but may hold non-negative values outside this range. It can be
|
| 3032 |
+
constructed with any `unsigned` value, which will be subsequently
|
| 3033 |
+
truncated to fit into `day`’s unspecified internal storage. `day` meets
|
| 3034 |
+
the *Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
|
| 3035 |
+
*Cpp17LessThanComparable* ([[cpp17.lessthancomparable]]) requirements,
|
| 3036 |
+
and participates in basic arithmetic with `days` objects, which
|
| 3037 |
+
represent a difference between two `day` objects.
|
| 3038 |
+
|
| 3039 |
+
`day` is a trivially copyable and standard-layout class type.
|
| 3040 |
+
|
| 3041 |
+
#### Member functions <a id="time.cal.day.members">[[time.cal.day.members]]</a>
|
| 3042 |
+
|
| 3043 |
+
``` cpp
|
| 3044 |
+
constexpr explicit day(unsigned d) noexcept;
|
| 3045 |
+
```
|
| 3046 |
+
|
| 3047 |
+
*Effects:* Initializes `d_` with `d`. The value held is unspecified if
|
| 3048 |
+
`d` is not in the range \[`0`, `255`\].
|
| 3049 |
+
|
| 3050 |
+
``` cpp
|
| 3051 |
+
constexpr day& operator++() noexcept;
|
| 3052 |
+
```
|
| 3053 |
+
|
| 3054 |
+
*Effects:* `++d_`.
|
| 3055 |
+
|
| 3056 |
+
*Returns:* `*this`.
|
| 3057 |
+
|
| 3058 |
+
``` cpp
|
| 3059 |
+
constexpr day operator++(int) noexcept;
|
| 3060 |
+
```
|
| 3061 |
+
|
| 3062 |
+
*Effects:* `++(*this)`.
|
| 3063 |
+
|
| 3064 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3065 |
+
function.
|
| 3066 |
+
|
| 3067 |
+
``` cpp
|
| 3068 |
+
constexpr day& operator--() noexcept;
|
| 3069 |
+
```
|
| 3070 |
+
|
| 3071 |
+
*Effects:* Equivalent to: `–d_`.
|
| 3072 |
+
|
| 3073 |
+
*Returns:* `*this`.
|
| 3074 |
+
|
| 3075 |
+
``` cpp
|
| 3076 |
+
constexpr day operator--(int) noexcept;
|
| 3077 |
+
```
|
| 3078 |
+
|
| 3079 |
+
*Effects:* `–(*this)`.
|
| 3080 |
+
|
| 3081 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3082 |
+
function.
|
| 3083 |
+
|
| 3084 |
+
``` cpp
|
| 3085 |
+
constexpr day& operator+=(const days& d) noexcept;
|
| 3086 |
+
```
|
| 3087 |
+
|
| 3088 |
+
*Effects:* `*this = *this + d`.
|
| 3089 |
+
|
| 3090 |
+
*Returns:* `*this`.
|
| 3091 |
+
|
| 3092 |
+
``` cpp
|
| 3093 |
+
constexpr day& operator-=(const days& d) noexcept;
|
| 3094 |
+
```
|
| 3095 |
+
|
| 3096 |
+
*Effects:* `*this = *this - d`.
|
| 3097 |
+
|
| 3098 |
+
*Returns:* `*this`.
|
| 3099 |
+
|
| 3100 |
+
``` cpp
|
| 3101 |
+
constexpr explicit operator unsigned() const noexcept;
|
| 3102 |
+
```
|
| 3103 |
+
|
| 3104 |
+
*Returns:* `d_`.
|
| 3105 |
+
|
| 3106 |
+
``` cpp
|
| 3107 |
+
constexpr bool ok() const noexcept;
|
| 3108 |
+
```
|
| 3109 |
+
|
| 3110 |
+
*Returns:* `1 <= d_ && d_ <= 31`.
|
| 3111 |
+
|
| 3112 |
+
#### Non-member functions <a id="time.cal.day.nonmembers">[[time.cal.day.nonmembers]]</a>
|
| 3113 |
+
|
| 3114 |
+
``` cpp
|
| 3115 |
+
constexpr bool operator==(const day& x, const day& y) noexcept;
|
| 3116 |
+
```
|
| 3117 |
+
|
| 3118 |
+
*Returns:* `unsigned{x} == unsigned{y}`.
|
| 3119 |
+
|
| 3120 |
+
``` cpp
|
| 3121 |
+
constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
|
| 3122 |
+
```
|
| 3123 |
+
|
| 3124 |
+
*Returns:* `unsigned{x} <=> unsigned{y}`.
|
| 3125 |
+
|
| 3126 |
+
``` cpp
|
| 3127 |
+
constexpr day operator+(const day& x, const days& y) noexcept;
|
| 3128 |
+
```
|
| 3129 |
+
|
| 3130 |
+
*Returns:* `day(unsigned{x} + y.count())`.
|
| 3131 |
+
|
| 3132 |
+
``` cpp
|
| 3133 |
+
constexpr day operator+(const days& x, const day& y) noexcept;
|
| 3134 |
+
```
|
| 3135 |
+
|
| 3136 |
+
*Returns:* `y + x`.
|
| 3137 |
+
|
| 3138 |
+
``` cpp
|
| 3139 |
+
constexpr day operator-(const day& x, const days& y) noexcept;
|
| 3140 |
+
```
|
| 3141 |
+
|
| 3142 |
+
*Returns:* `x + -y`.
|
| 3143 |
+
|
| 3144 |
+
``` cpp
|
| 3145 |
+
constexpr days operator-(const day& x, const day& y) noexcept;
|
| 3146 |
+
```
|
| 3147 |
+
|
| 3148 |
+
*Returns:* `days{int(unsigned{x}) - int(unsigned{y})}`.
|
| 3149 |
+
|
| 3150 |
+
``` cpp
|
| 3151 |
+
template<class charT, class traits>
|
| 3152 |
+
basic_ostream<charT, traits>&
|
| 3153 |
+
operator<<(basic_ostream<charT, traits>& os, const day& d);
|
| 3154 |
+
```
|
| 3155 |
+
|
| 3156 |
+
*Effects:* Equivalent to:
|
| 3157 |
+
|
| 3158 |
+
``` cpp
|
| 3159 |
+
return os << (d.ok() ?
|
| 3160 |
+
format(STATICALLY-WIDEN<charT>("{:%d}"), d) :
|
| 3161 |
+
format(STATICALLY-WIDEN<charT>("{:%d} is not a valid day"), d));
|
| 3162 |
+
```
|
| 3163 |
+
|
| 3164 |
+
``` cpp
|
| 3165 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 3166 |
+
basic_istream<charT, traits>&
|
| 3167 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 3168 |
+
day& d, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 3169 |
+
minutes* offset = nullptr);
|
| 3170 |
+
```
|
| 3171 |
+
|
| 3172 |
+
*Effects:* Attempts to parse the input stream `is` into the `day` `d`
|
| 3173 |
+
using the format flags given in the NTCTS `fmt` as specified in
|
| 3174 |
+
[[time.parse]]. If the parse fails to decode a valid day,
|
| 3175 |
+
`is.setstate(ios_base::failbit)` is called and `d` is not modified. If
|
| 3176 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 3177 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 3178 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 3179 |
+
if `offset` is non-null.
|
| 3180 |
+
|
| 3181 |
+
*Returns:* `is`.
|
| 3182 |
+
|
| 3183 |
+
``` cpp
|
| 3184 |
+
constexpr chrono::day operator""d(unsigned long long d) noexcept;
|
| 3185 |
+
```
|
| 3186 |
+
|
| 3187 |
+
*Returns:* `day{static_cast<unsigned>(d)}`.
|
| 3188 |
+
|
| 3189 |
+
### Class `month` <a id="time.cal.month">[[time.cal.month]]</a>
|
| 3190 |
+
|
| 3191 |
+
#### Overview <a id="time.cal.month.overview">[[time.cal.month.overview]]</a>
|
| 3192 |
+
|
| 3193 |
+
``` cpp
|
| 3194 |
+
namespace std::chrono {
|
| 3195 |
+
class month {
|
| 3196 |
+
unsigned char m_; // exposition only
|
| 3197 |
+
public:
|
| 3198 |
+
month() = default;
|
| 3199 |
+
constexpr explicit month(unsigned m) noexcept;
|
| 3200 |
+
|
| 3201 |
+
constexpr month& operator++() noexcept;
|
| 3202 |
+
constexpr month operator++(int) noexcept;
|
| 3203 |
+
constexpr month& operator--() noexcept;
|
| 3204 |
+
constexpr month operator--(int) noexcept;
|
| 3205 |
+
|
| 3206 |
+
constexpr month& operator+=(const months& m) noexcept;
|
| 3207 |
+
constexpr month& operator-=(const months& m) noexcept;
|
| 3208 |
+
|
| 3209 |
+
constexpr explicit operator unsigned() const noexcept;
|
| 3210 |
+
constexpr bool ok() const noexcept;
|
| 3211 |
+
};
|
| 3212 |
+
}
|
| 3213 |
+
```
|
| 3214 |
+
|
| 3215 |
+
`month` represents a month of a year. It normally holds values in the
|
| 3216 |
+
range 1 to 12, but may hold non-negative values outside this range. It
|
| 3217 |
+
can be constructed with any `unsigned` value, which will be subsequently
|
| 3218 |
+
truncated to fit into `month`’s unspecified internal storage. `month`
|
| 3219 |
+
meets the *Cpp17EqualityComparable* ([[cpp17.equalitycomparable]]) and
|
| 3220 |
+
*Cpp17LessThanComparable* ([[cpp17.lessthancomparable]]) requirements,
|
| 3221 |
+
and participates in basic arithmetic with `months` objects, which
|
| 3222 |
+
represent a difference between two `month` objects.
|
| 3223 |
+
|
| 3224 |
+
`month` is a trivially copyable and standard-layout class type.
|
| 3225 |
+
|
| 3226 |
+
#### Member functions <a id="time.cal.month.members">[[time.cal.month.members]]</a>
|
| 3227 |
+
|
| 3228 |
+
``` cpp
|
| 3229 |
+
constexpr explicit month(unsigned m) noexcept;
|
| 3230 |
+
```
|
| 3231 |
+
|
| 3232 |
+
*Effects:* Initializes `m_` with `m`. The value held is unspecified if
|
| 3233 |
+
`m` is not in the range \[`0`, `255`\].
|
| 3234 |
+
|
| 3235 |
+
``` cpp
|
| 3236 |
+
constexpr month& operator++() noexcept;
|
| 3237 |
+
```
|
| 3238 |
+
|
| 3239 |
+
*Effects:* `*this += months{1}`.
|
| 3240 |
+
|
| 3241 |
+
*Returns:* `*this`.
|
| 3242 |
+
|
| 3243 |
+
``` cpp
|
| 3244 |
+
constexpr month operator++(int) noexcept;
|
| 3245 |
+
```
|
| 3246 |
+
|
| 3247 |
+
*Effects:* `++(*this)`.
|
| 3248 |
+
|
| 3249 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3250 |
+
function.
|
| 3251 |
+
|
| 3252 |
+
``` cpp
|
| 3253 |
+
constexpr month& operator--() noexcept;
|
| 3254 |
+
```
|
| 3255 |
+
|
| 3256 |
+
*Effects:* `*this -= months{1}`.
|
| 3257 |
+
|
| 3258 |
+
*Returns:* `*this`.
|
| 3259 |
+
|
| 3260 |
+
``` cpp
|
| 3261 |
+
constexpr month operator--(int) noexcept;
|
| 3262 |
+
```
|
| 3263 |
+
|
| 3264 |
+
*Effects:* `–(*this)`.
|
| 3265 |
+
|
| 3266 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3267 |
+
function.
|
| 3268 |
+
|
| 3269 |
+
``` cpp
|
| 3270 |
+
constexpr month& operator+=(const months& m) noexcept;
|
| 3271 |
+
```
|
| 3272 |
+
|
| 3273 |
+
*Effects:* `*this = *this + m`.
|
| 3274 |
+
|
| 3275 |
+
*Returns:* `*this`.
|
| 3276 |
+
|
| 3277 |
+
``` cpp
|
| 3278 |
+
constexpr month& operator-=(const months& m) noexcept;
|
| 3279 |
+
```
|
| 3280 |
+
|
| 3281 |
+
*Effects:* `*this = *this - m`.
|
| 3282 |
+
|
| 3283 |
+
*Returns:* `*this`.
|
| 3284 |
+
|
| 3285 |
+
``` cpp
|
| 3286 |
+
constexpr explicit operator unsigned() const noexcept;
|
| 3287 |
+
```
|
| 3288 |
+
|
| 3289 |
+
*Returns:* `m_`.
|
| 3290 |
+
|
| 3291 |
+
``` cpp
|
| 3292 |
+
constexpr bool ok() const noexcept;
|
| 3293 |
+
```
|
| 3294 |
+
|
| 3295 |
+
*Returns:* `1 <= m_ && m_ <= 12`.
|
| 3296 |
+
|
| 3297 |
+
#### Non-member functions <a id="time.cal.month.nonmembers">[[time.cal.month.nonmembers]]</a>
|
| 3298 |
+
|
| 3299 |
+
``` cpp
|
| 3300 |
+
constexpr bool operator==(const month& x, const month& y) noexcept;
|
| 3301 |
+
```
|
| 3302 |
+
|
| 3303 |
+
*Returns:* `unsigned{x} == unsigned{y}`.
|
| 3304 |
+
|
| 3305 |
+
``` cpp
|
| 3306 |
+
constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
|
| 3307 |
+
```
|
| 3308 |
+
|
| 3309 |
+
*Returns:* `unsigned{x} <=> unsigned{y}`.
|
| 3310 |
+
|
| 3311 |
+
``` cpp
|
| 3312 |
+
constexpr month operator+(const month& x, const months& y) noexcept;
|
| 3313 |
+
```
|
| 3314 |
+
|
| 3315 |
+
*Returns:*
|
| 3316 |
+
|
| 3317 |
+
``` cpp
|
| 3318 |
+
month{modulo(static_cast<long long>(unsigned{x}) + (y.count() - 1), 12) + 1}
|
| 3319 |
+
```
|
| 3320 |
+
|
| 3321 |
+
where `modulo(n, 12)` computes the remainder of `n` divided by 12 using
|
| 3322 |
+
Euclidean division.
|
| 3323 |
+
|
| 3324 |
+
[*Note 1*: Given a divisor of 12, Euclidean division truncates towards
|
| 3325 |
+
negative infinity and always produces a remainder in the range of \[`0`,
|
| 3326 |
+
`11`\]. Assuming no overflow in the signed summation, this operation
|
| 3327 |
+
results in a `month` holding a value in the range \[`1`, `12`\] even if
|
| 3328 |
+
`!x.ok()`. — *end note*]
|
| 3329 |
+
|
| 3330 |
+
[*Example 1*: `February + months{11} == January`. — *end example*]
|
| 3331 |
+
|
| 3332 |
+
``` cpp
|
| 3333 |
+
constexpr month operator+(const months& x, const month& y) noexcept;
|
| 3334 |
+
```
|
| 3335 |
+
|
| 3336 |
+
*Returns:* `y + x`.
|
| 3337 |
+
|
| 3338 |
+
``` cpp
|
| 3339 |
+
constexpr month operator-(const month& x, const months& y) noexcept;
|
| 3340 |
+
```
|
| 3341 |
+
|
| 3342 |
+
*Returns:* `x + -y`.
|
| 3343 |
+
|
| 3344 |
+
``` cpp
|
| 3345 |
+
constexpr months operator-(const month& x, const month& y) noexcept;
|
| 3346 |
+
```
|
| 3347 |
+
|
| 3348 |
+
*Returns:* If `x.ok() == true` and `y.ok() == true`, returns a value `m`
|
| 3349 |
+
in the range \[`months{0}`, `months{11}`\] satisfying `y + m == x`.
|
| 3350 |
+
Otherwise the value returned is unspecified.
|
| 3351 |
+
|
| 3352 |
+
[*Example 2*: `January - February == months{11}`. — *end example*]
|
| 3353 |
+
|
| 3354 |
+
``` cpp
|
| 3355 |
+
template<class charT, class traits>
|
| 3356 |
+
basic_ostream<charT, traits>&
|
| 3357 |
+
operator<<(basic_ostream<charT, traits>& os, const month& m);
|
| 3358 |
+
```
|
| 3359 |
+
|
| 3360 |
+
*Effects:* Equivalent to:
|
| 3361 |
+
|
| 3362 |
+
``` cpp
|
| 3363 |
+
return os << (m.ok() ?
|
| 3364 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:%b}"), m) :
|
| 3365 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid month"),
|
| 3366 |
+
static_cast<unsigned>(m)));
|
| 3367 |
+
```
|
| 3368 |
+
|
| 3369 |
+
``` cpp
|
| 3370 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 3371 |
+
basic_istream<charT, traits>&
|
| 3372 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 3373 |
+
month& m, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 3374 |
+
minutes* offset = nullptr);
|
| 3375 |
+
```
|
| 3376 |
+
|
| 3377 |
+
*Effects:* Attempts to parse the input stream `is` into the `month` `m`
|
| 3378 |
+
using the format flags given in the NTCTS `fmt` as specified in
|
| 3379 |
+
[[time.parse]]. If the parse fails to decode a valid month,
|
| 3380 |
+
`is.setstate(ios_base::failbit)` is called and `m` is not modified. If
|
| 3381 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 3382 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 3383 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 3384 |
+
if `offset` is non-null.
|
| 3385 |
+
|
| 3386 |
+
*Returns:* `is`.
|
| 3387 |
+
|
| 3388 |
+
### Class `year` <a id="time.cal.year">[[time.cal.year]]</a>
|
| 3389 |
+
|
| 3390 |
+
#### Overview <a id="time.cal.year.overview">[[time.cal.year.overview]]</a>
|
| 3391 |
+
|
| 3392 |
+
``` cpp
|
| 3393 |
+
namespace std::chrono {
|
| 3394 |
+
class year {
|
| 3395 |
+
short y_; // exposition only
|
| 3396 |
+
public:
|
| 3397 |
+
year() = default;
|
| 3398 |
+
constexpr explicit year(int y) noexcept;
|
| 3399 |
+
|
| 3400 |
+
constexpr year& operator++() noexcept;
|
| 3401 |
+
constexpr year operator++(int) noexcept;
|
| 3402 |
+
constexpr year& operator--() noexcept;
|
| 3403 |
+
constexpr year operator--(int) noexcept;
|
| 3404 |
+
|
| 3405 |
+
constexpr year& operator+=(const years& y) noexcept;
|
| 3406 |
+
constexpr year& operator-=(const years& y) noexcept;
|
| 3407 |
+
|
| 3408 |
+
constexpr year operator+() const noexcept;
|
| 3409 |
+
constexpr year operator-() const noexcept;
|
| 3410 |
+
|
| 3411 |
+
constexpr bool is_leap() const noexcept;
|
| 3412 |
+
|
| 3413 |
+
constexpr explicit operator int() const noexcept;
|
| 3414 |
+
constexpr bool ok() const noexcept;
|
| 3415 |
+
|
| 3416 |
+
static constexpr year min() noexcept;
|
| 3417 |
+
static constexpr year max() noexcept;
|
| 3418 |
+
};
|
| 3419 |
+
}
|
| 3420 |
+
```
|
| 3421 |
+
|
| 3422 |
+
`year` represents a year in the civil calendar. It can represent values
|
| 3423 |
+
in the range \[`min()`, `max()`\]. It can be constructed with any `int`
|
| 3424 |
+
value, which will be subsequently truncated to fit into `year`’s
|
| 3425 |
+
unspecified internal storage. `year` meets the *Cpp17EqualityComparable*
|
| 3426 |
+
([[cpp17.equalitycomparable]]) and *Cpp17LessThanComparable* (
|
| 3427 |
+
[[cpp17.lessthancomparable]]) requirements, and participates in basic
|
| 3428 |
+
arithmetic with `years` objects, which represent a difference between
|
| 3429 |
+
two `year` objects.
|
| 3430 |
+
|
| 3431 |
+
`year` is a trivially copyable and standard-layout class type.
|
| 3432 |
+
|
| 3433 |
+
#### Member functions <a id="time.cal.year.members">[[time.cal.year.members]]</a>
|
| 3434 |
+
|
| 3435 |
+
``` cpp
|
| 3436 |
+
constexpr explicit year(int y) noexcept;
|
| 3437 |
+
```
|
| 3438 |
+
|
| 3439 |
+
*Effects:* Initializes `y_` with `y`. The value held is unspecified if
|
| 3440 |
+
`y` is not in the range \[`-32767`, `32767`\].
|
| 3441 |
+
|
| 3442 |
+
``` cpp
|
| 3443 |
+
constexpr year& operator++() noexcept;
|
| 3444 |
+
```
|
| 3445 |
+
|
| 3446 |
+
*Effects:* `++y_`.
|
| 3447 |
+
|
| 3448 |
+
*Returns:* `*this`.
|
| 3449 |
+
|
| 3450 |
+
``` cpp
|
| 3451 |
+
constexpr year operator++(int) noexcept;
|
| 3452 |
+
```
|
| 3453 |
+
|
| 3454 |
+
*Effects:* `++(*this)`.
|
| 3455 |
+
|
| 3456 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3457 |
+
function.
|
| 3458 |
+
|
| 3459 |
+
``` cpp
|
| 3460 |
+
constexpr year& operator--() noexcept;
|
| 3461 |
+
```
|
| 3462 |
+
|
| 3463 |
+
*Effects:* `–y_`.
|
| 3464 |
+
|
| 3465 |
+
*Returns:* `*this`.
|
| 3466 |
+
|
| 3467 |
+
``` cpp
|
| 3468 |
+
constexpr year operator--(int) noexcept;
|
| 3469 |
+
```
|
| 3470 |
+
|
| 3471 |
+
*Effects:* `–(*this)`.
|
| 3472 |
+
|
| 3473 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3474 |
+
function.
|
| 3475 |
+
|
| 3476 |
+
``` cpp
|
| 3477 |
+
constexpr year& operator+=(const years& y) noexcept;
|
| 3478 |
+
```
|
| 3479 |
+
|
| 3480 |
+
*Effects:* `*this = *this + y`.
|
| 3481 |
+
|
| 3482 |
+
*Returns:* `*this`.
|
| 3483 |
+
|
| 3484 |
+
``` cpp
|
| 3485 |
+
constexpr year& operator-=(const years& y) noexcept;
|
| 3486 |
+
```
|
| 3487 |
+
|
| 3488 |
+
*Effects:* `*this = *this - y`.
|
| 3489 |
+
|
| 3490 |
+
*Returns:* `*this`.
|
| 3491 |
+
|
| 3492 |
+
``` cpp
|
| 3493 |
+
constexpr year operator+() const noexcept;
|
| 3494 |
+
```
|
| 3495 |
+
|
| 3496 |
+
*Returns:* `*this`.
|
| 3497 |
+
|
| 3498 |
+
``` cpp
|
| 3499 |
+
constexpr year year::operator-() const noexcept;
|
| 3500 |
+
```
|
| 3501 |
+
|
| 3502 |
+
*Returns:* `year{-y_}`.
|
| 3503 |
+
|
| 3504 |
+
``` cpp
|
| 3505 |
+
constexpr bool is_leap() const noexcept;
|
| 3506 |
+
```
|
| 3507 |
+
|
| 3508 |
+
*Returns:* `y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0)`.
|
| 3509 |
+
|
| 3510 |
+
``` cpp
|
| 3511 |
+
constexpr explicit operator int() const noexcept;
|
| 3512 |
+
```
|
| 3513 |
+
|
| 3514 |
+
*Returns:* `y_`.
|
| 3515 |
+
|
| 3516 |
+
``` cpp
|
| 3517 |
+
constexpr bool ok() const noexcept;
|
| 3518 |
+
```
|
| 3519 |
+
|
| 3520 |
+
*Returns:* `min().y_ <= y_ && y_ <= max().y_`.
|
| 3521 |
+
|
| 3522 |
+
``` cpp
|
| 3523 |
+
static constexpr year min() noexcept;
|
| 3524 |
+
```
|
| 3525 |
+
|
| 3526 |
+
*Returns:* `year{-32767}`.
|
| 3527 |
+
|
| 3528 |
+
``` cpp
|
| 3529 |
+
static constexpr year max() noexcept;
|
| 3530 |
+
```
|
| 3531 |
+
|
| 3532 |
+
*Returns:* `year{32767}`.
|
| 3533 |
+
|
| 3534 |
+
#### Non-member functions <a id="time.cal.year.nonmembers">[[time.cal.year.nonmembers]]</a>
|
| 3535 |
+
|
| 3536 |
+
``` cpp
|
| 3537 |
+
constexpr bool operator==(const year& x, const year& y) noexcept;
|
| 3538 |
+
```
|
| 3539 |
+
|
| 3540 |
+
*Returns:* `int{x} == int{y}`.
|
| 3541 |
+
|
| 3542 |
+
``` cpp
|
| 3543 |
+
constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
|
| 3544 |
+
```
|
| 3545 |
+
|
| 3546 |
+
*Returns:* `int{x} <=> int{y}`.
|
| 3547 |
+
|
| 3548 |
+
``` cpp
|
| 3549 |
+
constexpr year operator+(const year& x, const years& y) noexcept;
|
| 3550 |
+
```
|
| 3551 |
+
|
| 3552 |
+
*Returns:* `year{int{x} + y.count()}`.
|
| 3553 |
+
|
| 3554 |
+
``` cpp
|
| 3555 |
+
constexpr year operator+(const years& x, const year& y) noexcept;
|
| 3556 |
+
```
|
| 3557 |
+
|
| 3558 |
+
*Returns:* `y + x`.
|
| 3559 |
+
|
| 3560 |
+
``` cpp
|
| 3561 |
+
constexpr year operator-(const year& x, const years& y) noexcept;
|
| 3562 |
+
```
|
| 3563 |
+
|
| 3564 |
+
*Returns:* `x + -y`.
|
| 3565 |
+
|
| 3566 |
+
``` cpp
|
| 3567 |
+
constexpr years operator-(const year& x, const year& y) noexcept;
|
| 3568 |
+
```
|
| 3569 |
+
|
| 3570 |
+
*Returns:* `years{int{x} - int{y}}`.
|
| 3571 |
+
|
| 3572 |
+
``` cpp
|
| 3573 |
+
template<class charT, class traits>
|
| 3574 |
+
basic_ostream<charT, traits>&
|
| 3575 |
+
operator<<(basic_ostream<charT, traits>& os, const year& y);
|
| 3576 |
+
```
|
| 3577 |
+
|
| 3578 |
+
*Effects:* Equivalent to:
|
| 3579 |
+
|
| 3580 |
+
``` cpp
|
| 3581 |
+
return os << (y.ok() ?
|
| 3582 |
+
format(STATICALLY-WIDEN<charT>("{:%Y}"), y) :
|
| 3583 |
+
format(STATICALLY-WIDEN<charT>("{:%Y} is not a valid year"), y));
|
| 3584 |
+
```
|
| 3585 |
+
|
| 3586 |
+
``` cpp
|
| 3587 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 3588 |
+
basic_istream<charT, traits>&
|
| 3589 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 3590 |
+
year& y, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 3591 |
+
minutes* offset = nullptr);
|
| 3592 |
+
```
|
| 3593 |
+
|
| 3594 |
+
*Effects:* Attempts to parse the input stream `is` into the `year` `y`
|
| 3595 |
+
using the format flags given in the NTCTS `fmt` as specified in
|
| 3596 |
+
[[time.parse]]. If the parse fails to decode a valid year,
|
| 3597 |
+
`is.setstate(ios_base::failbit)` is called and `y` is not modified. If
|
| 3598 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 3599 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 3600 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 3601 |
+
if `offset` is non-null.
|
| 3602 |
+
|
| 3603 |
+
*Returns:* `is`.
|
| 3604 |
+
|
| 3605 |
+
``` cpp
|
| 3606 |
+
constexpr chrono::year operator""y(unsigned long long y) noexcept;
|
| 3607 |
+
```
|
| 3608 |
+
|
| 3609 |
+
*Returns:* `year{static_cast<int>(y)}`.
|
| 3610 |
+
|
| 3611 |
+
### Class `weekday` <a id="time.cal.wd">[[time.cal.wd]]</a>
|
| 3612 |
+
|
| 3613 |
+
#### Overview <a id="time.cal.wd.overview">[[time.cal.wd.overview]]</a>
|
| 3614 |
+
|
| 3615 |
+
``` cpp
|
| 3616 |
+
namespace std::chrono {
|
| 3617 |
+
class weekday {
|
| 3618 |
+
unsigned char wd_; // exposition only
|
| 3619 |
+
public:
|
| 3620 |
+
weekday() = default;
|
| 3621 |
+
constexpr explicit weekday(unsigned wd) noexcept;
|
| 3622 |
+
constexpr weekday(const sys_days& dp) noexcept;
|
| 3623 |
+
constexpr explicit weekday(const local_days& dp) noexcept;
|
| 3624 |
+
|
| 3625 |
+
constexpr weekday& operator++() noexcept;
|
| 3626 |
+
constexpr weekday operator++(int) noexcept;
|
| 3627 |
+
constexpr weekday& operator--() noexcept;
|
| 3628 |
+
constexpr weekday operator--(int) noexcept;
|
| 3629 |
+
|
| 3630 |
+
constexpr weekday& operator+=(const days& d) noexcept;
|
| 3631 |
+
constexpr weekday& operator-=(const days& d) noexcept;
|
| 3632 |
+
|
| 3633 |
+
constexpr unsigned c_encoding() const noexcept;
|
| 3634 |
+
constexpr unsigned iso_encoding() const noexcept;
|
| 3635 |
+
constexpr bool ok() const noexcept;
|
| 3636 |
+
|
| 3637 |
+
constexpr weekday_indexed operator[](unsigned index) const noexcept;
|
| 3638 |
+
constexpr weekday_last operator[](last_spec) const noexcept;
|
| 3639 |
+
};
|
| 3640 |
+
}
|
| 3641 |
+
```
|
| 3642 |
+
|
| 3643 |
+
`weekday` represents a day of the week in the civil calendar. It
|
| 3644 |
+
normally holds values in the range `0` to `6`, corresponding to Sunday
|
| 3645 |
+
through Saturday, but it may hold non-negative values outside this
|
| 3646 |
+
range. It can be constructed with any `unsigned` value, which will be
|
| 3647 |
+
subsequently truncated to fit into `weekday`’s unspecified internal
|
| 3648 |
+
storage. `weekday` meets the *Cpp17EqualityComparable* (
|
| 3649 |
+
[[cpp17.equalitycomparable]]) requirements.
|
| 3650 |
+
|
| 3651 |
+
[*Note 1*: `weekday` is not *Cpp17LessThanComparable* because there is
|
| 3652 |
+
no universal consensus on which day is the first day of the week.
|
| 3653 |
+
`weekday`’s arithmetic operations treat the days of the week as a
|
| 3654 |
+
circular range, with no beginning and no end. — *end note*]
|
| 3655 |
+
|
| 3656 |
+
`weekday` is a trivially copyable and standard-layout class type.
|
| 3657 |
+
|
| 3658 |
+
#### Member functions <a id="time.cal.wd.members">[[time.cal.wd.members]]</a>
|
| 3659 |
+
|
| 3660 |
+
``` cpp
|
| 3661 |
+
constexpr explicit weekday(unsigned wd) noexcept;
|
| 3662 |
+
```
|
| 3663 |
+
|
| 3664 |
+
*Effects:* Initializes `wd_` with `wd == 7 ? 0 : wd`. The value held is
|
| 3665 |
+
unspecified if `wd` is not in the range \[`0`, `255`\].
|
| 3666 |
+
|
| 3667 |
+
``` cpp
|
| 3668 |
+
constexpr weekday(const sys_days& dp) noexcept;
|
| 3669 |
+
```
|
| 3670 |
+
|
| 3671 |
+
*Effects:* Computes what day of the week corresponds to the `sys_days`
|
| 3672 |
+
`dp`, and initializes that day of the week in `wd_`.
|
| 3673 |
+
|
| 3674 |
+
[*Example 1*: If `dp` represents 1970-01-01, the constructed `weekday`
|
| 3675 |
+
represents Thursday by storing `4` in `wd_`. — *end example*]
|
| 3676 |
+
|
| 3677 |
+
``` cpp
|
| 3678 |
+
constexpr explicit weekday(const local_days& dp) noexcept;
|
| 3679 |
+
```
|
| 3680 |
+
|
| 3681 |
+
*Effects:* Computes what day of the week corresponds to the `local_days`
|
| 3682 |
+
`dp`, and initializes that day of the week in `wd_`.
|
| 3683 |
+
|
| 3684 |
+
*Ensures:* The value is identical to that constructed from
|
| 3685 |
+
`sys_days{dp.time_since_epoch()}`.
|
| 3686 |
+
|
| 3687 |
+
``` cpp
|
| 3688 |
+
constexpr weekday& operator++() noexcept;
|
| 3689 |
+
```
|
| 3690 |
+
|
| 3691 |
+
*Effects:* `*this += days{1}`.
|
| 3692 |
+
|
| 3693 |
+
*Returns:* `*this`.
|
| 3694 |
+
|
| 3695 |
+
``` cpp
|
| 3696 |
+
constexpr weekday operator++(int) noexcept;
|
| 3697 |
+
```
|
| 3698 |
+
|
| 3699 |
+
*Effects:* `++(*this)`.
|
| 3700 |
+
|
| 3701 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3702 |
+
function.
|
| 3703 |
+
|
| 3704 |
+
``` cpp
|
| 3705 |
+
constexpr weekday& operator--() noexcept;
|
| 3706 |
+
```
|
| 3707 |
+
|
| 3708 |
+
*Effects:* `*this -= days{1}`.
|
| 3709 |
+
|
| 3710 |
+
*Returns:* `*this`.
|
| 3711 |
+
|
| 3712 |
+
``` cpp
|
| 3713 |
+
constexpr weekday operator--(int) noexcept;
|
| 3714 |
+
```
|
| 3715 |
+
|
| 3716 |
+
*Effects:* `–(*this)`.
|
| 3717 |
+
|
| 3718 |
+
*Returns:* A copy of `*this` as it existed on entry to this member
|
| 3719 |
+
function.
|
| 3720 |
+
|
| 3721 |
+
``` cpp
|
| 3722 |
+
constexpr weekday& operator+=(const days& d) noexcept;
|
| 3723 |
+
```
|
| 3724 |
+
|
| 3725 |
+
*Effects:* `*this = *this + d`.
|
| 3726 |
+
|
| 3727 |
+
*Returns:* `*this`.
|
| 3728 |
+
|
| 3729 |
+
``` cpp
|
| 3730 |
+
constexpr weekday& operator-=(const days& d) noexcept;
|
| 3731 |
+
```
|
| 3732 |
+
|
| 3733 |
+
*Effects:* `*this = *this - d`.
|
| 3734 |
+
|
| 3735 |
+
*Returns:* `*this`.
|
| 3736 |
+
|
| 3737 |
+
``` cpp
|
| 3738 |
+
constexpr unsigned c_encoding() const noexcept;
|
| 3739 |
+
```
|
| 3740 |
+
|
| 3741 |
+
*Returns:* `wd_`.
|
| 3742 |
+
|
| 3743 |
+
``` cpp
|
| 3744 |
+
constexpr unsigned iso_encoding() const noexcept;
|
| 3745 |
+
```
|
| 3746 |
+
|
| 3747 |
+
*Returns:* `wd_ == 0u ? 7u : wd_`.
|
| 3748 |
+
|
| 3749 |
+
``` cpp
|
| 3750 |
+
constexpr bool ok() const noexcept;
|
| 3751 |
+
```
|
| 3752 |
+
|
| 3753 |
+
*Returns:* `wd_ <= 6`.
|
| 3754 |
+
|
| 3755 |
+
``` cpp
|
| 3756 |
+
constexpr weekday_indexed operator[](unsigned index) const noexcept;
|
| 3757 |
+
```
|
| 3758 |
+
|
| 3759 |
+
*Returns:* `{*this, index}`.
|
| 3760 |
+
|
| 3761 |
+
``` cpp
|
| 3762 |
+
constexpr weekday_last operator[](last_spec) const noexcept;
|
| 3763 |
+
```
|
| 3764 |
+
|
| 3765 |
+
*Returns:* `weekday_last{*this}`.
|
| 3766 |
+
|
| 3767 |
+
#### Non-member functions <a id="time.cal.wd.nonmembers">[[time.cal.wd.nonmembers]]</a>
|
| 3768 |
+
|
| 3769 |
+
``` cpp
|
| 3770 |
+
constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
|
| 3771 |
+
```
|
| 3772 |
+
|
| 3773 |
+
*Returns:* `x.wd_ == y.wd_`.
|
| 3774 |
+
|
| 3775 |
+
``` cpp
|
| 3776 |
+
constexpr weekday operator+(const weekday& x, const days& y) noexcept;
|
| 3777 |
+
```
|
| 3778 |
+
|
| 3779 |
+
*Returns:*
|
| 3780 |
+
|
| 3781 |
+
``` cpp
|
| 3782 |
+
weekday{modulo(static_cast<long long>(x.wd_) + y.count(), 7)}
|
| 3783 |
+
```
|
| 3784 |
+
|
| 3785 |
+
where `modulo(n, 7)` computes the remainder of `n` divided by 7 using
|
| 3786 |
+
Euclidean division.
|
| 3787 |
+
|
| 3788 |
+
[*Note 1*: Given a divisor of 7, Euclidean division truncates towards
|
| 3789 |
+
negative infinity and always produces a remainder in the range of \[`0`,
|
| 3790 |
+
`6`\]. Assuming no overflow in the signed summation, this operation
|
| 3791 |
+
results in a `weekday` holding a value in the range \[`0`, `6`\] even if
|
| 3792 |
+
`!x.ok()`. — *end note*]
|
| 3793 |
+
|
| 3794 |
+
[*Example 1*: `Monday + days{6} == Sunday`. — *end example*]
|
| 3795 |
+
|
| 3796 |
+
``` cpp
|
| 3797 |
+
constexpr weekday operator+(const days& x, const weekday& y) noexcept;
|
| 3798 |
+
```
|
| 3799 |
+
|
| 3800 |
+
*Returns:* `y + x`.
|
| 3801 |
+
|
| 3802 |
+
``` cpp
|
| 3803 |
+
constexpr weekday operator-(const weekday& x, const days& y) noexcept;
|
| 3804 |
+
```
|
| 3805 |
+
|
| 3806 |
+
*Returns:* `x + -y`.
|
| 3807 |
+
|
| 3808 |
+
``` cpp
|
| 3809 |
+
constexpr days operator-(const weekday& x, const weekday& y) noexcept;
|
| 3810 |
+
```
|
| 3811 |
+
|
| 3812 |
+
*Returns:* If `x.ok() == true` and `y.ok() == true`, returns a value `d`
|
| 3813 |
+
in the range \[`days{0}`, `days{6}`\] satisfying `y + d == x`. Otherwise
|
| 3814 |
+
the value returned is unspecified.
|
| 3815 |
+
|
| 3816 |
+
[*Example 2*: `Sunday - Monday == days{6}`. — *end example*]
|
| 3817 |
+
|
| 3818 |
+
``` cpp
|
| 3819 |
+
template<class charT, class traits>
|
| 3820 |
+
basic_ostream<charT, traits>&
|
| 3821 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
|
| 3822 |
+
```
|
| 3823 |
+
|
| 3824 |
+
*Effects:* Equivalent to:
|
| 3825 |
+
|
| 3826 |
+
``` cpp
|
| 3827 |
+
return os << (wd.ok() ?
|
| 3828 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{:%a}"), wd) :
|
| 3829 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{} is not a valid weekday"),
|
| 3830 |
+
static_cast<unsigned>(wd.wd_)));
|
| 3831 |
+
```
|
| 3832 |
+
|
| 3833 |
+
``` cpp
|
| 3834 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 3835 |
+
basic_istream<charT, traits>&
|
| 3836 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 3837 |
+
weekday& wd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 3838 |
+
minutes* offset = nullptr);
|
| 3839 |
+
```
|
| 3840 |
+
|
| 3841 |
+
*Effects:* Attempts to parse the input stream `is` into the `weekday`
|
| 3842 |
+
`wd` using the format flags given in the NTCTS `fmt` as specified in
|
| 3843 |
+
[[time.parse]]. If the parse fails to decode a valid weekday,
|
| 3844 |
+
`is.setstate(ios_base::failbit)` is called and `wd` is not modified. If
|
| 3845 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 3846 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 3847 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 3848 |
+
if `offset` is non-null.
|
| 3849 |
+
|
| 3850 |
+
*Returns:* `is`.
|
| 3851 |
+
|
| 3852 |
+
### Class `weekday_indexed` <a id="time.cal.wdidx">[[time.cal.wdidx]]</a>
|
| 3853 |
+
|
| 3854 |
+
#### Overview <a id="time.cal.wdidx.overview">[[time.cal.wdidx.overview]]</a>
|
| 3855 |
+
|
| 3856 |
+
``` cpp
|
| 3857 |
+
namespace std::chrono {
|
| 3858 |
+
class weekday_indexed {
|
| 3859 |
+
chrono::weekday wd_; // exposition only
|
| 3860 |
+
unsigned char index_; // exposition only
|
| 3861 |
+
|
| 3862 |
+
public:
|
| 3863 |
+
weekday_indexed() = default;
|
| 3864 |
+
constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
|
| 3865 |
+
|
| 3866 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 3867 |
+
constexpr unsigned index() const noexcept;
|
| 3868 |
+
constexpr bool ok() const noexcept;
|
| 3869 |
+
};
|
| 3870 |
+
}
|
| 3871 |
+
```
|
| 3872 |
+
|
| 3873 |
+
`weekday_indexed` represents a `weekday` and a small index in the range
|
| 3874 |
+
1 to 5. This class is used to represent the first, second, third,
|
| 3875 |
+
fourth, or fifth weekday of a month.
|
| 3876 |
+
|
| 3877 |
+
[*Note 1*: A `weekday_indexed` object can be constructed by indexing a
|
| 3878 |
+
`weekday` with an `unsigned`. — *end note*]
|
| 3879 |
+
|
| 3880 |
+
[*Example 1*:
|
| 3881 |
+
|
| 3882 |
+
``` cpp
|
| 3883 |
+
constexpr auto wdi = Sunday[2]; // wdi is the second Sunday of an as yet unspecified month
|
| 3884 |
+
static_assert(wdi.weekday() == Sunday);
|
| 3885 |
+
static_assert(wdi.index() == 2);
|
| 3886 |
+
```
|
| 3887 |
+
|
| 3888 |
+
— *end example*]
|
| 3889 |
+
|
| 3890 |
+
`weekday_indexed` is a trivially copyable and standard-layout class
|
| 3891 |
+
type.
|
| 3892 |
+
|
| 3893 |
+
#### Member functions <a id="time.cal.wdidx.members">[[time.cal.wdidx.members]]</a>
|
| 3894 |
+
|
| 3895 |
+
``` cpp
|
| 3896 |
+
constexpr weekday_indexed(const chrono::weekday& wd, unsigned index) noexcept;
|
| 3897 |
+
```
|
| 3898 |
+
|
| 3899 |
+
*Effects:* Initializes `wd_` with `wd` and `index_` with `index`. The
|
| 3900 |
+
values held are unspecified if `!wd.ok()` or `index` is not in the range
|
| 3901 |
+
\[`0`, `7`\].
|
| 3902 |
+
|
| 3903 |
+
``` cpp
|
| 3904 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 3905 |
+
```
|
| 3906 |
+
|
| 3907 |
+
*Returns:* `wd_`.
|
| 3908 |
+
|
| 3909 |
+
``` cpp
|
| 3910 |
+
constexpr unsigned index() const noexcept;
|
| 3911 |
+
```
|
| 3912 |
+
|
| 3913 |
+
*Returns:* `index_`.
|
| 3914 |
+
|
| 3915 |
+
``` cpp
|
| 3916 |
+
constexpr bool ok() const noexcept;
|
| 3917 |
+
```
|
| 3918 |
+
|
| 3919 |
+
*Returns:* `wd_.ok() && 1 <= index_ && index_ <= 5`.
|
| 3920 |
+
|
| 3921 |
+
#### Non-member functions <a id="time.cal.wdidx.nonmembers">[[time.cal.wdidx.nonmembers]]</a>
|
| 3922 |
+
|
| 3923 |
+
``` cpp
|
| 3924 |
+
constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
|
| 3925 |
+
```
|
| 3926 |
+
|
| 3927 |
+
*Returns:* `x.weekday() == y.weekday() && x.index() == y.index()`.
|
| 3928 |
+
|
| 3929 |
+
``` cpp
|
| 3930 |
+
template<class charT, class traits>
|
| 3931 |
+
basic_ostream<charT, traits>&
|
| 3932 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
|
| 3933 |
+
```
|
| 3934 |
+
|
| 3935 |
+
*Effects:* Equivalent to:
|
| 3936 |
+
|
| 3937 |
+
``` cpp
|
| 3938 |
+
auto i = wdi.index();
|
| 3939 |
+
return os << (i >= 1 && i <= 5 ?
|
| 3940 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{}[{}]"), wdi.weekday(), i) :
|
| 3941 |
+
format(os.getloc(), STATICALLY-WIDEN<charT>("{}[{} is not a valid index]"),
|
| 3942 |
+
wdi.weekday(), i));
|
| 3943 |
+
```
|
| 3944 |
+
|
| 3945 |
+
### Class `weekday_last` <a id="time.cal.wdlast">[[time.cal.wdlast]]</a>
|
| 3946 |
+
|
| 3947 |
+
#### Overview <a id="time.cal.wdlast.overview">[[time.cal.wdlast.overview]]</a>
|
| 3948 |
+
|
| 3949 |
+
``` cpp
|
| 3950 |
+
namespace std::chrono {
|
| 3951 |
+
class weekday_last {
|
| 3952 |
+
chrono::weekday wd_; // exposition only
|
| 3953 |
+
|
| 3954 |
+
public:
|
| 3955 |
+
constexpr explicit weekday_last(const chrono::weekday& wd) noexcept;
|
| 3956 |
+
|
| 3957 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 3958 |
+
constexpr bool ok() const noexcept;
|
| 3959 |
+
};
|
| 3960 |
+
}
|
| 3961 |
+
```
|
| 3962 |
+
|
| 3963 |
+
`weekday_last` represents the last weekday of a month.
|
| 3964 |
+
|
| 3965 |
+
[*Note 1*: A `weekday_last` object can be constructed by indexing a
|
| 3966 |
+
`weekday` with `last`. — *end note*]
|
| 3967 |
+
|
| 3968 |
+
[*Example 1*:
|
| 3969 |
+
|
| 3970 |
+
``` cpp
|
| 3971 |
+
constexpr auto wdl = Sunday[last]; // wdl is the last Sunday of an as yet unspecified month
|
| 3972 |
+
static_assert(wdl.weekday() == Sunday);
|
| 3973 |
+
```
|
| 3974 |
+
|
| 3975 |
+
— *end example*]
|
| 3976 |
+
|
| 3977 |
+
`weekday_last` is a trivially copyable and standard-layout class type.
|
| 3978 |
+
|
| 3979 |
+
#### Member functions <a id="time.cal.wdlast.members">[[time.cal.wdlast.members]]</a>
|
| 3980 |
+
|
| 3981 |
+
``` cpp
|
| 3982 |
+
constexpr explicit weekday_last(const chrono::weekday& wd) noexcept;
|
| 3983 |
+
```
|
| 3984 |
+
|
| 3985 |
+
*Effects:* Initializes `wd_` with `wd`.
|
| 3986 |
+
|
| 3987 |
+
``` cpp
|
| 3988 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 3989 |
+
```
|
| 3990 |
+
|
| 3991 |
+
*Returns:* `wd_`.
|
| 3992 |
+
|
| 3993 |
+
``` cpp
|
| 3994 |
+
constexpr bool ok() const noexcept;
|
| 3995 |
+
```
|
| 3996 |
+
|
| 3997 |
+
*Returns:* `wd_.ok()`.
|
| 3998 |
+
|
| 3999 |
+
#### Non-member functions <a id="time.cal.wdlast.nonmembers">[[time.cal.wdlast.nonmembers]]</a>
|
| 4000 |
+
|
| 4001 |
+
``` cpp
|
| 4002 |
+
constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
|
| 4003 |
+
```
|
| 4004 |
+
|
| 4005 |
+
*Returns:* `x.weekday() == y.weekday()`.
|
| 4006 |
+
|
| 4007 |
+
``` cpp
|
| 4008 |
+
template<class charT, class traits>
|
| 4009 |
+
basic_ostream<charT, traits>&
|
| 4010 |
+
operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
|
| 4011 |
+
```
|
| 4012 |
+
|
| 4013 |
+
*Effects:* Equivalent to:
|
| 4014 |
+
|
| 4015 |
+
``` cpp
|
| 4016 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}[last]"), wdl.weekday());
|
| 4017 |
+
```
|
| 4018 |
+
|
| 4019 |
+
### Class `month_day` <a id="time.cal.md">[[time.cal.md]]</a>
|
| 4020 |
+
|
| 4021 |
+
#### Overview <a id="time.cal.md.overview">[[time.cal.md.overview]]</a>
|
| 4022 |
+
|
| 4023 |
+
``` cpp
|
| 4024 |
+
namespace std::chrono {
|
| 4025 |
+
class month_day {
|
| 4026 |
+
chrono::month m_; // exposition only
|
| 4027 |
+
chrono::day d_; // exposition only
|
| 4028 |
+
|
| 4029 |
+
public:
|
| 4030 |
+
month_day() = default;
|
| 4031 |
+
constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
|
| 4032 |
+
|
| 4033 |
+
constexpr chrono::month month() const noexcept;
|
| 4034 |
+
constexpr chrono::day day() const noexcept;
|
| 4035 |
+
constexpr bool ok() const noexcept;
|
| 4036 |
+
};
|
| 4037 |
+
}
|
| 4038 |
+
```
|
| 4039 |
+
|
| 4040 |
+
`month_day` represents a specific day of a specific month, but with an
|
| 4041 |
+
unspecified year. `month_day` meets the *Cpp17EqualityComparable* (
|
| 4042 |
+
[[cpp17.equalitycomparable]]) and *Cpp17LessThanComparable* (
|
| 4043 |
+
[[cpp17.lessthancomparable]]) requirements.
|
| 4044 |
+
|
| 4045 |
+
`month_day` is a trivially copyable and standard-layout class type.
|
| 4046 |
+
|
| 4047 |
+
#### Member functions <a id="time.cal.md.members">[[time.cal.md.members]]</a>
|
| 4048 |
+
|
| 4049 |
+
``` cpp
|
| 4050 |
+
constexpr month_day(const chrono::month& m, const chrono::day& d) noexcept;
|
| 4051 |
+
```
|
| 4052 |
+
|
| 4053 |
+
*Effects:* Initializes `m_` with `m`, and `d_` with `d`.
|
| 4054 |
+
|
| 4055 |
+
``` cpp
|
| 4056 |
+
constexpr chrono::month month() const noexcept;
|
| 4057 |
+
```
|
| 4058 |
+
|
| 4059 |
+
*Returns:* `m_`.
|
| 4060 |
+
|
| 4061 |
+
``` cpp
|
| 4062 |
+
constexpr chrono::day day() const noexcept;
|
| 4063 |
+
```
|
| 4064 |
+
|
| 4065 |
+
*Returns:* `d_`.
|
| 4066 |
+
|
| 4067 |
+
``` cpp
|
| 4068 |
+
constexpr bool ok() const noexcept;
|
| 4069 |
+
```
|
| 4070 |
+
|
| 4071 |
+
*Returns:* `true` if `m_.ok()` is `true`, `1d <= d_`, and `d_` is less
|
| 4072 |
+
than or equal to the number of days in month `m_`; otherwise returns
|
| 4073 |
+
`false`. When `m_ == February`, the number of days is considered to be
|
| 4074 |
+
29.
|
| 4075 |
+
|
| 4076 |
+
#### Non-member functions <a id="time.cal.md.nonmembers">[[time.cal.md.nonmembers]]</a>
|
| 4077 |
+
|
| 4078 |
+
``` cpp
|
| 4079 |
+
constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
|
| 4080 |
+
```
|
| 4081 |
+
|
| 4082 |
+
*Returns:* `x.month() == y.month() && x.day() == y.day()`.
|
| 4083 |
+
|
| 4084 |
+
``` cpp
|
| 4085 |
+
constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
|
| 4086 |
+
```
|
| 4087 |
+
|
| 4088 |
+
*Effects:* Equivalent to:
|
| 4089 |
+
|
| 4090 |
+
``` cpp
|
| 4091 |
+
if (auto c = x.month() <=> y.month(); c != 0) return c;
|
| 4092 |
+
return x.day() <=> y.day();
|
| 4093 |
+
```
|
| 4094 |
+
|
| 4095 |
+
``` cpp
|
| 4096 |
+
template<class charT, class traits>
|
| 4097 |
+
basic_ostream<charT, traits>&
|
| 4098 |
+
operator<<(basic_ostream<charT, traits>& os, const month_day& md);
|
| 4099 |
+
```
|
| 4100 |
+
|
| 4101 |
+
*Effects:* Equivalent to:
|
| 4102 |
+
|
| 4103 |
+
``` cpp
|
| 4104 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4105 |
+
md.month(), md.day());
|
| 4106 |
+
```
|
| 4107 |
+
|
| 4108 |
+
``` cpp
|
| 4109 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 4110 |
+
basic_istream<charT, traits>&
|
| 4111 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 4112 |
+
month_day& md, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 4113 |
+
minutes* offset = nullptr);
|
| 4114 |
+
```
|
| 4115 |
+
|
| 4116 |
+
*Effects:* Attempts to parse the input stream `is` into the `month_day`
|
| 4117 |
+
`md` using the format flags given in the NTCTS `fmt` as specified in
|
| 4118 |
+
[[time.parse]]. If the parse fails to decode a valid `month_day`,
|
| 4119 |
+
`is.setstate(ios_base::failbit)` is called and `md` is not modified. If
|
| 4120 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 4121 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 4122 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 4123 |
+
if `offset` is non-null.
|
| 4124 |
+
|
| 4125 |
+
*Returns:* `is`.
|
| 4126 |
+
|
| 4127 |
+
### Class `month_day_last` <a id="time.cal.mdlast">[[time.cal.mdlast]]</a>
|
| 4128 |
+
|
| 4129 |
+
``` cpp
|
| 4130 |
+
namespace std::chrono {
|
| 4131 |
+
class month_day_last {
|
| 4132 |
+
chrono::month m_; // exposition only
|
| 4133 |
+
|
| 4134 |
+
public:
|
| 4135 |
+
constexpr explicit month_day_last(const chrono::month& m) noexcept;
|
| 4136 |
+
|
| 4137 |
+
constexpr chrono::month month() const noexcept;
|
| 4138 |
+
constexpr bool ok() const noexcept;
|
| 4139 |
+
};
|
| 4140 |
+
}
|
| 4141 |
+
```
|
| 4142 |
+
|
| 4143 |
+
`month_day_last` represents the last day of a month.
|
| 4144 |
+
|
| 4145 |
+
[*Note 1*: A `month_day_last` object can be constructed using the
|
| 4146 |
+
expression `m/last` or `last/m`, where `m` is an expression of type
|
| 4147 |
+
`month`. — *end note*]
|
| 4148 |
+
|
| 4149 |
+
[*Example 1*:
|
| 4150 |
+
|
| 4151 |
+
``` cpp
|
| 4152 |
+
constexpr auto mdl = February/last; // mdl is the last day of February of an as yet unspecified year
|
| 4153 |
+
static_assert(mdl.month() == February);
|
| 4154 |
+
```
|
| 4155 |
+
|
| 4156 |
+
— *end example*]
|
| 4157 |
+
|
| 4158 |
+
`month_day_last` is a trivially copyable and standard-layout class type.
|
| 4159 |
+
|
| 4160 |
+
``` cpp
|
| 4161 |
+
constexpr explicit month_day_last(const chrono::month& m) noexcept;
|
| 4162 |
+
```
|
| 4163 |
+
|
| 4164 |
+
*Effects:* Initializes `m_` with `m`.
|
| 4165 |
+
|
| 4166 |
+
``` cpp
|
| 4167 |
+
constexpr month month() const noexcept;
|
| 4168 |
+
```
|
| 4169 |
+
|
| 4170 |
+
*Returns:* `m_`.
|
| 4171 |
+
|
| 4172 |
+
``` cpp
|
| 4173 |
+
constexpr bool ok() const noexcept;
|
| 4174 |
+
```
|
| 4175 |
+
|
| 4176 |
+
*Returns:* `m_.ok()`.
|
| 4177 |
+
|
| 4178 |
+
``` cpp
|
| 4179 |
+
constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
|
| 4180 |
+
```
|
| 4181 |
+
|
| 4182 |
+
*Returns:* `x.month() == y.month()`.
|
| 4183 |
+
|
| 4184 |
+
``` cpp
|
| 4185 |
+
constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
|
| 4186 |
+
```
|
| 4187 |
+
|
| 4188 |
+
*Returns:* `x.month() <=> y.month()`.
|
| 4189 |
+
|
| 4190 |
+
``` cpp
|
| 4191 |
+
template<class charT, class traits>
|
| 4192 |
+
basic_ostream<charT, traits>&
|
| 4193 |
+
operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
|
| 4194 |
+
```
|
| 4195 |
+
|
| 4196 |
+
*Effects:* Equivalent to:
|
| 4197 |
+
|
| 4198 |
+
``` cpp
|
| 4199 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/last"), mdl.month());
|
| 4200 |
+
```
|
| 4201 |
+
|
| 4202 |
+
### Class `month_weekday` <a id="time.cal.mwd">[[time.cal.mwd]]</a>
|
| 4203 |
+
|
| 4204 |
+
#### Overview <a id="time.cal.mwd.overview">[[time.cal.mwd.overview]]</a>
|
| 4205 |
+
|
| 4206 |
+
``` cpp
|
| 4207 |
+
namespace std::chrono {
|
| 4208 |
+
class month_weekday {
|
| 4209 |
+
chrono::month m_; // exposition only
|
| 4210 |
+
chrono::weekday_indexed wdi_; // exposition only
|
| 4211 |
+
public:
|
| 4212 |
+
constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
|
| 4213 |
+
|
| 4214 |
+
constexpr chrono::month month() const noexcept;
|
| 4215 |
+
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
|
| 4216 |
+
constexpr bool ok() const noexcept;
|
| 4217 |
+
};
|
| 4218 |
+
}
|
| 4219 |
+
```
|
| 4220 |
+
|
| 4221 |
+
`month_weekday` represents the nᵗʰ weekday of a month, of an as yet
|
| 4222 |
+
unspecified year. To do this the `month_weekday` stores a `month` and a
|
| 4223 |
+
`weekday_indexed`.
|
| 4224 |
+
|
| 4225 |
+
[*Example 1*:
|
| 4226 |
+
|
| 4227 |
+
``` cpp
|
| 4228 |
+
constexpr auto mwd
|
| 4229 |
+
= February/Tuesday[3]; // mwd is the third Tuesday of February of an as yet unspecified year
|
| 4230 |
+
static_assert(mwd.month() == February);
|
| 4231 |
+
static_assert(mwd.weekday_indexed() == Tuesday[3]);
|
| 4232 |
+
```
|
| 4233 |
+
|
| 4234 |
+
— *end example*]
|
| 4235 |
+
|
| 4236 |
+
`month_weekday` is a trivially copyable and standard-layout class type.
|
| 4237 |
+
|
| 4238 |
+
#### Member functions <a id="time.cal.mwd.members">[[time.cal.mwd.members]]</a>
|
| 4239 |
+
|
| 4240 |
+
``` cpp
|
| 4241 |
+
constexpr month_weekday(const chrono::month& m, const chrono::weekday_indexed& wdi) noexcept;
|
| 4242 |
+
```
|
| 4243 |
+
|
| 4244 |
+
*Effects:* Initializes `m_` with `m`, and `wdi_` with `wdi`.
|
| 4245 |
+
|
| 4246 |
+
``` cpp
|
| 4247 |
+
constexpr chrono::month month() const noexcept;
|
| 4248 |
+
```
|
| 4249 |
+
|
| 4250 |
+
*Returns:* `m_`.
|
| 4251 |
+
|
| 4252 |
+
``` cpp
|
| 4253 |
+
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
|
| 4254 |
+
```
|
| 4255 |
+
|
| 4256 |
+
*Returns:* `wdi_`.
|
| 4257 |
+
|
| 4258 |
+
``` cpp
|
| 4259 |
+
constexpr bool ok() const noexcept;
|
| 4260 |
+
```
|
| 4261 |
+
|
| 4262 |
+
*Returns:* `m_.ok() && wdi_.ok()`.
|
| 4263 |
+
|
| 4264 |
+
#### Non-member functions <a id="time.cal.mwd.nonmembers">[[time.cal.mwd.nonmembers]]</a>
|
| 4265 |
+
|
| 4266 |
+
``` cpp
|
| 4267 |
+
constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
|
| 4268 |
+
```
|
| 4269 |
+
|
| 4270 |
+
*Returns:*
|
| 4271 |
+
`x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed()`.
|
| 4272 |
+
|
| 4273 |
+
``` cpp
|
| 4274 |
+
template<class charT, class traits>
|
| 4275 |
+
basic_ostream<charT, traits>&
|
| 4276 |
+
operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
|
| 4277 |
+
```
|
| 4278 |
+
|
| 4279 |
+
*Effects:* Equivalent to:
|
| 4280 |
+
|
| 4281 |
+
``` cpp
|
| 4282 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4283 |
+
mwd.month(), mwd.weekday_indexed());
|
| 4284 |
+
```
|
| 4285 |
+
|
| 4286 |
+
### Class `month_weekday_last` <a id="time.cal.mwdlast">[[time.cal.mwdlast]]</a>
|
| 4287 |
+
|
| 4288 |
+
#### Overview <a id="time.cal.mwdlast.overview">[[time.cal.mwdlast.overview]]</a>
|
| 4289 |
+
|
| 4290 |
+
``` cpp
|
| 4291 |
+
namespace std::chrono {
|
| 4292 |
+
class month_weekday_last {
|
| 4293 |
+
chrono::month m_; // exposition only
|
| 4294 |
+
chrono::weekday_last wdl_; // exposition only
|
| 4295 |
+
public:
|
| 4296 |
+
constexpr month_weekday_last(const chrono::month& m,
|
| 4297 |
+
const chrono::weekday_last& wdl) noexcept;
|
| 4298 |
+
|
| 4299 |
+
constexpr chrono::month month() const noexcept;
|
| 4300 |
+
constexpr chrono::weekday_last weekday_last() const noexcept;
|
| 4301 |
+
constexpr bool ok() const noexcept;
|
| 4302 |
+
};
|
| 4303 |
+
}
|
| 4304 |
+
```
|
| 4305 |
+
|
| 4306 |
+
`month_weekday_last` represents the last weekday of a month, of an as
|
| 4307 |
+
yet unspecified year. To do this the `month_weekday_last` stores a
|
| 4308 |
+
`month` and a `weekday_last`.
|
| 4309 |
+
|
| 4310 |
+
[*Example 1*:
|
| 4311 |
+
|
| 4312 |
+
``` cpp
|
| 4313 |
+
constexpr auto mwd
|
| 4314 |
+
= February/Tuesday[last]; // mwd is the last Tuesday of February of an as yet unspecified year
|
| 4315 |
+
static_assert(mwd.month() == February);
|
| 4316 |
+
static_assert(mwd.weekday_last() == Tuesday[last]);
|
| 4317 |
+
```
|
| 4318 |
+
|
| 4319 |
+
— *end example*]
|
| 4320 |
+
|
| 4321 |
+
`month_weekday_last` is a trivially copyable and standard-layout class
|
| 4322 |
+
type.
|
| 4323 |
+
|
| 4324 |
+
#### Member functions <a id="time.cal.mwdlast.members">[[time.cal.mwdlast.members]]</a>
|
| 4325 |
+
|
| 4326 |
+
``` cpp
|
| 4327 |
+
constexpr month_weekday_last(const chrono::month& m,
|
| 4328 |
+
const chrono::weekday_last& wdl) noexcept;
|
| 4329 |
+
```
|
| 4330 |
+
|
| 4331 |
+
*Effects:* Initializes `m_` with `m`, and `wdl_` with `wdl`.
|
| 4332 |
+
|
| 4333 |
+
``` cpp
|
| 4334 |
+
constexpr chrono::month month() const noexcept;
|
| 4335 |
+
```
|
| 4336 |
+
|
| 4337 |
+
*Returns:* `m_`.
|
| 4338 |
+
|
| 4339 |
+
``` cpp
|
| 4340 |
+
constexpr chrono::weekday_last weekday_last() const noexcept;
|
| 4341 |
+
```
|
| 4342 |
+
|
| 4343 |
+
*Returns:* `wdl_`.
|
| 4344 |
+
|
| 4345 |
+
``` cpp
|
| 4346 |
+
constexpr bool ok() const noexcept;
|
| 4347 |
+
```
|
| 4348 |
+
|
| 4349 |
+
*Returns:* `m_.ok() && wdl_.ok()`.
|
| 4350 |
+
|
| 4351 |
+
#### Non-member functions <a id="time.cal.mwdlast.nonmembers">[[time.cal.mwdlast.nonmembers]]</a>
|
| 4352 |
+
|
| 4353 |
+
``` cpp
|
| 4354 |
+
constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
|
| 4355 |
+
```
|
| 4356 |
+
|
| 4357 |
+
*Returns:*
|
| 4358 |
+
`x.month() == y.month() && x.weekday_last() == y.weekday_last()`.
|
| 4359 |
+
|
| 4360 |
+
``` cpp
|
| 4361 |
+
template<class charT, class traits>
|
| 4362 |
+
basic_ostream<charT, traits>&
|
| 4363 |
+
operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
|
| 4364 |
+
```
|
| 4365 |
+
|
| 4366 |
+
*Effects:* Equivalent to:
|
| 4367 |
+
|
| 4368 |
+
``` cpp
|
| 4369 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4370 |
+
mwdl.month(), mwdl.weekday_last());
|
| 4371 |
+
```
|
| 4372 |
+
|
| 4373 |
+
### Class `year_month` <a id="time.cal.ym">[[time.cal.ym]]</a>
|
| 4374 |
+
|
| 4375 |
+
#### Overview <a id="time.cal.ym.overview">[[time.cal.ym.overview]]</a>
|
| 4376 |
+
|
| 4377 |
+
``` cpp
|
| 4378 |
+
namespace std::chrono {
|
| 4379 |
+
class year_month {
|
| 4380 |
+
chrono::year y_; // exposition only
|
| 4381 |
+
chrono::month m_; // exposition only
|
| 4382 |
+
|
| 4383 |
+
public:
|
| 4384 |
+
year_month() = default;
|
| 4385 |
+
constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
|
| 4386 |
+
|
| 4387 |
+
constexpr chrono::year year() const noexcept;
|
| 4388 |
+
constexpr chrono::month month() const noexcept;
|
| 4389 |
+
|
| 4390 |
+
constexpr year_month& operator+=(const months& dm) noexcept;
|
| 4391 |
+
constexpr year_month& operator-=(const months& dm) noexcept;
|
| 4392 |
+
constexpr year_month& operator+=(const years& dy) noexcept;
|
| 4393 |
+
constexpr year_month& operator-=(const years& dy) noexcept;
|
| 4394 |
+
|
| 4395 |
+
constexpr bool ok() const noexcept;
|
| 4396 |
+
};
|
| 4397 |
+
}
|
| 4398 |
+
```
|
| 4399 |
+
|
| 4400 |
+
`year_month` represents a specific month of a specific year, but with an
|
| 4401 |
+
unspecified day. `year_month` is a field-based time point with a
|
| 4402 |
+
resolution of `months`. `year_month` meets the *Cpp17EqualityComparable*
|
| 4403 |
+
([[cpp17.equalitycomparable]]) and *Cpp17LessThanComparable* (
|
| 4404 |
+
[[cpp17.lessthancomparable]]) requirements.
|
| 4405 |
+
|
| 4406 |
+
`year_month` is a trivially copyable and standard-layout class type.
|
| 4407 |
+
|
| 4408 |
+
#### Member functions <a id="time.cal.ym.members">[[time.cal.ym.members]]</a>
|
| 4409 |
+
|
| 4410 |
+
``` cpp
|
| 4411 |
+
constexpr year_month(const chrono::year& y, const chrono::month& m) noexcept;
|
| 4412 |
+
```
|
| 4413 |
+
|
| 4414 |
+
*Effects:* Initializes `y_` with `y`, and `m_` with `m`.
|
| 4415 |
+
|
| 4416 |
+
``` cpp
|
| 4417 |
+
constexpr chrono::year year() const noexcept;
|
| 4418 |
+
```
|
| 4419 |
+
|
| 4420 |
+
*Returns:* `y_`.
|
| 4421 |
+
|
| 4422 |
+
``` cpp
|
| 4423 |
+
constexpr chrono::month month() const noexcept;
|
| 4424 |
+
```
|
| 4425 |
+
|
| 4426 |
+
*Returns:* `m_`.
|
| 4427 |
+
|
| 4428 |
+
``` cpp
|
| 4429 |
+
constexpr year_month& operator+=(const months& dm) noexcept;
|
| 4430 |
+
```
|
| 4431 |
+
|
| 4432 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4433 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4434 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4435 |
+
[[over.ics.rank]].
|
| 4436 |
+
|
| 4437 |
+
*Effects:* `*this = *this + dm`.
|
| 4438 |
+
|
| 4439 |
+
*Returns:* `*this`.
|
| 4440 |
+
|
| 4441 |
+
``` cpp
|
| 4442 |
+
constexpr year_month& operator-=(const months& dm) noexcept;
|
| 4443 |
+
```
|
| 4444 |
+
|
| 4445 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4446 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4447 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4448 |
+
[[over.ics.rank]].
|
| 4449 |
+
|
| 4450 |
+
*Effects:* `*this = *this - dm`.
|
| 4451 |
+
|
| 4452 |
+
*Returns:* `*this`.
|
| 4453 |
+
|
| 4454 |
+
``` cpp
|
| 4455 |
+
constexpr year_month& operator+=(const years& dy) noexcept;
|
| 4456 |
+
```
|
| 4457 |
+
|
| 4458 |
+
*Effects:* `*this = *this + dy`.
|
| 4459 |
+
|
| 4460 |
+
*Returns:* `*this`.
|
| 4461 |
+
|
| 4462 |
+
``` cpp
|
| 4463 |
+
constexpr year_month& operator-=(const years& dy) noexcept;
|
| 4464 |
+
```
|
| 4465 |
+
|
| 4466 |
+
*Effects:* `*this = *this - dy`.
|
| 4467 |
+
|
| 4468 |
+
*Returns:* `*this`.
|
| 4469 |
+
|
| 4470 |
+
``` cpp
|
| 4471 |
+
constexpr bool ok() const noexcept;
|
| 4472 |
+
```
|
| 4473 |
+
|
| 4474 |
+
*Returns:* `y_.ok() && m_.ok()`.
|
| 4475 |
+
|
| 4476 |
+
#### Non-member functions <a id="time.cal.ym.nonmembers">[[time.cal.ym.nonmembers]]</a>
|
| 4477 |
+
|
| 4478 |
+
``` cpp
|
| 4479 |
+
constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
|
| 4480 |
+
```
|
| 4481 |
+
|
| 4482 |
+
*Returns:* `x.year() == y.year() && x.month() == y.month()`.
|
| 4483 |
+
|
| 4484 |
+
``` cpp
|
| 4485 |
+
constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
|
| 4486 |
+
```
|
| 4487 |
+
|
| 4488 |
+
*Effects:* Equivalent to:
|
| 4489 |
+
|
| 4490 |
+
``` cpp
|
| 4491 |
+
if (auto c = x.year() <=> y.year(); c != 0) return c;
|
| 4492 |
+
return x.month() <=> y.month();
|
| 4493 |
+
```
|
| 4494 |
+
|
| 4495 |
+
``` cpp
|
| 4496 |
+
constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
|
| 4497 |
+
```
|
| 4498 |
+
|
| 4499 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4500 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4501 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4502 |
+
[[over.ics.rank]].
|
| 4503 |
+
|
| 4504 |
+
*Returns:* A `year_month` value `z` such that `z.ok() && z - ym == dm`
|
| 4505 |
+
is `true`.
|
| 4506 |
+
|
| 4507 |
+
*Complexity:* 𝑂(1) with respect to the value of `dm`.
|
| 4508 |
+
|
| 4509 |
+
``` cpp
|
| 4510 |
+
constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
|
| 4511 |
+
```
|
| 4512 |
+
|
| 4513 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4514 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4515 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4516 |
+
[[over.ics.rank]].
|
| 4517 |
+
|
| 4518 |
+
*Returns:* `ym + dm`.
|
| 4519 |
+
|
| 4520 |
+
``` cpp
|
| 4521 |
+
constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
|
| 4522 |
+
```
|
| 4523 |
+
|
| 4524 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4525 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4526 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4527 |
+
[[over.ics.rank]].
|
| 4528 |
+
|
| 4529 |
+
*Returns:* `ym + -dm`.
|
| 4530 |
+
|
| 4531 |
+
``` cpp
|
| 4532 |
+
constexpr months operator-(const year_month& x, const year_month& y) noexcept;
|
| 4533 |
+
```
|
| 4534 |
+
|
| 4535 |
+
*Returns:*
|
| 4536 |
+
|
| 4537 |
+
``` cpp
|
| 4538 |
+
x.year() - y.year() + months{static_cast<int>(unsigned{x.month()}) -
|
| 4539 |
+
static_cast<int>(unsigned{y.month()})}
|
| 4540 |
+
```
|
| 4541 |
+
|
| 4542 |
+
``` cpp
|
| 4543 |
+
constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
|
| 4544 |
+
```
|
| 4545 |
+
|
| 4546 |
+
*Returns:* `(ym.year() + dy) / ym.month()`.
|
| 4547 |
+
|
| 4548 |
+
``` cpp
|
| 4549 |
+
constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
|
| 4550 |
+
```
|
| 4551 |
+
|
| 4552 |
+
*Returns:* `ym + dy`.
|
| 4553 |
+
|
| 4554 |
+
``` cpp
|
| 4555 |
+
constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
|
| 4556 |
+
```
|
| 4557 |
+
|
| 4558 |
+
*Returns:* `ym + -dy`.
|
| 4559 |
+
|
| 4560 |
+
``` cpp
|
| 4561 |
+
template<class charT, class traits>
|
| 4562 |
+
basic_ostream<charT, traits>&
|
| 4563 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
|
| 4564 |
+
```
|
| 4565 |
+
|
| 4566 |
+
*Effects:* Equivalent to:
|
| 4567 |
+
|
| 4568 |
+
``` cpp
|
| 4569 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 4570 |
+
ym.year(), ym.month());
|
| 4571 |
+
```
|
| 4572 |
+
|
| 4573 |
+
``` cpp
|
| 4574 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 4575 |
+
basic_istream<charT, traits>&
|
| 4576 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 4577 |
+
year_month& ym, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 4578 |
+
minutes* offset = nullptr);
|
| 4579 |
+
```
|
| 4580 |
+
|
| 4581 |
+
*Effects:* Attempts to parse the input stream `is` into the `year_month`
|
| 4582 |
+
`ym` using the format flags given in the NTCTS `fmt` as specified in
|
| 4583 |
+
[[time.parse]]. If the parse fails to decode a valid `year_month`,
|
| 4584 |
+
`is.setstate(ios_base::failbit)` is called and `ym` is not modified. If
|
| 4585 |
+
`%Z` is used and successfully parsed, that value will be assigned to
|
| 4586 |
+
`*abbrev` if `abbrev` is non-null. If `%z` (or a modified variant) is
|
| 4587 |
+
used and successfully parsed, that value will be assigned to `*offset`
|
| 4588 |
+
if `offset` is non-null.
|
| 4589 |
+
|
| 4590 |
+
*Returns:* `is`.
|
| 4591 |
+
|
| 4592 |
+
### Class `year_month_day` <a id="time.cal.ymd">[[time.cal.ymd]]</a>
|
| 4593 |
+
|
| 4594 |
+
#### Overview <a id="time.cal.ymd.overview">[[time.cal.ymd.overview]]</a>
|
| 4595 |
+
|
| 4596 |
+
``` cpp
|
| 4597 |
+
namespace std::chrono {
|
| 4598 |
+
class year_month_day {
|
| 4599 |
+
chrono::year y_; // exposition only
|
| 4600 |
+
chrono::month m_; // exposition only
|
| 4601 |
+
chrono::day d_; // exposition only
|
| 4602 |
+
|
| 4603 |
+
public:
|
| 4604 |
+
year_month_day() = default;
|
| 4605 |
+
constexpr year_month_day(const chrono::year& y, const chrono::month& m,
|
| 4606 |
+
const chrono::day& d) noexcept;
|
| 4607 |
+
constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
|
| 4608 |
+
constexpr year_month_day(const sys_days& dp) noexcept;
|
| 4609 |
+
constexpr explicit year_month_day(const local_days& dp) noexcept;
|
| 4610 |
+
|
| 4611 |
+
constexpr year_month_day& operator+=(const months& m) noexcept;
|
| 4612 |
+
constexpr year_month_day& operator-=(const months& m) noexcept;
|
| 4613 |
+
constexpr year_month_day& operator+=(const years& y) noexcept;
|
| 4614 |
+
constexpr year_month_day& operator-=(const years& y) noexcept;
|
| 4615 |
+
|
| 4616 |
+
constexpr chrono::year year() const noexcept;
|
| 4617 |
+
constexpr chrono::month month() const noexcept;
|
| 4618 |
+
constexpr chrono::day day() const noexcept;
|
| 4619 |
+
|
| 4620 |
+
constexpr operator sys_days() const noexcept;
|
| 4621 |
+
constexpr explicit operator local_days() const noexcept;
|
| 4622 |
+
constexpr bool ok() const noexcept;
|
| 4623 |
+
};
|
| 4624 |
+
}
|
| 4625 |
+
```
|
| 4626 |
+
|
| 4627 |
+
`year_month_day` represents a specific year, month, and day.
|
| 4628 |
+
`year_month_day` is a field-based time point with a resolution of
|
| 4629 |
+
`days`.
|
| 4630 |
+
|
| 4631 |
+
[*Note 1*: `year_month_day` supports `years`- and `months`-oriented
|
| 4632 |
+
arithmetic, but not `days`-oriented arithmetic. For the latter, there is
|
| 4633 |
+
a conversion to `sys_days`, which efficiently supports `days`-oriented
|
| 4634 |
+
arithmetic. — *end note*]
|
| 4635 |
+
|
| 4636 |
+
`year_month_day` meets the *Cpp17EqualityComparable* (
|
| 4637 |
+
[[cpp17.equalitycomparable]]) and *Cpp17LessThanComparable* (
|
| 4638 |
+
[[cpp17.lessthancomparable]]) requirements.
|
| 4639 |
+
|
| 4640 |
+
`year_month_day` is a trivially copyable and standard-layout class type.
|
| 4641 |
+
|
| 4642 |
+
#### Member functions <a id="time.cal.ymd.members">[[time.cal.ymd.members]]</a>
|
| 4643 |
+
|
| 4644 |
+
``` cpp
|
| 4645 |
+
constexpr year_month_day(const chrono::year& y, const chrono::month& m,
|
| 4646 |
+
const chrono::day& d) noexcept;
|
| 4647 |
+
```
|
| 4648 |
+
|
| 4649 |
+
*Effects:* Initializes `y_` with `y`, `m_` with `m`, and `d_` with `d`.
|
| 4650 |
+
|
| 4651 |
+
``` cpp
|
| 4652 |
+
constexpr year_month_day(const year_month_day_last& ymdl) noexcept;
|
| 4653 |
+
```
|
| 4654 |
+
|
| 4655 |
+
*Effects:* Initializes `y_` with `ymdl.year()`, `m_` with
|
| 4656 |
+
`ymdl.month()`, and `d_` with `ymdl.day()`.
|
| 4657 |
+
|
| 4658 |
+
[*Note 1*: This conversion from `year_month_day_last` to
|
| 4659 |
+
`year_month_day` may be more efficient than converting a
|
| 4660 |
+
`year_month_day_last` to a `sys_days`, and then converting that
|
| 4661 |
+
`sys_days` to a `year_month_day`. — *end note*]
|
| 4662 |
+
|
| 4663 |
+
``` cpp
|
| 4664 |
+
constexpr year_month_day(const sys_days& dp) noexcept;
|
| 4665 |
+
```
|
| 4666 |
+
|
| 4667 |
+
*Effects:* Constructs an object of type `year_month_day` that
|
| 4668 |
+
corresponds to the date represented by `dp`.
|
| 4669 |
+
|
| 4670 |
+
*Remarks:* For any value `ymd` of type `year_month_day` for which
|
| 4671 |
+
`ymd.ok()` is `true`, `ymd == year_month_day{sys_days{ymd}}` is `true`.
|
| 4672 |
+
|
| 4673 |
+
``` cpp
|
| 4674 |
+
constexpr explicit year_month_day(const local_days& dp) noexcept;
|
| 4675 |
+
```
|
| 4676 |
+
|
| 4677 |
+
*Effects:* Equivalent to constructing with
|
| 4678 |
+
`sys_days{dp.time_since_epoch()}`.
|
| 4679 |
+
|
| 4680 |
+
``` cpp
|
| 4681 |
+
constexpr year_month_day& operator+=(const months& m) noexcept;
|
| 4682 |
+
```
|
| 4683 |
+
|
| 4684 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4685 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4686 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4687 |
+
[[over.ics.rank]].
|
| 4688 |
+
|
| 4689 |
+
*Effects:* `*this = *this + m`.
|
| 4690 |
+
|
| 4691 |
+
*Returns:* `*this`.
|
| 4692 |
+
|
| 4693 |
+
``` cpp
|
| 4694 |
+
constexpr year_month_day& operator-=(const months& m) noexcept;
|
| 4695 |
+
```
|
| 4696 |
+
|
| 4697 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4698 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4699 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4700 |
+
[[over.ics.rank]].
|
| 4701 |
+
|
| 4702 |
+
*Effects:* `*this = *this - m`.
|
| 4703 |
+
|
| 4704 |
+
*Returns:* `*this`.
|
| 4705 |
+
|
| 4706 |
+
``` cpp
|
| 4707 |
+
constexpr year_month_day& year_month_day::operator+=(const years& y) noexcept;
|
| 4708 |
+
```
|
| 4709 |
+
|
| 4710 |
+
*Effects:* `*this = *this + y`.
|
| 4711 |
+
|
| 4712 |
+
*Returns:* `*this`.
|
| 4713 |
+
|
| 4714 |
+
``` cpp
|
| 4715 |
+
constexpr year_month_day& year_month_day::operator-=(const years& y) noexcept;
|
| 4716 |
+
```
|
| 4717 |
+
|
| 4718 |
+
*Effects:* `*this = *this - y`.
|
| 4719 |
+
|
| 4720 |
+
*Returns:* `*this`.
|
| 4721 |
+
|
| 4722 |
+
``` cpp
|
| 4723 |
+
constexpr chrono::year year() const noexcept;
|
| 4724 |
+
```
|
| 4725 |
+
|
| 4726 |
+
*Returns:* `y_`.
|
| 4727 |
+
|
| 4728 |
+
``` cpp
|
| 4729 |
+
constexpr chrono::month month() const noexcept;
|
| 4730 |
+
```
|
| 4731 |
+
|
| 4732 |
+
*Returns:* `m_`.
|
| 4733 |
+
|
| 4734 |
+
``` cpp
|
| 4735 |
+
constexpr chrono::day day() const noexcept;
|
| 4736 |
+
```
|
| 4737 |
+
|
| 4738 |
+
*Returns:* `d_`.
|
| 4739 |
+
|
| 4740 |
+
``` cpp
|
| 4741 |
+
constexpr operator sys_days() const noexcept;
|
| 4742 |
+
```
|
| 4743 |
+
|
| 4744 |
+
*Returns:* If `ok()`, returns a `sys_days` holding a count of days from
|
| 4745 |
+
the `sys_days` epoch to `*this` (a negative value if `*this` represents
|
| 4746 |
+
a date prior to the `sys_days` epoch). Otherwise, if
|
| 4747 |
+
`y_.ok() && m_.ok()` is `true`, returns
|
| 4748 |
+
`sys_days{y_/m_/1d} + (d_ - 1d)`. Otherwise the value returned is
|
| 4749 |
+
unspecified.
|
| 4750 |
+
|
| 4751 |
+
*Remarks:* A `sys_days` in the range \[`days{-12687428}`,
|
| 4752 |
+
`days{11248737}`\] which is converted to a `year_month_day` has the same
|
| 4753 |
+
value when converted back to a `sys_days`.
|
| 4754 |
+
|
| 4755 |
+
[*Example 1*:
|
| 4756 |
+
|
| 4757 |
+
``` cpp
|
| 4758 |
+
static_assert(year_month_day{sys_days{2017y/January/0}} == 2016y/December/31);
|
| 4759 |
+
static_assert(year_month_day{sys_days{2017y/January/31}} == 2017y/January/31);
|
| 4760 |
+
static_assert(year_month_day{sys_days{2017y/January/32}} == 2017y/February/1);
|
| 4761 |
+
```
|
| 4762 |
+
|
| 4763 |
+
— *end example*]
|
| 4764 |
+
|
| 4765 |
+
``` cpp
|
| 4766 |
+
constexpr explicit operator local_days() const noexcept;
|
| 4767 |
+
```
|
| 4768 |
+
|
| 4769 |
+
*Returns:* `local_days{sys_days{*this}.time_since_epoch()}`.
|
| 4770 |
+
|
| 4771 |
+
``` cpp
|
| 4772 |
+
constexpr bool ok() const noexcept;
|
| 4773 |
+
```
|
| 4774 |
+
|
| 4775 |
+
*Returns:* If `y_.ok()` is `true`, and `m_.ok()` is `true`, and `d_` is
|
| 4776 |
+
in the range \[`1d`, `(y_/m_/last).day()`\], then returns `true`;
|
| 4777 |
+
otherwise returns `false`.
|
| 4778 |
+
|
| 4779 |
+
#### Non-member functions <a id="time.cal.ymd.nonmembers">[[time.cal.ymd.nonmembers]]</a>
|
| 4780 |
+
|
| 4781 |
+
``` cpp
|
| 4782 |
+
constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
|
| 4783 |
+
```
|
| 4784 |
+
|
| 4785 |
+
*Returns:*
|
| 4786 |
+
`x.year() == y.year() && x.month() == y.month() && x.day() == y.day()`.
|
| 4787 |
+
|
| 4788 |
+
``` cpp
|
| 4789 |
+
constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
|
| 4790 |
+
```
|
| 4791 |
+
|
| 4792 |
+
*Effects:* Equivalent to:
|
| 4793 |
+
|
| 4794 |
+
``` cpp
|
| 4795 |
+
if (auto c = x.year() <=> y.year(); c != 0) return c;
|
| 4796 |
+
if (auto c = x.month() <=> y.month(); c != 0) return c;
|
| 4797 |
+
return x.day() <=> y.day();
|
| 4798 |
+
```
|
| 4799 |
+
|
| 4800 |
+
``` cpp
|
| 4801 |
+
constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
|
| 4802 |
+
```
|
| 4803 |
+
|
| 4804 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4805 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4806 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4807 |
+
[[over.ics.rank]].
|
| 4808 |
+
|
| 4809 |
+
*Returns:* `(ymd.year() / ymd.month() + dm) / ymd.day()`.
|
| 4810 |
+
|
| 4811 |
+
[*Note 1*: If `ymd.day()` is in the range \[`1d`, `28d`\], `ok()` will
|
| 4812 |
+
return `true` for the resultant `year_month_day`. — *end note*]
|
| 4813 |
+
|
| 4814 |
+
``` cpp
|
| 4815 |
+
constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
|
| 4816 |
+
```
|
| 4817 |
+
|
| 4818 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4819 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4820 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4821 |
+
[[over.ics.rank]].
|
| 4822 |
+
|
| 4823 |
+
*Returns:* `ymd + dm`.
|
| 4824 |
+
|
| 4825 |
+
``` cpp
|
| 4826 |
+
constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
|
| 4827 |
+
```
|
| 4828 |
+
|
| 4829 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4830 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4831 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4832 |
+
[[over.ics.rank]].
|
| 4833 |
+
|
| 4834 |
+
*Returns:* `ymd + (-dm)`.
|
| 4835 |
+
|
| 4836 |
+
``` cpp
|
| 4837 |
+
constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
|
| 4838 |
+
```
|
| 4839 |
+
|
| 4840 |
+
*Returns:* `(ymd.year() + dy) / ymd.month() / ymd.day()`.
|
| 4841 |
+
|
| 4842 |
+
[*Note 2*: If `ymd.month()` is February and `ymd.day()` is not in the
|
| 4843 |
+
range \[`1d`, `28d`\], `ok()` may return `false` for the resultant
|
| 4844 |
+
`year_month_day`. — *end note*]
|
| 4845 |
+
|
| 4846 |
+
``` cpp
|
| 4847 |
+
constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
|
| 4848 |
+
```
|
| 4849 |
+
|
| 4850 |
+
*Returns:* `ymd + dy`.
|
| 4851 |
+
|
| 4852 |
+
``` cpp
|
| 4853 |
+
constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
|
| 4854 |
+
```
|
| 4855 |
+
|
| 4856 |
+
*Returns:* `ymd + (-dy)`.
|
| 4857 |
+
|
| 4858 |
+
``` cpp
|
| 4859 |
+
template<class charT, class traits>
|
| 4860 |
+
basic_ostream<charT, traits>&
|
| 4861 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
|
| 4862 |
+
```
|
| 4863 |
+
|
| 4864 |
+
*Effects:* Equivalent to:
|
| 4865 |
+
|
| 4866 |
+
``` cpp
|
| 4867 |
+
return os << (ymd.ok() ?
|
| 4868 |
+
format(STATICALLY-WIDEN<charT>("{:%F}"), ymd) :
|
| 4869 |
+
format(STATICALLY-WIDEN<charT>("{:%F} is not a valid date"), ymd));
|
| 4870 |
+
```
|
| 4871 |
+
|
| 4872 |
+
``` cpp
|
| 4873 |
+
template<class charT, class traits, class Alloc = allocator<charT>>
|
| 4874 |
+
basic_istream<charT, traits>&
|
| 4875 |
+
from_stream(basic_istream<charT, traits>& is, const charT* fmt,
|
| 4876 |
+
year_month_day& ymd, basic_string<charT, traits, Alloc>* abbrev = nullptr,
|
| 4877 |
+
minutes* offset = nullptr);
|
| 4878 |
+
```
|
| 4879 |
+
|
| 4880 |
+
*Effects:* Attempts to parse the input stream `is` into the
|
| 4881 |
+
`year_month_day` `ymd` using the format flags given in the NTCTS `fmt`
|
| 4882 |
+
as specified in [[time.parse]]. If the parse fails to decode a valid
|
| 4883 |
+
`year_month_day`, `is.setstate(ios_base::failbit)` is called and `ymd`
|
| 4884 |
+
is not modified. If `%Z` is used and successfully parsed, that value
|
| 4885 |
+
will be assigned to `*abbrev` if `abbrev` is non-null. If `%z` (or a
|
| 4886 |
+
modified variant) is used and successfully parsed, that value will be
|
| 4887 |
+
assigned to `*offset` if `offset` is non-null.
|
| 4888 |
+
|
| 4889 |
+
*Returns:* `is`.
|
| 4890 |
+
|
| 4891 |
+
### Class `year_month_day_last` <a id="time.cal.ymdlast">[[time.cal.ymdlast]]</a>
|
| 4892 |
+
|
| 4893 |
+
#### Overview <a id="time.cal.ymdlast.overview">[[time.cal.ymdlast.overview]]</a>
|
| 4894 |
+
|
| 4895 |
+
``` cpp
|
| 4896 |
+
namespace std::chrono {
|
| 4897 |
+
class year_month_day_last {
|
| 4898 |
+
chrono::year y_; // exposition only
|
| 4899 |
+
chrono::month_day_last mdl_; // exposition only
|
| 4900 |
+
|
| 4901 |
+
public:
|
| 4902 |
+
constexpr year_month_day_last(const chrono::year& y,
|
| 4903 |
+
const chrono::month_day_last& mdl) noexcept;
|
| 4904 |
+
|
| 4905 |
+
constexpr year_month_day_last& operator+=(const months& m) noexcept;
|
| 4906 |
+
constexpr year_month_day_last& operator-=(const months& m) noexcept;
|
| 4907 |
+
constexpr year_month_day_last& operator+=(const years& y) noexcept;
|
| 4908 |
+
constexpr year_month_day_last& operator-=(const years& y) noexcept;
|
| 4909 |
+
|
| 4910 |
+
constexpr chrono::year year() const noexcept;
|
| 4911 |
+
constexpr chrono::month month() const noexcept;
|
| 4912 |
+
constexpr chrono::month_day_last month_day_last() const noexcept;
|
| 4913 |
+
constexpr chrono::day day() const noexcept;
|
| 4914 |
+
|
| 4915 |
+
constexpr operator sys_days() const noexcept;
|
| 4916 |
+
constexpr explicit operator local_days() const noexcept;
|
| 4917 |
+
constexpr bool ok() const noexcept;
|
| 4918 |
+
};
|
| 4919 |
+
}
|
| 4920 |
+
```
|
| 4921 |
+
|
| 4922 |
+
`year_month_day_last` represents the last day of a specific year and
|
| 4923 |
+
month. `year_month_day_last` is a field-based time point with a
|
| 4924 |
+
resolution of `days`, except that it is restricted to pointing to the
|
| 4925 |
+
last day of a year and month.
|
| 4926 |
+
|
| 4927 |
+
[*Note 1*: `year_month_day_last` supports `years`- and
|
| 4928 |
+
`months`-oriented arithmetic, but not `days`-oriented arithmetic. For
|
| 4929 |
+
the latter, there is a conversion to `sys_days`, which efficiently
|
| 4930 |
+
supports `days`-oriented arithmetic. — *end note*]
|
| 4931 |
+
|
| 4932 |
+
`year_month_day_last` meets the *Cpp17EqualityComparable* (
|
| 4933 |
+
[[cpp17.equalitycomparable]]) and *Cpp17LessThanComparable* (
|
| 4934 |
+
[[cpp17.lessthancomparable]]) requirements.
|
| 4935 |
+
|
| 4936 |
+
`year_month_day_last` is a trivially copyable and standard-layout class
|
| 4937 |
+
type.
|
| 4938 |
+
|
| 4939 |
+
#### Member functions <a id="time.cal.ymdlast.members">[[time.cal.ymdlast.members]]</a>
|
| 4940 |
+
|
| 4941 |
+
``` cpp
|
| 4942 |
+
constexpr year_month_day_last(const chrono::year& y,
|
| 4943 |
+
const chrono::month_day_last& mdl) noexcept;
|
| 4944 |
+
```
|
| 4945 |
+
|
| 4946 |
+
*Effects:* Initializes `y_` with `y` and `mdl_` with `mdl`.
|
| 4947 |
+
|
| 4948 |
+
``` cpp
|
| 4949 |
+
constexpr year_month_day_last& operator+=(const months& m) noexcept;
|
| 4950 |
+
```
|
| 4951 |
+
|
| 4952 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4953 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4954 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4955 |
+
[[over.ics.rank]].
|
| 4956 |
+
|
| 4957 |
+
*Effects:* `*this = *this + m`.
|
| 4958 |
+
|
| 4959 |
+
*Returns:* `*this`.
|
| 4960 |
+
|
| 4961 |
+
``` cpp
|
| 4962 |
+
constexpr year_month_day_last& operator-=(const months& m) noexcept;
|
| 4963 |
+
```
|
| 4964 |
+
|
| 4965 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 4966 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 4967 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 4968 |
+
[[over.ics.rank]].
|
| 4969 |
+
|
| 4970 |
+
*Effects:* `*this = *this - m`.
|
| 4971 |
+
|
| 4972 |
+
*Returns:* `*this`.
|
| 4973 |
+
|
| 4974 |
+
``` cpp
|
| 4975 |
+
constexpr year_month_day_last& operator+=(const years& y) noexcept;
|
| 4976 |
+
```
|
| 4977 |
+
|
| 4978 |
+
*Effects:* `*this = *this + y`.
|
| 4979 |
+
|
| 4980 |
+
*Returns:* `*this`.
|
| 4981 |
+
|
| 4982 |
+
``` cpp
|
| 4983 |
+
constexpr year_month_day_last& operator-=(const years& y) noexcept;
|
| 4984 |
+
```
|
| 4985 |
+
|
| 4986 |
+
*Effects:* `*this = *this - y`.
|
| 4987 |
+
|
| 4988 |
+
*Returns:* `*this`.
|
| 4989 |
+
|
| 4990 |
+
``` cpp
|
| 4991 |
+
constexpr chrono::year year() const noexcept;
|
| 4992 |
+
```
|
| 4993 |
+
|
| 4994 |
+
*Returns:* `y_`.
|
| 4995 |
+
|
| 4996 |
+
``` cpp
|
| 4997 |
+
constexpr chrono::month month() const noexcept;
|
| 4998 |
+
```
|
| 4999 |
+
|
| 5000 |
+
*Returns:* `mdl_.month()`.
|
| 5001 |
+
|
| 5002 |
+
``` cpp
|
| 5003 |
+
constexpr chrono::month_day_last month_day_last() const noexcept;
|
| 5004 |
+
```
|
| 5005 |
+
|
| 5006 |
+
*Returns:* `mdl_`.
|
| 5007 |
+
|
| 5008 |
+
``` cpp
|
| 5009 |
+
constexpr chrono::day day() const noexcept;
|
| 5010 |
+
```
|
| 5011 |
+
|
| 5012 |
+
*Returns:* If `ok()` is `true`, returns a `day` representing the last
|
| 5013 |
+
day of the (`year`, `month`) pair represented by `*this`. Otherwise, the
|
| 5014 |
+
returned value is unspecified.
|
| 5015 |
+
|
| 5016 |
+
[*Note 1*: This value may be computed on demand. — *end note*]
|
| 5017 |
+
|
| 5018 |
+
``` cpp
|
| 5019 |
+
constexpr operator sys_days() const noexcept;
|
| 5020 |
+
```
|
| 5021 |
+
|
| 5022 |
+
*Returns:* `sys_days{year()/month()/day()}`.
|
| 5023 |
+
|
| 5024 |
+
``` cpp
|
| 5025 |
+
constexpr explicit operator local_days() const noexcept;
|
| 5026 |
+
```
|
| 5027 |
+
|
| 5028 |
+
*Returns:* `local_days{sys_days{*this}.time_since_epoch()}`.
|
| 5029 |
+
|
| 5030 |
+
``` cpp
|
| 5031 |
+
constexpr bool ok() const noexcept;
|
| 5032 |
+
```
|
| 5033 |
+
|
| 5034 |
+
*Returns:* `y_.ok() && mdl_.ok()`.
|
| 5035 |
+
|
| 5036 |
+
#### Non-member functions <a id="time.cal.ymdlast.nonmembers">[[time.cal.ymdlast.nonmembers]]</a>
|
| 5037 |
+
|
| 5038 |
+
``` cpp
|
| 5039 |
+
constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
|
| 5040 |
+
```
|
| 5041 |
+
|
| 5042 |
+
*Returns:*
|
| 5043 |
+
`x.year() == y.year() && x.month_day_last() == y.month_day_last()`.
|
| 5044 |
+
|
| 5045 |
+
``` cpp
|
| 5046 |
+
constexpr strong_ordering operator<=>(const year_month_day_last& x,
|
| 5047 |
+
const year_month_day_last& y) noexcept;
|
| 5048 |
+
```
|
| 5049 |
+
|
| 5050 |
+
*Effects:* Equivalent to:
|
| 5051 |
+
|
| 5052 |
+
``` cpp
|
| 5053 |
+
if (auto c = x.year() <=> y.year(); c != 0) return c;
|
| 5054 |
+
return x.month_day_last() <=> y.month_day_last();
|
| 5055 |
+
```
|
| 5056 |
+
|
| 5057 |
+
``` cpp
|
| 5058 |
+
constexpr year_month_day_last
|
| 5059 |
+
operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
|
| 5060 |
+
```
|
| 5061 |
+
|
| 5062 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5063 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5064 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5065 |
+
[[over.ics.rank]].
|
| 5066 |
+
|
| 5067 |
+
*Returns:* `(ymdl.year() / ymdl.month() + dm) / last`.
|
| 5068 |
+
|
| 5069 |
+
``` cpp
|
| 5070 |
+
constexpr year_month_day_last
|
| 5071 |
+
operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
|
| 5072 |
+
```
|
| 5073 |
+
|
| 5074 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5075 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5076 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5077 |
+
[[over.ics.rank]].
|
| 5078 |
+
|
| 5079 |
+
*Returns:* `ymdl + dm`.
|
| 5080 |
+
|
| 5081 |
+
``` cpp
|
| 5082 |
+
constexpr year_month_day_last
|
| 5083 |
+
operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
|
| 5084 |
+
```
|
| 5085 |
+
|
| 5086 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5087 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5088 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5089 |
+
[[over.ics.rank]].
|
| 5090 |
+
|
| 5091 |
+
*Returns:* `ymdl + (-dm)`.
|
| 5092 |
+
|
| 5093 |
+
``` cpp
|
| 5094 |
+
constexpr year_month_day_last
|
| 5095 |
+
operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
|
| 5096 |
+
```
|
| 5097 |
+
|
| 5098 |
+
*Returns:* `{ymdl.year()+dy, ymdl.month_day_last()}`.
|
| 5099 |
+
|
| 5100 |
+
``` cpp
|
| 5101 |
+
constexpr year_month_day_last
|
| 5102 |
+
operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
|
| 5103 |
+
```
|
| 5104 |
+
|
| 5105 |
+
*Returns:* `ymdl + dy`.
|
| 5106 |
+
|
| 5107 |
+
``` cpp
|
| 5108 |
+
constexpr year_month_day_last
|
| 5109 |
+
operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
|
| 5110 |
+
```
|
| 5111 |
+
|
| 5112 |
+
*Returns:* `ymdl + (-dy)`.
|
| 5113 |
+
|
| 5114 |
+
``` cpp
|
| 5115 |
+
template<class charT, class traits>
|
| 5116 |
+
basic_ostream<charT, traits>&
|
| 5117 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
|
| 5118 |
+
```
|
| 5119 |
+
|
| 5120 |
+
*Effects:* Equivalent to:
|
| 5121 |
+
|
| 5122 |
+
``` cpp
|
| 5123 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}"),
|
| 5124 |
+
ymdl.year(), ymdl.month_day_last());
|
| 5125 |
+
```
|
| 5126 |
+
|
| 5127 |
+
### Class `year_month_weekday` <a id="time.cal.ymwd">[[time.cal.ymwd]]</a>
|
| 5128 |
+
|
| 5129 |
+
#### Overview <a id="time.cal.ymwd.overview">[[time.cal.ymwd.overview]]</a>
|
| 5130 |
+
|
| 5131 |
+
``` cpp
|
| 5132 |
+
namespace std::chrono {
|
| 5133 |
+
class year_month_weekday {
|
| 5134 |
+
chrono::year y_; // exposition only
|
| 5135 |
+
chrono::month m_; // exposition only
|
| 5136 |
+
chrono::weekday_indexed wdi_; // exposition only
|
| 5137 |
+
|
| 5138 |
+
public:
|
| 5139 |
+
year_month_weekday() = default;
|
| 5140 |
+
constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
|
| 5141 |
+
const chrono::weekday_indexed& wdi) noexcept;
|
| 5142 |
+
constexpr year_month_weekday(const sys_days& dp) noexcept;
|
| 5143 |
+
constexpr explicit year_month_weekday(const local_days& dp) noexcept;
|
| 5144 |
+
|
| 5145 |
+
constexpr year_month_weekday& operator+=(const months& m) noexcept;
|
| 5146 |
+
constexpr year_month_weekday& operator-=(const months& m) noexcept;
|
| 5147 |
+
constexpr year_month_weekday& operator+=(const years& y) noexcept;
|
| 5148 |
+
constexpr year_month_weekday& operator-=(const years& y) noexcept;
|
| 5149 |
+
|
| 5150 |
+
constexpr chrono::year year() const noexcept;
|
| 5151 |
+
constexpr chrono::month month() const noexcept;
|
| 5152 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 5153 |
+
constexpr unsigned index() const noexcept;
|
| 5154 |
+
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
|
| 5155 |
+
|
| 5156 |
+
constexpr operator sys_days() const noexcept;
|
| 5157 |
+
constexpr explicit operator local_days() const noexcept;
|
| 5158 |
+
constexpr bool ok() const noexcept;
|
| 5159 |
+
};
|
| 5160 |
+
}
|
| 5161 |
+
```
|
| 5162 |
+
|
| 5163 |
+
`year_month_weekday` represents a specific year, month, and nᵗʰ weekday
|
| 5164 |
+
of the month. `year_month_weekday` is a field-based time point with a
|
| 5165 |
+
resolution of `days`.
|
| 5166 |
+
|
| 5167 |
+
[*Note 1*: `year_month_weekday` supports `years`- and `months`-oriented
|
| 5168 |
+
arithmetic, but not `days`-oriented arithmetic. For the latter, there is
|
| 5169 |
+
a conversion to `sys_days`, which efficiently supports `days`-oriented
|
| 5170 |
+
arithmetic. — *end note*]
|
| 5171 |
+
|
| 5172 |
+
`year_month_weekday` meets the *Cpp17EqualityComparable* (
|
| 5173 |
+
[[cpp17.equalitycomparable]]) requirements.
|
| 5174 |
+
|
| 5175 |
+
`year_month_weekday` is a trivially copyable and standard-layout class
|
| 5176 |
+
type.
|
| 5177 |
+
|
| 5178 |
+
#### Member functions <a id="time.cal.ymwd.members">[[time.cal.ymwd.members]]</a>
|
| 5179 |
+
|
| 5180 |
+
``` cpp
|
| 5181 |
+
constexpr year_month_weekday(const chrono::year& y, const chrono::month& m,
|
| 5182 |
+
const chrono::weekday_indexed& wdi) noexcept;
|
| 5183 |
+
```
|
| 5184 |
+
|
| 5185 |
+
*Effects:* Initializes `y_` with `y`, `m_` with `m`, and `wdi_` with
|
| 5186 |
+
`wdi`.
|
| 5187 |
+
|
| 5188 |
+
``` cpp
|
| 5189 |
+
constexpr year_month_weekday(const sys_days& dp) noexcept;
|
| 5190 |
+
```
|
| 5191 |
+
|
| 5192 |
+
*Effects:* Constructs an object of type `year_month_weekday` which
|
| 5193 |
+
corresponds to the date represented by `dp`.
|
| 5194 |
+
|
| 5195 |
+
*Remarks:* For any value `ymdl` of type `year_month_weekday` for which
|
| 5196 |
+
`ymdl.ok()` is `true`, `ymdl == year_month_weekday{sys_days{ymdl}}` is
|
| 5197 |
+
`true`.
|
| 5198 |
+
|
| 5199 |
+
``` cpp
|
| 5200 |
+
constexpr explicit year_month_weekday(const local_days& dp) noexcept;
|
| 5201 |
+
```
|
| 5202 |
+
|
| 5203 |
+
*Effects:* Equivalent to constructing with
|
| 5204 |
+
`sys_days{dp.time_since_epoch()}`.
|
| 5205 |
+
|
| 5206 |
+
``` cpp
|
| 5207 |
+
constexpr year_month_weekday& operator+=(const months& m) noexcept;
|
| 5208 |
+
```
|
| 5209 |
+
|
| 5210 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5211 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5212 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5213 |
+
[[over.ics.rank]].
|
| 5214 |
+
|
| 5215 |
+
*Effects:* `*this = *this + m`.
|
| 5216 |
+
|
| 5217 |
+
*Returns:* `*this`.
|
| 5218 |
+
|
| 5219 |
+
``` cpp
|
| 5220 |
+
constexpr year_month_weekday& operator-=(const months& m) noexcept;
|
| 5221 |
+
```
|
| 5222 |
+
|
| 5223 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5224 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5225 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5226 |
+
[[over.ics.rank]].
|
| 5227 |
+
|
| 5228 |
+
*Effects:* `*this = *this - m`.
|
| 5229 |
+
|
| 5230 |
+
*Returns:* `*this`.
|
| 5231 |
+
|
| 5232 |
+
``` cpp
|
| 5233 |
+
constexpr year_month_weekday& operator+=(const years& y) noexcept;
|
| 5234 |
+
```
|
| 5235 |
+
|
| 5236 |
+
*Effects:* `*this = *this + y`.
|
| 5237 |
+
|
| 5238 |
+
*Returns:* `*this`.
|
| 5239 |
+
|
| 5240 |
+
``` cpp
|
| 5241 |
+
constexpr year_month_weekday& operator-=(const years& y) noexcept;
|
| 5242 |
+
```
|
| 5243 |
+
|
| 5244 |
+
*Effects:* `*this = *this - y`.
|
| 5245 |
+
|
| 5246 |
+
*Returns:* `*this`.
|
| 5247 |
+
|
| 5248 |
+
``` cpp
|
| 5249 |
+
constexpr chrono::year year() const noexcept;
|
| 5250 |
+
```
|
| 5251 |
+
|
| 5252 |
+
*Returns:* `y_`.
|
| 5253 |
+
|
| 5254 |
+
``` cpp
|
| 5255 |
+
constexpr chrono::month month() const noexcept;
|
| 5256 |
+
```
|
| 5257 |
+
|
| 5258 |
+
*Returns:* `m_`.
|
| 5259 |
+
|
| 5260 |
+
``` cpp
|
| 5261 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 5262 |
+
```
|
| 5263 |
+
|
| 5264 |
+
*Returns:* `wdi_.weekday()`.
|
| 5265 |
+
|
| 5266 |
+
``` cpp
|
| 5267 |
+
constexpr unsigned index() const noexcept;
|
| 5268 |
+
```
|
| 5269 |
+
|
| 5270 |
+
*Returns:* `wdi_.index()`.
|
| 5271 |
+
|
| 5272 |
+
``` cpp
|
| 5273 |
+
constexpr chrono::weekday_indexed weekday_indexed() const noexcept;
|
| 5274 |
+
```
|
| 5275 |
+
|
| 5276 |
+
*Returns:* `wdi_`.
|
| 5277 |
+
|
| 5278 |
+
``` cpp
|
| 5279 |
+
constexpr operator sys_days() const noexcept;
|
| 5280 |
+
```
|
| 5281 |
+
|
| 5282 |
+
*Returns:* If `y_.ok() && m_.ok() && wdi_.weekday().ok()`, returns a
|
| 5283 |
+
`sys_days` that represents the date `(index() - 1) * 7` days after the
|
| 5284 |
+
first `weekday()` of `year()/month()`. If `index()` is 0 the returned
|
| 5285 |
+
`sys_days` represents the date 7 days prior to the first `weekday()` of
|
| 5286 |
+
`year()/month()`. Otherwise the returned value is unspecified.
|
| 5287 |
+
|
| 5288 |
+
``` cpp
|
| 5289 |
+
constexpr explicit operator local_days() const noexcept;
|
| 5290 |
+
```
|
| 5291 |
+
|
| 5292 |
+
*Returns:* `local_days{sys_days{*this}.time_since_epoch()}`.
|
| 5293 |
+
|
| 5294 |
+
``` cpp
|
| 5295 |
+
constexpr bool ok() const noexcept;
|
| 5296 |
+
```
|
| 5297 |
+
|
| 5298 |
+
*Returns:* If any of `y_.ok()`, `m_.ok()`, or `wdi_.ok()` is `false`,
|
| 5299 |
+
returns `false`. Otherwise, if `*this` represents a valid date, returns
|
| 5300 |
+
`true`. Otherwise, returns `false`.
|
| 5301 |
+
|
| 5302 |
+
#### Non-member functions <a id="time.cal.ymwd.nonmembers">[[time.cal.ymwd.nonmembers]]</a>
|
| 5303 |
+
|
| 5304 |
+
``` cpp
|
| 5305 |
+
constexpr bool operator==(const year_month_weekday& x, const year_month_weekday& y) noexcept;
|
| 5306 |
+
```
|
| 5307 |
+
|
| 5308 |
+
*Returns:*
|
| 5309 |
+
|
| 5310 |
+
``` cpp
|
| 5311 |
+
x.year() == y.year() && x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed()
|
| 5312 |
+
```
|
| 5313 |
+
|
| 5314 |
+
``` cpp
|
| 5315 |
+
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
|
| 5316 |
+
```
|
| 5317 |
+
|
| 5318 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5319 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5320 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5321 |
+
[[over.ics.rank]].
|
| 5322 |
+
|
| 5323 |
+
*Returns:* `(ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed()`.
|
| 5324 |
+
|
| 5325 |
+
``` cpp
|
| 5326 |
+
constexpr year_month_weekday operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
|
| 5327 |
+
```
|
| 5328 |
+
|
| 5329 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5330 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5331 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5332 |
+
[[over.ics.rank]].
|
| 5333 |
+
|
| 5334 |
+
*Returns:* `ymwd + dm`.
|
| 5335 |
+
|
| 5336 |
+
``` cpp
|
| 5337 |
+
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
|
| 5338 |
+
```
|
| 5339 |
+
|
| 5340 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5341 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5342 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5343 |
+
[[over.ics.rank]].
|
| 5344 |
+
|
| 5345 |
+
*Returns:* `ymwd + (-dm)`.
|
| 5346 |
+
|
| 5347 |
+
``` cpp
|
| 5348 |
+
constexpr year_month_weekday operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 5349 |
+
```
|
| 5350 |
+
|
| 5351 |
+
*Returns:* `{ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()}`.
|
| 5352 |
+
|
| 5353 |
+
``` cpp
|
| 5354 |
+
constexpr year_month_weekday operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
|
| 5355 |
+
```
|
| 5356 |
+
|
| 5357 |
+
*Returns:* `ymwd + dy`.
|
| 5358 |
+
|
| 5359 |
+
``` cpp
|
| 5360 |
+
constexpr year_month_weekday operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
|
| 5361 |
+
```
|
| 5362 |
+
|
| 5363 |
+
*Returns:* `ymwd + (-dy)`.
|
| 5364 |
+
|
| 5365 |
+
``` cpp
|
| 5366 |
+
template<class charT, class traits>
|
| 5367 |
+
basic_ostream<charT, traits>&
|
| 5368 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
|
| 5369 |
+
```
|
| 5370 |
+
|
| 5371 |
+
*Effects:* Equivalent to:
|
| 5372 |
+
|
| 5373 |
+
``` cpp
|
| 5374 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}/{}"),
|
| 5375 |
+
ymwd.year(), ymwd.month(), ymwd.weekday_indexed());
|
| 5376 |
+
```
|
| 5377 |
+
|
| 5378 |
+
### Class `year_month_weekday_last` <a id="time.cal.ymwdlast">[[time.cal.ymwdlast]]</a>
|
| 5379 |
+
|
| 5380 |
+
#### Overview <a id="time.cal.ymwdlast.overview">[[time.cal.ymwdlast.overview]]</a>
|
| 5381 |
+
|
| 5382 |
+
``` cpp
|
| 5383 |
+
namespace std::chrono {
|
| 5384 |
+
class year_month_weekday_last {
|
| 5385 |
+
chrono::year y_; // exposition only
|
| 5386 |
+
chrono::month m_; // exposition only
|
| 5387 |
+
chrono::weekday_last wdl_; // exposition only
|
| 5388 |
+
|
| 5389 |
+
public:
|
| 5390 |
+
constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
|
| 5391 |
+
const chrono::weekday_last& wdl) noexcept;
|
| 5392 |
+
|
| 5393 |
+
constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
|
| 5394 |
+
constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
|
| 5395 |
+
constexpr year_month_weekday_last& operator+=(const years& y) noexcept;
|
| 5396 |
+
constexpr year_month_weekday_last& operator-=(const years& y) noexcept;
|
| 5397 |
+
|
| 5398 |
+
constexpr chrono::year year() const noexcept;
|
| 5399 |
+
constexpr chrono::month month() const noexcept;
|
| 5400 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 5401 |
+
constexpr chrono::weekday_last weekday_last() const noexcept;
|
| 5402 |
+
|
| 5403 |
+
constexpr operator sys_days() const noexcept;
|
| 5404 |
+
constexpr explicit operator local_days() const noexcept;
|
| 5405 |
+
constexpr bool ok() const noexcept;
|
| 5406 |
+
};
|
| 5407 |
+
}
|
| 5408 |
+
```
|
| 5409 |
+
|
| 5410 |
+
`year_month_weekday_last` represents a specific year, month, and last
|
| 5411 |
+
weekday of the month. `year_month_weekday_last` is a field-based time
|
| 5412 |
+
point with a resolution of `days`, except that it is restricted to
|
| 5413 |
+
pointing to the last weekday of a year and month.
|
| 5414 |
+
|
| 5415 |
+
[*Note 1*: `year_month_weekday_last` supports `years`- and
|
| 5416 |
+
`months`-oriented arithmetic, but not `days`-oriented arithmetic. For
|
| 5417 |
+
the latter, there is a conversion to `sys_days`, which efficiently
|
| 5418 |
+
supports `days`-oriented arithmetic. — *end note*]
|
| 5419 |
+
|
| 5420 |
+
`year_month_weekday_last` meets the *Cpp17EqualityComparable* (
|
| 5421 |
+
[[cpp17.equalitycomparable]]) requirements.
|
| 5422 |
+
|
| 5423 |
+
`year_month_weekday_last` is a trivially copyable and standard-layout
|
| 5424 |
+
class type.
|
| 5425 |
+
|
| 5426 |
+
#### Member functions <a id="time.cal.ymwdlast.members">[[time.cal.ymwdlast.members]]</a>
|
| 5427 |
+
|
| 5428 |
+
``` cpp
|
| 5429 |
+
constexpr year_month_weekday_last(const chrono::year& y, const chrono::month& m,
|
| 5430 |
+
const chrono::weekday_last& wdl) noexcept;
|
| 5431 |
+
```
|
| 5432 |
+
|
| 5433 |
+
*Effects:* Initializes `y_` with `y`, `m_` with `m`, and `wdl_` with
|
| 5434 |
+
`wdl`.
|
| 5435 |
+
|
| 5436 |
+
``` cpp
|
| 5437 |
+
constexpr year_month_weekday_last& operator+=(const months& m) noexcept;
|
| 5438 |
+
```
|
| 5439 |
+
|
| 5440 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5441 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5442 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5443 |
+
[[over.ics.rank]].
|
| 5444 |
+
|
| 5445 |
+
*Effects:* `*this = *this + m`.
|
| 5446 |
+
|
| 5447 |
+
*Returns:* `*this`.
|
| 5448 |
+
|
| 5449 |
+
``` cpp
|
| 5450 |
+
constexpr year_month_weekday_last& operator-=(const months& m) noexcept;
|
| 5451 |
+
```
|
| 5452 |
+
|
| 5453 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5454 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5455 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5456 |
+
[[over.ics.rank]].
|
| 5457 |
+
|
| 5458 |
+
*Effects:* `*this = *this - m`.
|
| 5459 |
+
|
| 5460 |
+
*Returns:* `*this`.
|
| 5461 |
+
|
| 5462 |
+
``` cpp
|
| 5463 |
+
constexpr year_month_weekday_last& operator+=(const years& y) noexcept;
|
| 5464 |
+
```
|
| 5465 |
+
|
| 5466 |
+
*Effects:* `*this = *this + y`.
|
| 5467 |
+
|
| 5468 |
+
*Returns:* `*this`.
|
| 5469 |
+
|
| 5470 |
+
``` cpp
|
| 5471 |
+
constexpr year_month_weekday_last& operator-=(const years& y) noexcept;
|
| 5472 |
+
```
|
| 5473 |
+
|
| 5474 |
+
*Effects:* `*this = *this - y`.
|
| 5475 |
+
|
| 5476 |
+
*Returns:* `*this`.
|
| 5477 |
+
|
| 5478 |
+
``` cpp
|
| 5479 |
+
constexpr chrono::year year() const noexcept;
|
| 5480 |
+
```
|
| 5481 |
+
|
| 5482 |
+
*Returns:* `y_`.
|
| 5483 |
+
|
| 5484 |
+
``` cpp
|
| 5485 |
+
constexpr chrono::month month() const noexcept;
|
| 5486 |
+
```
|
| 5487 |
+
|
| 5488 |
+
*Returns:* `m_`.
|
| 5489 |
+
|
| 5490 |
+
``` cpp
|
| 5491 |
+
constexpr chrono::weekday weekday() const noexcept;
|
| 5492 |
+
```
|
| 5493 |
+
|
| 5494 |
+
*Returns:* `wdl_.weekday()`.
|
| 5495 |
+
|
| 5496 |
+
``` cpp
|
| 5497 |
+
constexpr chrono::weekday_last weekday_last() const noexcept;
|
| 5498 |
+
```
|
| 5499 |
+
|
| 5500 |
+
*Returns:* `wdl_`.
|
| 5501 |
+
|
| 5502 |
+
``` cpp
|
| 5503 |
+
constexpr operator sys_days() const noexcept;
|
| 5504 |
+
```
|
| 5505 |
+
|
| 5506 |
+
*Returns:* If `ok() == true`, returns a `sys_days` that represents the
|
| 5507 |
+
last `weekday()` of `year()/month()`. Otherwise the returned value is
|
| 5508 |
+
unspecified.
|
| 5509 |
+
|
| 5510 |
+
``` cpp
|
| 5511 |
+
constexpr explicit operator local_days() const noexcept;
|
| 5512 |
+
```
|
| 5513 |
+
|
| 5514 |
+
*Returns:* `local_days{sys_days{*this}.time_since_epoch()}`.
|
| 5515 |
+
|
| 5516 |
+
``` cpp
|
| 5517 |
+
constexpr bool ok() const noexcept;
|
| 5518 |
+
```
|
| 5519 |
+
|
| 5520 |
+
*Returns:* `y_.ok() && m_.ok() && wdl_.ok()`.
|
| 5521 |
+
|
| 5522 |
+
#### Non-member functions <a id="time.cal.ymwdlast.nonmembers">[[time.cal.ymwdlast.nonmembers]]</a>
|
| 5523 |
+
|
| 5524 |
+
``` cpp
|
| 5525 |
+
constexpr bool operator==(const year_month_weekday_last& x,
|
| 5526 |
+
const year_month_weekday_last& y) noexcept;
|
| 5527 |
+
```
|
| 5528 |
+
|
| 5529 |
+
*Returns:*
|
| 5530 |
+
|
| 5531 |
+
``` cpp
|
| 5532 |
+
x.year() == y.year() && x.month() == y.month() && x.weekday_last() == y.weekday_last()
|
| 5533 |
+
```
|
| 5534 |
+
|
| 5535 |
+
``` cpp
|
| 5536 |
+
constexpr year_month_weekday_last
|
| 5537 |
+
operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
| 5538 |
+
```
|
| 5539 |
+
|
| 5540 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5541 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5542 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5543 |
+
[[over.ics.rank]].
|
| 5544 |
+
|
| 5545 |
+
*Returns:* `(ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last()`.
|
| 5546 |
+
|
| 5547 |
+
``` cpp
|
| 5548 |
+
constexpr year_month_weekday_last
|
| 5549 |
+
operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
|
| 5550 |
+
```
|
| 5551 |
+
|
| 5552 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5553 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5554 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5555 |
+
[[over.ics.rank]].
|
| 5556 |
+
|
| 5557 |
+
*Returns:* `ymwdl + dm`.
|
| 5558 |
+
|
| 5559 |
+
``` cpp
|
| 5560 |
+
constexpr year_month_weekday_last
|
| 5561 |
+
operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
|
| 5562 |
+
```
|
| 5563 |
+
|
| 5564 |
+
*Constraints:* If the argument supplied by the caller for the `months`
|
| 5565 |
+
parameter is convertible to `years`, its implicit conversion sequence to
|
| 5566 |
+
`years` is worse than its implicit conversion sequence to `months`
|
| 5567 |
+
[[over.ics.rank]].
|
| 5568 |
+
|
| 5569 |
+
*Returns:* `ymwdl + (-dm)`.
|
| 5570 |
+
|
| 5571 |
+
``` cpp
|
| 5572 |
+
constexpr year_month_weekday_last
|
| 5573 |
+
operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
| 5574 |
+
```
|
| 5575 |
+
|
| 5576 |
+
*Returns:* `{ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()}`.
|
| 5577 |
+
|
| 5578 |
+
``` cpp
|
| 5579 |
+
constexpr year_month_weekday_last
|
| 5580 |
+
operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
|
| 5581 |
+
```
|
| 5582 |
+
|
| 5583 |
+
*Returns:* `ymwdl + dy`.
|
| 5584 |
+
|
| 5585 |
+
``` cpp
|
| 5586 |
+
constexpr year_month_weekday_last
|
| 5587 |
+
operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
|
| 5588 |
+
```
|
| 5589 |
+
|
| 5590 |
+
*Returns:* `ymwdl + (-dy)`.
|
| 5591 |
+
|
| 5592 |
+
``` cpp
|
| 5593 |
+
template<class charT, class traits>
|
| 5594 |
+
basic_ostream<charT, traits>&
|
| 5595 |
+
operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
|
| 5596 |
+
```
|
| 5597 |
+
|
| 5598 |
+
*Effects:* Equivalent to:
|
| 5599 |
+
|
| 5600 |
+
``` cpp
|
| 5601 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{}/{}/{}"),
|
| 5602 |
+
ymwdl.year(), ymwdl.month(), ymwdl.weekday_last());
|
| 5603 |
+
```
|
| 5604 |
+
|
| 5605 |
+
### Conventional syntax operators <a id="time.cal.operators">[[time.cal.operators]]</a>
|
| 5606 |
+
|
| 5607 |
+
A set of overloaded `operator/` functions provides a conventional syntax
|
| 5608 |
+
for the creation of civil calendar dates.
|
| 5609 |
+
|
| 5610 |
+
[*Note 1*:
|
| 5611 |
+
|
| 5612 |
+
The year, month, and day are accepted in any of the following 3 orders:
|
| 5613 |
+
|
| 5614 |
+
``` cpp
|
| 5615 |
+
year/month/day
|
| 5616 |
+
month/day/year
|
| 5617 |
+
day/month/year
|
| 5618 |
+
```
|
| 5619 |
+
|
| 5620 |
+
Anywhere a `day` is required, any of the following can also be
|
| 5621 |
+
specified:
|
| 5622 |
+
|
| 5623 |
+
``` cpp
|
| 5624 |
+
last
|
| 5625 |
+
weekday[i]
|
| 5626 |
+
weekday[last]
|
| 5627 |
+
```
|
| 5628 |
+
|
| 5629 |
+
— *end note*]
|
| 5630 |
+
|
| 5631 |
+
[*Note 2*:
|
| 5632 |
+
|
| 5633 |
+
Partial-date types such as `year_month` and `month_day` can be created
|
| 5634 |
+
by not applying the second division operator for any of the three
|
| 5635 |
+
orders. For example:
|
| 5636 |
+
|
| 5637 |
+
``` cpp
|
| 5638 |
+
year_month ym = 2015y/April;
|
| 5639 |
+
month_day md1 = April/4;
|
| 5640 |
+
month_day md2 = 4d/April;
|
| 5641 |
+
```
|
| 5642 |
+
|
| 5643 |
+
— *end note*]
|
| 5644 |
+
|
| 5645 |
+
[*Example 1*:
|
| 5646 |
+
|
| 5647 |
+
``` cpp
|
| 5648 |
+
auto a = 2015/4/4; // a == int(125)
|
| 5649 |
+
auto b = 2015y/4/4; // b == year_month_day{year(2015), month(4), day(4)}
|
| 5650 |
+
auto c = 2015y/4d/April; // error: no viable operator/ for first /
|
| 5651 |
+
auto d = 2015/April/4; // error: no viable operator/ for first /
|
| 5652 |
+
```
|
| 5653 |
+
|
| 5654 |
+
— *end example*]
|
| 5655 |
+
|
| 5656 |
+
``` cpp
|
| 5657 |
+
constexpr year_month
|
| 5658 |
+
operator/(const year& y, const month& m) noexcept;
|
| 5659 |
+
```
|
| 5660 |
+
|
| 5661 |
+
*Returns:* `{y, m}`.
|
| 5662 |
+
|
| 5663 |
+
``` cpp
|
| 5664 |
+
constexpr year_month
|
| 5665 |
+
operator/(const year& y, int m) noexcept;
|
| 5666 |
+
```
|
| 5667 |
+
|
| 5668 |
+
*Returns:* `y / month(m)`.
|
| 5669 |
+
|
| 5670 |
+
``` cpp
|
| 5671 |
+
constexpr month_day
|
| 5672 |
+
operator/(const month& m, const day& d) noexcept;
|
| 5673 |
+
```
|
| 5674 |
+
|
| 5675 |
+
*Returns:* `{m, d}`.
|
| 5676 |
+
|
| 5677 |
+
``` cpp
|
| 5678 |
+
constexpr month_day
|
| 5679 |
+
operator/(const month& m, int d) noexcept;
|
| 5680 |
+
```
|
| 5681 |
+
|
| 5682 |
+
*Returns:* `m / day(d)`.
|
| 5683 |
+
|
| 5684 |
+
``` cpp
|
| 5685 |
+
constexpr month_day
|
| 5686 |
+
operator/(int m, const day& d) noexcept;
|
| 5687 |
+
```
|
| 5688 |
+
|
| 5689 |
+
*Returns:* `month(m) / d`.
|
| 5690 |
+
|
| 5691 |
+
``` cpp
|
| 5692 |
+
constexpr month_day
|
| 5693 |
+
operator/(const day& d, const month& m) noexcept;
|
| 5694 |
+
```
|
| 5695 |
+
|
| 5696 |
+
*Returns:* `m / d`.
|
| 5697 |
+
|
| 5698 |
+
``` cpp
|
| 5699 |
+
constexpr month_day
|
| 5700 |
+
operator/(const day& d, int m) noexcept;
|
| 5701 |
+
```
|
| 5702 |
+
|
| 5703 |
+
*Returns:* `month(m) / d`.
|
| 5704 |
+
|
| 5705 |
+
``` cpp
|
| 5706 |
+
constexpr month_day_last
|
| 5707 |
+
operator/(const month& m, last_spec) noexcept;
|
| 5708 |
+
```
|
| 5709 |
+
|
| 5710 |
+
*Returns:* `month_day_last{m}`.
|
| 5711 |
+
|
| 5712 |
+
``` cpp
|
| 5713 |
+
constexpr month_day_last
|
| 5714 |
+
operator/(int m, last_spec) noexcept;
|
| 5715 |
+
```
|
| 5716 |
+
|
| 5717 |
+
*Returns:* `month(m) / last`.
|
| 5718 |
+
|
| 5719 |
+
``` cpp
|
| 5720 |
+
constexpr month_day_last
|
| 5721 |
+
operator/(last_spec, const month& m) noexcept;
|
| 5722 |
+
```
|
| 5723 |
+
|
| 5724 |
+
*Returns:* `m / last`.
|
| 5725 |
+
|
| 5726 |
+
``` cpp
|
| 5727 |
+
constexpr month_day_last
|
| 5728 |
+
operator/(last_spec, int m) noexcept;
|
| 5729 |
+
```
|
| 5730 |
+
|
| 5731 |
+
*Returns:* `month(m) / last`.
|
| 5732 |
+
|
| 5733 |
+
``` cpp
|
| 5734 |
+
constexpr month_weekday
|
| 5735 |
+
operator/(const month& m, const weekday_indexed& wdi) noexcept;
|
| 5736 |
+
```
|
| 5737 |
+
|
| 5738 |
+
*Returns:* `{m, wdi}`.
|
| 5739 |
+
|
| 5740 |
+
``` cpp
|
| 5741 |
+
constexpr month_weekday
|
| 5742 |
+
operator/(int m, const weekday_indexed& wdi) noexcept;
|
| 5743 |
+
```
|
| 5744 |
+
|
| 5745 |
+
*Returns:* `month(m) / wdi`.
|
| 5746 |
+
|
| 5747 |
+
``` cpp
|
| 5748 |
+
constexpr month_weekday
|
| 5749 |
+
operator/(const weekday_indexed& wdi, const month& m) noexcept;
|
| 5750 |
+
```
|
| 5751 |
+
|
| 5752 |
+
*Returns:* `m / wdi`.
|
| 5753 |
+
|
| 5754 |
+
``` cpp
|
| 5755 |
+
constexpr month_weekday
|
| 5756 |
+
operator/(const weekday_indexed& wdi, int m) noexcept;
|
| 5757 |
+
```
|
| 5758 |
+
|
| 5759 |
+
*Returns:* `month(m) / wdi`.
|
| 5760 |
+
|
| 5761 |
+
``` cpp
|
| 5762 |
+
constexpr month_weekday_last
|
| 5763 |
+
operator/(const month& m, const weekday_last& wdl) noexcept;
|
| 5764 |
+
```
|
| 5765 |
+
|
| 5766 |
+
*Returns:* `{m, wdl}`.
|
| 5767 |
+
|
| 5768 |
+
``` cpp
|
| 5769 |
+
constexpr month_weekday_last
|
| 5770 |
+
operator/(int m, const weekday_last& wdl) noexcept;
|
| 5771 |
+
```
|
| 5772 |
+
|
| 5773 |
+
*Returns:* `month(m) / wdl`.
|
| 5774 |
+
|
| 5775 |
+
``` cpp
|
| 5776 |
+
constexpr month_weekday_last
|
| 5777 |
+
operator/(const weekday_last& wdl, const month& m) noexcept;
|
| 5778 |
+
```
|
| 5779 |
+
|
| 5780 |
+
*Returns:* `m / wdl`.
|
| 5781 |
+
|
| 5782 |
+
``` cpp
|
| 5783 |
+
constexpr month_weekday_last
|
| 5784 |
+
operator/(const weekday_last& wdl, int m) noexcept;
|
| 5785 |
+
```
|
| 5786 |
+
|
| 5787 |
+
*Returns:* `month(m) / wdl`.
|
| 5788 |
+
|
| 5789 |
+
``` cpp
|
| 5790 |
+
constexpr year_month_day
|
| 5791 |
+
operator/(const year_month& ym, const day& d) noexcept;
|
| 5792 |
+
```
|
| 5793 |
+
|
| 5794 |
+
*Returns:* `{ym.year(), ym.month(), d}`.
|
| 5795 |
+
|
| 5796 |
+
``` cpp
|
| 5797 |
+
constexpr year_month_day
|
| 5798 |
+
operator/(const year_month& ym, int d) noexcept;
|
| 5799 |
+
```
|
| 5800 |
+
|
| 5801 |
+
*Returns:* `ym / day(d)`.
|
| 5802 |
+
|
| 5803 |
+
``` cpp
|
| 5804 |
+
constexpr year_month_day
|
| 5805 |
+
operator/(const year& y, const month_day& md) noexcept;
|
| 5806 |
+
```
|
| 5807 |
+
|
| 5808 |
+
*Returns:* `y / md.month() / md.day()`.
|
| 5809 |
+
|
| 5810 |
+
``` cpp
|
| 5811 |
+
constexpr year_month_day
|
| 5812 |
+
operator/(int y, const month_day& md) noexcept;
|
| 5813 |
+
```
|
| 5814 |
+
|
| 5815 |
+
*Returns:* `year(y) / md`.
|
| 5816 |
+
|
| 5817 |
+
``` cpp
|
| 5818 |
+
constexpr year_month_day
|
| 5819 |
+
operator/(const month_day& md, const year& y) noexcept;
|
| 5820 |
+
```
|
| 5821 |
+
|
| 5822 |
+
*Returns:* `y / md`.
|
| 5823 |
+
|
| 5824 |
+
``` cpp
|
| 5825 |
+
constexpr year_month_day
|
| 5826 |
+
operator/(const month_day& md, int y) noexcept;
|
| 5827 |
+
```
|
| 5828 |
+
|
| 5829 |
+
*Returns:* `year(y) / md`.
|
| 5830 |
+
|
| 5831 |
+
``` cpp
|
| 5832 |
+
constexpr year_month_day_last
|
| 5833 |
+
operator/(const year_month& ym, last_spec) noexcept;
|
| 5834 |
+
```
|
| 5835 |
+
|
| 5836 |
+
*Returns:* `{ym.year(), month_day_last{ym.month()}}`.
|
| 5837 |
+
|
| 5838 |
+
``` cpp
|
| 5839 |
+
constexpr year_month_day_last
|
| 5840 |
+
operator/(const year& y, const month_day_last& mdl) noexcept;
|
| 5841 |
+
```
|
| 5842 |
+
|
| 5843 |
+
*Returns:* `{y, mdl}`.
|
| 5844 |
+
|
| 5845 |
+
``` cpp
|
| 5846 |
+
constexpr year_month_day_last
|
| 5847 |
+
operator/(int y, const month_day_last& mdl) noexcept;
|
| 5848 |
+
```
|
| 5849 |
+
|
| 5850 |
+
*Returns:* `year(y) / mdl`.
|
| 5851 |
+
|
| 5852 |
+
``` cpp
|
| 5853 |
+
constexpr year_month_day_last
|
| 5854 |
+
operator/(const month_day_last& mdl, const year& y) noexcept;
|
| 5855 |
+
```
|
| 5856 |
+
|
| 5857 |
+
*Returns:* `y / mdl`.
|
| 5858 |
+
|
| 5859 |
+
``` cpp
|
| 5860 |
+
constexpr year_month_day_last
|
| 5861 |
+
operator/(const month_day_last& mdl, int y) noexcept;
|
| 5862 |
+
```
|
| 5863 |
+
|
| 5864 |
+
*Returns:* `year(y) / mdl`.
|
| 5865 |
+
|
| 5866 |
+
``` cpp
|
| 5867 |
+
constexpr year_month_weekday
|
| 5868 |
+
operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
|
| 5869 |
+
```
|
| 5870 |
+
|
| 5871 |
+
*Returns:* `{ym.year(), ym.month(), wdi}`.
|
| 5872 |
+
|
| 5873 |
+
``` cpp
|
| 5874 |
+
constexpr year_month_weekday
|
| 5875 |
+
operator/(const year& y, const month_weekday& mwd) noexcept;
|
| 5876 |
+
```
|
| 5877 |
+
|
| 5878 |
+
*Returns:* `{y, mwd.month(), mwd.weekday_indexed()}`.
|
| 5879 |
+
|
| 5880 |
+
``` cpp
|
| 5881 |
+
constexpr year_month_weekday
|
| 5882 |
+
operator/(int y, const month_weekday& mwd) noexcept;
|
| 5883 |
+
```
|
| 5884 |
+
|
| 5885 |
+
*Returns:* `year(y) / mwd`.
|
| 5886 |
+
|
| 5887 |
+
``` cpp
|
| 5888 |
+
constexpr year_month_weekday
|
| 5889 |
+
operator/(const month_weekday& mwd, const year& y) noexcept;
|
| 5890 |
+
```
|
| 5891 |
+
|
| 5892 |
+
*Returns:* `y / mwd`.
|
| 5893 |
+
|
| 5894 |
+
``` cpp
|
| 5895 |
+
constexpr year_month_weekday
|
| 5896 |
+
operator/(const month_weekday& mwd, int y) noexcept;
|
| 5897 |
+
```
|
| 5898 |
+
|
| 5899 |
+
*Returns:* `year(y) / mwd`.
|
| 5900 |
+
|
| 5901 |
+
``` cpp
|
| 5902 |
+
constexpr year_month_weekday_last
|
| 5903 |
+
operator/(const year_month& ym, const weekday_last& wdl) noexcept;
|
| 5904 |
+
```
|
| 5905 |
+
|
| 5906 |
+
*Returns:* `{ym.year(), ym.month(), wdl}`.
|
| 5907 |
+
|
| 5908 |
+
``` cpp
|
| 5909 |
+
constexpr year_month_weekday_last
|
| 5910 |
+
operator/(const year& y, const month_weekday_last& mwdl) noexcept;
|
| 5911 |
+
```
|
| 5912 |
+
|
| 5913 |
+
*Returns:* `{y, mwdl.month(), mwdl.weekday_last()}`.
|
| 5914 |
+
|
| 5915 |
+
``` cpp
|
| 5916 |
+
constexpr year_month_weekday_last
|
| 5917 |
+
operator/(int y, const month_weekday_last& mwdl) noexcept;
|
| 5918 |
+
```
|
| 5919 |
+
|
| 5920 |
+
*Returns:* `year(y) / mwdl`.
|
| 5921 |
+
|
| 5922 |
+
``` cpp
|
| 5923 |
+
constexpr year_month_weekday_last
|
| 5924 |
+
operator/(const month_weekday_last& mwdl, const year& y) noexcept;
|
| 5925 |
+
```
|
| 5926 |
+
|
| 5927 |
+
*Returns:* `y / mwdl`.
|
| 5928 |
+
|
| 5929 |
+
``` cpp
|
| 5930 |
+
constexpr year_month_weekday_last
|
| 5931 |
+
operator/(const month_weekday_last& mwdl, int y) noexcept;
|
| 5932 |
+
```
|
| 5933 |
+
|
| 5934 |
+
*Returns:* `year(y) / mwdl`.
|
| 5935 |
+
|
| 5936 |
+
## Class template `hh_mm_ss` <a id="time.hms">[[time.hms]]</a>
|
| 5937 |
+
|
| 5938 |
+
### Overview <a id="time.hms.overview">[[time.hms.overview]]</a>
|
| 5939 |
+
|
| 5940 |
+
``` cpp
|
| 5941 |
+
namespace std::chrono {
|
| 5942 |
+
template<class Duration> class hh_mm_ss {
|
| 5943 |
+
public:
|
| 5944 |
+
static constexpr unsigned fractional_width = see below;
|
| 5945 |
+
using precision = see below;
|
| 5946 |
+
|
| 5947 |
+
constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
|
| 5948 |
+
constexpr explicit hh_mm_ss(Duration d);
|
| 5949 |
+
|
| 5950 |
+
constexpr bool is_negative() const noexcept;
|
| 5951 |
+
constexpr chrono::hours hours() const noexcept;
|
| 5952 |
+
constexpr chrono::minutes minutes() const noexcept;
|
| 5953 |
+
constexpr chrono::seconds seconds() const noexcept;
|
| 5954 |
+
constexpr precision subseconds() const noexcept;
|
| 5955 |
+
|
| 5956 |
+
constexpr explicit operator precision() const noexcept;
|
| 5957 |
+
constexpr precision to_duration() const noexcept;
|
| 5958 |
+
|
| 5959 |
+
private:
|
| 5960 |
+
bool is_neg; // exposition only
|
| 5961 |
+
chrono::hours h; // exposition only
|
| 5962 |
+
chrono::minutes m; // exposition only
|
| 5963 |
+
chrono::seconds s; // exposition only
|
| 5964 |
+
precision ss; // exposition only
|
| 5965 |
+
};
|
| 5966 |
+
}
|
| 5967 |
+
```
|
| 5968 |
+
|
| 5969 |
+
The `hh_mm_ss` class template splits a `duration` into a multi-field
|
| 5970 |
+
time structure *hours*:*minutes*:*seconds* and possibly *subseconds*,
|
| 5971 |
+
where *subseconds* will be a duration unit based on a non-positive power
|
| 5972 |
+
of 10. The `Duration` template parameter dictates the precision to which
|
| 5973 |
+
the time is split. A `hh_mm_ss` models negative durations with a
|
| 5974 |
+
distinct `is_negative` getter that returns `true` when the input
|
| 5975 |
+
duration is negative. The individual duration fields always return
|
| 5976 |
+
non-negative durations even when `is_negative()` indicates the structure
|
| 5977 |
+
is representing a negative duration.
|
| 5978 |
+
|
| 5979 |
+
If `Duration` is not an instance of `duration`, the program is
|
| 5980 |
+
ill-formed.
|
| 5981 |
+
|
| 5982 |
+
### Members <a id="time.hms.members">[[time.hms.members]]</a>
|
| 5983 |
+
|
| 5984 |
+
``` cpp
|
| 5985 |
+
static constexpr unsigned fractional_width = see below;
|
| 5986 |
+
```
|
| 5987 |
+
|
| 5988 |
+
`fractional_width` is the number of fractional decimal digits
|
| 5989 |
+
represented by `precision`. `fractional_width` has the value of the
|
| 5990 |
+
smallest possible integer in the range \[`0`, `18`\] such that
|
| 5991 |
+
`precision` will exactly represent all values of `Duration`. If no such
|
| 5992 |
+
value of `fractional_width` exists, then `fractional_width` is 6.
|
| 5993 |
+
|
| 5994 |
+
[*Example 1*:
|
| 5995 |
+
|
| 5996 |
+
See [[time.hms.width]] for some durations, the resulting
|
| 5997 |
+
`fractional_width`, and the formatted fractional second output of
|
| 5998 |
+
`Duration{1}`.
|
| 5999 |
+
|
| 6000 |
+
**Table: Examples for `fractional_width`** <a id="time.hms.width">[time.hms.width]</a>
|
| 6001 |
+
|
| 6002 |
+
| | | |
|
| 6003 |
+
| --------------------------------- | --- | ------------- |
|
| 6004 |
+
| `hours`, `minutes`, and `seconds` | `0` | |
|
| 6005 |
+
| `milliseconds` | `3` | `0.001` |
|
| 6006 |
+
| `microseconds` | `6` | `0.000001` |
|
| 6007 |
+
| `nanoseconds` | `9` | `0.000000001` |
|
| 6008 |
+
| `duration<int, ratio<1, 2>>` | `1` | `0.5` |
|
| 6009 |
+
| `duration<int, ratio<1, 3>>` | `6` | `0.333333` |
|
| 6010 |
+
| `duration<int, ratio<1, 4>>` | `2` | `0.25` |
|
| 6011 |
+
| `duration<int, ratio<1, 5>>` | `1` | `0.2` |
|
| 6012 |
+
| `duration<int, ratio<1, 6>>` | `6` | `0.166666` |
|
| 6013 |
+
| `duration<int, ratio<1, 7>>` | `6` | `0.142857` |
|
| 6014 |
+
| `duration<int, ratio<1, 8>>` | `3` | `0.125` |
|
| 6015 |
+
| `duration<int, ratio<1, 9>>` | `6` | `0.111111` |
|
| 6016 |
+
| `duration<int, ratio<1, 10>>` | `1` | `0.1` |
|
| 6017 |
+
| `duration<int, ratio<756, 625>>` | `4` | `0.2096` |
|
| 6018 |
+
|
| 6019 |
+
|
| 6020 |
+
— *end example*]
|
| 6021 |
+
|
| 6022 |
+
``` cpp
|
| 6023 |
+
using precision = see below;
|
| 6024 |
+
```
|
| 6025 |
+
|
| 6026 |
+
`precision` is
|
| 6027 |
+
|
| 6028 |
+
``` cpp
|
| 6029 |
+
duration<common_type_t<Duration::rep, seconds::rep>, ratio<1, $10^fractional_width$>>
|
| 6030 |
+
```
|
| 6031 |
+
|
| 6032 |
+
``` cpp
|
| 6033 |
+
constexpr explicit hh_mm_ss(Duration d);
|
| 6034 |
+
```
|
| 6035 |
+
|
| 6036 |
+
*Effects:* Constructs an object of type `hh_mm_ss` which represents the
|
| 6037 |
+
`Duration d` with precision `precision`.
|
| 6038 |
+
|
| 6039 |
+
- Initializes `is_neg` with `d < Duration::zero()`.
|
| 6040 |
+
- Initializes `h` with `duration_cast<chrono::hours>(abs(d))`.
|
| 6041 |
+
- Initializes `m` with
|
| 6042 |
+
`duration_cast<chrono::minutes>(abs(d) - hours())`.
|
| 6043 |
+
- Initializes `s` with
|
| 6044 |
+
`duration_cast<chrono::seconds>(abs(d) - hours() - minutes())`.
|
| 6045 |
+
- If `treat_as_floating_point_v<precision::rep>` is `true`, initializes
|
| 6046 |
+
`ss` with `abs(d) - hours() - minutes() - seconds()`. Otherwise,
|
| 6047 |
+
initializes `ss` with
|
| 6048 |
+
`duration_cast<precision>(abs(d) - hours() - minutes() - seconds())`.
|
| 6049 |
+
|
| 6050 |
+
[*Note 1*: When `precision::rep` is integral and `precision::period` is
|
| 6051 |
+
`ratio<1>`, `subseconds()` always returns a value equal to
|
| 6052 |
+
`0s`. — *end note*]
|
| 6053 |
+
|
| 6054 |
+
*Ensures:* If `treat_as_floating_point_v<precision::rep>` is `true`,
|
| 6055 |
+
`to_duration()` returns `d`, otherwise `to_duration()` returns
|
| 6056 |
+
`duration_cast<precision>(d)`.
|
| 6057 |
+
|
| 6058 |
+
``` cpp
|
| 6059 |
+
constexpr bool is_negative() const noexcept;
|
| 6060 |
+
```
|
| 6061 |
+
|
| 6062 |
+
*Returns:* `is_neg`.
|
| 6063 |
+
|
| 6064 |
+
``` cpp
|
| 6065 |
+
constexpr chrono::hours hours() const noexcept;
|
| 6066 |
+
```
|
| 6067 |
+
|
| 6068 |
+
*Returns:* `h`.
|
| 6069 |
+
|
| 6070 |
+
``` cpp
|
| 6071 |
+
constexpr chrono::minutes minutes() const noexcept;
|
| 6072 |
+
```
|
| 6073 |
+
|
| 6074 |
+
*Returns:* `m`.
|
| 6075 |
+
|
| 6076 |
+
``` cpp
|
| 6077 |
+
constexpr chrono::seconds seconds() const noexcept;
|
| 6078 |
+
```
|
| 6079 |
+
|
| 6080 |
+
*Returns:* `s`.
|
| 6081 |
+
|
| 6082 |
+
``` cpp
|
| 6083 |
+
constexpr precision subseconds() const noexcept;
|
| 6084 |
+
```
|
| 6085 |
+
|
| 6086 |
+
*Returns:* `ss`.
|
| 6087 |
+
|
| 6088 |
+
``` cpp
|
| 6089 |
+
constexpr precision to_duration() const noexcept;
|
| 6090 |
+
```
|
| 6091 |
+
|
| 6092 |
+
*Returns:* If `is_neg`, returns `-(h + m + s + ss)`, otherwise returns
|
| 6093 |
+
`h + m + s + ss`.
|
| 6094 |
+
|
| 6095 |
+
``` cpp
|
| 6096 |
+
constexpr explicit operator precision() const noexcept;
|
| 6097 |
+
```
|
| 6098 |
+
|
| 6099 |
+
*Returns:* `to_duration()`.
|
| 6100 |
+
|
| 6101 |
+
### Non-members <a id="time.hms.nonmembers">[[time.hms.nonmembers]]</a>
|
| 6102 |
+
|
| 6103 |
+
``` cpp
|
| 6104 |
+
template<class charT, class traits, class Duration>
|
| 6105 |
+
basic_ostream<charT, traits>&
|
| 6106 |
+
operator<<(basic_ostream<charT, traits>& os, const hh_mm_ss<Duration>& hms);
|
| 6107 |
+
```
|
| 6108 |
+
|
| 6109 |
+
*Effects:* Equivalent to:
|
| 6110 |
+
|
| 6111 |
+
``` cpp
|
| 6112 |
+
return os << format(os.getloc(), STATICALLY-WIDEN<charT>("{:%T}"), hms);
|
| 6113 |
+
```
|
| 6114 |
+
|
| 6115 |
+
[*Example 1*:
|
| 6116 |
+
|
| 6117 |
+
``` cpp
|
| 6118 |
+
for (auto ms : {-4083007ms, 4083007ms, 65745123ms}) {
|
| 6119 |
+
hh_mm_ss hms{ms};
|
| 6120 |
+
cout << hms << '\n';
|
| 6121 |
+
}
|
| 6122 |
+
cout << hh_mm_ss{65745s} << '\n';
|
| 6123 |
+
```
|
| 6124 |
+
|
| 6125 |
+
Produces the output (assuming the "C" locale):
|
| 6126 |
+
|
| 6127 |
+
``` cpp
|
| 6128 |
+
-01:08:03.007
|
| 6129 |
+
01:08:03.007
|
| 6130 |
+
18:15:45.123
|
| 6131 |
+
18:15:45
|
| 6132 |
+
```
|
| 6133 |
+
|
| 6134 |
+
— *end example*]
|
| 6135 |
+
|
| 6136 |
+
## 12/24 hours functions <a id="time.12">[[time.12]]</a>
|
| 6137 |
+
|
| 6138 |
+
These functions aid in translating between a 12h format time of day and
|
| 6139 |
+
a 24h format time of day.
|
| 6140 |
+
|
| 6141 |
+
``` cpp
|
| 6142 |
+
constexpr bool is_am(const hours& h) noexcept;
|
| 6143 |
+
```
|
| 6144 |
+
|
| 6145 |
+
*Returns:* `0h <= h && h <= 11h`.
|
| 6146 |
+
|
| 6147 |
+
``` cpp
|
| 6148 |
+
constexpr bool is_pm(const hours& h) noexcept;
|
| 6149 |
+
```
|
| 6150 |
+
|
| 6151 |
+
*Returns:* `12h <= h && h <= 23h`.
|
| 6152 |
+
|
| 6153 |
+
``` cpp
|
| 6154 |
+
constexpr hours make12(const hours& h) noexcept;
|
| 6155 |
+
```
|
| 6156 |
+
|
| 6157 |
+
*Returns:* The 12-hour equivalent of `h` in the range \[`1h`, `12h`\].
|
| 6158 |
+
If `h` is not in the range \[`0h`, `23h`\], the value returned is
|
| 6159 |
+
unspecified.
|
| 6160 |
+
|
| 6161 |
+
``` cpp
|
| 6162 |
+
constexpr hours make24(const hours& h, bool is_pm) noexcept;
|
| 6163 |
+
```
|
| 6164 |
+
|
| 6165 |
+
*Returns:* If `is_pm` is `false`, returns the 24-hour equivalent of `h`
|
| 6166 |
+
in the range \[`0h`, `11h`\], assuming `h` represents an ante meridiem
|
| 6167 |
+
hour. Otherwise, returns the 24-hour equivalent of `h` in the range
|
| 6168 |
+
\[`12h`, `23h`\], assuming `h` represents a post meridiem hour. If `h`
|
| 6169 |
+
is not in the range \[`1h`, `12h`\], the value returned is unspecified.
|
| 6170 |
+
|
| 6171 |
+
## Time zones <a id="time.zone">[[time.zone]]</a>
|
| 6172 |
+
|
| 6173 |
+
### In general <a id="time.zone.general">[[time.zone.general]]</a>
|
| 6174 |
+
|
| 6175 |
+
[[time.zone]] describes an interface for accessing the IANA Time Zone
|
| 6176 |
+
Database that interoperates with `sys_time` and `local_time`. This
|
| 6177 |
+
interface provides time zone support to both the civil calendar types
|
| 6178 |
+
[[time.cal]] and to user-defined calendars.
|
| 6179 |
+
|
| 6180 |
+
### Time zone database <a id="time.zone.db">[[time.zone.db]]</a>
|
| 6181 |
+
|
| 6182 |
+
#### Class `tzdb` <a id="time.zone.db.tzdb">[[time.zone.db.tzdb]]</a>
|
| 6183 |
+
|
| 6184 |
+
``` cpp
|
| 6185 |
+
namespace std::chrono {
|
| 6186 |
+
struct tzdb {
|
| 6187 |
+
string version;
|
| 6188 |
+
vector<time_zone> zones;
|
| 6189 |
+
vector<time_zone_link> links;
|
| 6190 |
+
vector<leap_second> leap_seconds;
|
| 6191 |
+
|
| 6192 |
+
const time_zone* locate_zone(string_view tz_name) const;
|
| 6193 |
+
const time_zone* current_zone() const;
|
| 6194 |
+
};
|
| 6195 |
+
}
|
| 6196 |
+
```
|
| 6197 |
+
|
| 6198 |
+
Each `vector` in a `tzdb` object is sorted to enable fast lookup.
|
| 6199 |
+
|
| 6200 |
+
``` cpp
|
| 6201 |
+
const time_zone* locate_zone(string_view tz_name) const;
|
| 6202 |
+
```
|
| 6203 |
+
|
| 6204 |
+
*Returns:*
|
| 6205 |
+
|
| 6206 |
+
- If `zones` contains an element `tz` for which `tz.name() == tz_name`,
|
| 6207 |
+
a pointer to `tz`;
|
| 6208 |
+
- otherwise, if `links` contains an element `tz_l` for which
|
| 6209 |
+
`tz_l.name() == tz_name`, then a pointer to the element `tz` of
|
| 6210 |
+
`zones` for which `tz.name() == tz_l.target()`.
|
| 6211 |
+
|
| 6212 |
+
[*Note 1*: A `time_zone_link` specifies an alternative name for a
|
| 6213 |
+
`time_zone`. — *end note*]
|
| 6214 |
+
|
| 6215 |
+
*Throws:* If a `const time_zone*` cannot be found as described in the
|
| 6216 |
+
*Returns:* clause, throws a `runtime_error`.
|
| 6217 |
+
|
| 6218 |
+
[*Note 2*: On non-exceptional return, the return value is always a
|
| 6219 |
+
pointer to a valid `time_zone`. — *end note*]
|
| 6220 |
+
|
| 6221 |
+
``` cpp
|
| 6222 |
+
const time_zone* current_zone() const;
|
| 6223 |
+
```
|
| 6224 |
+
|
| 6225 |
+
*Returns:* A pointer to the time zone which the computer has set as its
|
| 6226 |
+
local time zone.
|
| 6227 |
+
|
| 6228 |
+
#### Class `tzdb_list` <a id="time.zone.db.list">[[time.zone.db.list]]</a>
|
| 6229 |
+
|
| 6230 |
+
``` cpp
|
| 6231 |
+
namespace std::chrono {
|
| 6232 |
+
class tzdb_list {
|
| 6233 |
+
public:
|
| 6234 |
+
tzdb_list(const tzdb_list&) = delete;
|
| 6235 |
+
tzdb_list& operator=(const tzdb_list&) = delete;
|
| 6236 |
+
|
| 6237 |
+
// unspecified additional constructors
|
| 6238 |
+
|
| 6239 |
+
class const_iterator;
|
| 6240 |
+
|
| 6241 |
+
const tzdb& front() const noexcept;
|
| 6242 |
+
|
| 6243 |
+
const_iterator erase_after(const_iterator p);
|
| 6244 |
+
|
| 6245 |
+
const_iterator begin() const noexcept;
|
| 6246 |
+
const_iterator end() const noexcept;
|
| 6247 |
+
|
| 6248 |
+
const_iterator cbegin() const noexcept;
|
| 6249 |
+
const_iterator cend() const noexcept;
|
| 6250 |
+
};
|
| 6251 |
+
}
|
| 6252 |
+
```
|
| 6253 |
+
|
| 6254 |
+
The `tzdb_list` database is a singleton; the unique object of type
|
| 6255 |
+
`tzdb_list` can be accessed via the `get_tzdb_list()` function.
|
| 6256 |
+
|
| 6257 |
+
[*Note 1*: This access is only needed for those applications that need
|
| 6258 |
+
to have long uptimes and have a need to update the time zone database
|
| 6259 |
+
while running. Other applications can implicitly access the `front()` of
|
| 6260 |
+
this list via the read-only namespace scope functions `get_tzdb()`,
|
| 6261 |
+
`locate_zone()`, and `current_zone()`. — *end note*]
|
| 6262 |
+
|
| 6263 |
+
The `tzdb_list` object contains a list of `tzdb` objects.
|
| 6264 |
+
|
| 6265 |
+
`tzdb_list::const_iterator` is a constant iterator which meets the
|
| 6266 |
+
*Cpp17ForwardIterator* requirements and has a value type of `tzdb`.
|
| 6267 |
+
|
| 6268 |
+
``` cpp
|
| 6269 |
+
const tzdb& front() const noexcept;
|
| 6270 |
+
```
|
| 6271 |
+
|
| 6272 |
+
*Synchronization:* This operation is thread-safe with respect to
|
| 6273 |
+
`reload_tzdb()`.
|
| 6274 |
+
|
| 6275 |
+
[*Note 1*: `reload_tzdb()` pushes a new `tzdb` onto the front of this
|
| 6276 |
+
container. — *end note*]
|
| 6277 |
+
|
| 6278 |
+
*Returns:* A reference to the first `tzdb` in the container.
|
| 6279 |
+
|
| 6280 |
+
``` cpp
|
| 6281 |
+
const_iterator erase_after(const_iterator p);
|
| 6282 |
+
```
|
| 6283 |
+
|
| 6284 |
+
*Preconditions:* The iterator following `p` is dereferenceable.
|
| 6285 |
+
|
| 6286 |
+
*Effects:* Erases the `tzdb` referred to by the iterator following `p`.
|
| 6287 |
+
|
| 6288 |
+
*Returns:* An iterator pointing to the element following the one that
|
| 6289 |
+
was erased, or `end()` if no such element exists.
|
| 6290 |
+
|
| 6291 |
+
*Ensures:* No pointers, references, or iterators are invalidated except
|
| 6292 |
+
those referring to the erased `tzdb`.
|
| 6293 |
+
|
| 6294 |
+
[*Note 2*: It is not possible to erase the `tzdb` referred to by
|
| 6295 |
+
`begin()`. — *end note*]
|
| 6296 |
+
|
| 6297 |
+
*Throws:* Nothing.
|
| 6298 |
+
|
| 6299 |
+
``` cpp
|
| 6300 |
+
const_iterator begin() const noexcept;
|
| 6301 |
+
```
|
| 6302 |
+
|
| 6303 |
+
*Returns:* An iterator referring to the first `tzdb` in the container.
|
| 6304 |
+
|
| 6305 |
+
``` cpp
|
| 6306 |
+
const_iterator end() const noexcept;
|
| 6307 |
+
```
|
| 6308 |
+
|
| 6309 |
+
*Returns:* An iterator referring to the position one past the last
|
| 6310 |
+
`tzdb` in the container.
|
| 6311 |
+
|
| 6312 |
+
``` cpp
|
| 6313 |
+
const_iterator cbegin() const noexcept;
|
| 6314 |
+
```
|
| 6315 |
+
|
| 6316 |
+
*Returns:* `begin()`.
|
| 6317 |
+
|
| 6318 |
+
``` cpp
|
| 6319 |
+
const_iterator cend() const noexcept;
|
| 6320 |
+
```
|
| 6321 |
+
|
| 6322 |
+
*Returns:* `end()`.
|
| 6323 |
+
|
| 6324 |
+
#### Time zone database access <a id="time.zone.db.access">[[time.zone.db.access]]</a>
|
| 6325 |
+
|
| 6326 |
+
``` cpp
|
| 6327 |
+
tzdb_list& get_tzdb_list();
|
| 6328 |
+
```
|
| 6329 |
+
|
| 6330 |
+
*Effects:* If this is the first access to the time zone database,
|
| 6331 |
+
initializes the database. If this call initializes the database, the
|
| 6332 |
+
resulting database will be a `tzdb_list` holding a single initialized
|
| 6333 |
+
`tzdb`.
|
| 6334 |
+
|
| 6335 |
+
*Synchronization:* It is safe to call this function from multiple
|
| 6336 |
+
threads at one time.
|
| 6337 |
+
|
| 6338 |
+
*Returns:* A reference to the database.
|
| 6339 |
+
|
| 6340 |
+
*Throws:* `runtime_error` if for any reason a reference cannot be
|
| 6341 |
+
returned to a valid `tzdb_list` containing one or more valid `tzdb`s.
|
| 6342 |
+
|
| 6343 |
+
``` cpp
|
| 6344 |
+
const tzdb& get_tzdb();
|
| 6345 |
+
```
|
| 6346 |
+
|
| 6347 |
+
*Returns:* `get_tzdb_list().front()`.
|
| 6348 |
+
|
| 6349 |
+
``` cpp
|
| 6350 |
+
const time_zone* locate_zone(string_view tz_name);
|
| 6351 |
+
```
|
| 6352 |
+
|
| 6353 |
+
*Returns:* `get_tzdb().locate_zone(tz_name)`.
|
| 6354 |
+
|
| 6355 |
+
[*Note 1*: The time zone database will be initialized if this is the
|
| 6356 |
+
first reference to the database. — *end note*]
|
| 6357 |
+
|
| 6358 |
+
``` cpp
|
| 6359 |
+
const time_zone* current_zone();
|
| 6360 |
+
```
|
| 6361 |
+
|
| 6362 |
+
*Returns:* `get_tzdb().current_zone()`.
|
| 6363 |
+
|
| 6364 |
+
#### Remote time zone database support <a id="time.zone.db.remote">[[time.zone.db.remote]]</a>
|
| 6365 |
+
|
| 6366 |
+
The local time zone database is that supplied by the implementation when
|
| 6367 |
+
the program first accesses the database, for example via
|
| 6368 |
+
`current_zone()`. While the program is running, the implementation may
|
| 6369 |
+
choose to update the time zone database. This update shall not impact
|
| 6370 |
+
the program in any way unless the program calls the functions in this
|
| 6371 |
+
subclause. This potentially updated time zone database is referred to as
|
| 6372 |
+
the *remote time zone database*.
|
| 6373 |
+
|
| 6374 |
+
``` cpp
|
| 6375 |
+
const tzdb& reload_tzdb();
|
| 6376 |
+
```
|
| 6377 |
+
|
| 6378 |
+
*Effects:* This function first checks the version of the remote time
|
| 6379 |
+
zone database. If the versions of the local and remote databases are the
|
| 6380 |
+
same, there are no effects. Otherwise the remote database is pushed to
|
| 6381 |
+
the front of the `tzdb_list` accessed by `get_tzdb_list()`.
|
| 6382 |
+
|
| 6383 |
+
*Synchronization:* This function is thread-safe with respect to
|
| 6384 |
+
`get_tzdb_list().front()` and `get_tzdb_list().erase_after()`.
|
| 6385 |
+
|
| 6386 |
+
*Ensures:* No pointers, references, or iterators are invalidated.
|
| 6387 |
+
|
| 6388 |
+
*Returns:* `get_tzdb_list().front()`.
|
| 6389 |
+
|
| 6390 |
+
*Throws:* `runtime_error` if for any reason a reference cannot be
|
| 6391 |
+
returned to a valid `tzdb`.
|
| 6392 |
+
|
| 6393 |
+
``` cpp
|
| 6394 |
+
string remote_version();
|
| 6395 |
+
```
|
| 6396 |
+
|
| 6397 |
+
*Returns:* The latest remote database version.
|
| 6398 |
+
|
| 6399 |
+
[*Note 1*: This can be compared with `get_tzdb().version` to discover
|
| 6400 |
+
if the local and remote databases are equivalent. — *end note*]
|
| 6401 |
+
|
| 6402 |
+
### Exception classes <a id="time.zone.exception">[[time.zone.exception]]</a>
|
| 6403 |
+
|
| 6404 |
+
#### Class `nonexistent_local_time` <a id="time.zone.exception.nonexist">[[time.zone.exception.nonexist]]</a>
|
| 6405 |
+
|
| 6406 |
+
``` cpp
|
| 6407 |
+
namespace std::chrono {
|
| 6408 |
+
class nonexistent_local_time : public runtime_error {
|
| 6409 |
+
public:
|
| 6410 |
+
template<class Duration>
|
| 6411 |
+
nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
|
| 6412 |
+
};
|
| 6413 |
+
}
|
| 6414 |
+
```
|
| 6415 |
+
|
| 6416 |
+
`nonexistent_local_time` is thrown when an attempt is made to convert a
|
| 6417 |
+
non-existent `local_time` to a `sys_time` without specifying
|
| 6418 |
+
`choose::earliest` or `choose::latest`.
|
| 6419 |
+
|
| 6420 |
+
``` cpp
|
| 6421 |
+
template<class Duration>
|
| 6422 |
+
nonexistent_local_time(const local_time<Duration>& tp, const local_info& i);
|
| 6423 |
+
```
|
| 6424 |
+
|
| 6425 |
+
*Preconditions:* `i.result == local_info::nonexistent` is `true`.
|
| 6426 |
+
|
| 6427 |
+
*Effects:* Initializes the base class with a sequence of `char`
|
| 6428 |
+
equivalent to that produced by `os.str()` initialized as shown below:
|
| 6429 |
+
|
| 6430 |
+
``` cpp
|
| 6431 |
+
ostringstream os;
|
| 6432 |
+
os << tp << " is in a gap between\n"
|
| 6433 |
+
<< local_seconds{i.first.end.time_since_epoch()} + i.first.offset << ' '
|
| 6434 |
+
<< i.first.abbrev << " and\n"
|
| 6435 |
+
<< local_seconds{i.second.begin.time_since_epoch()} + i.second.offset << ' '
|
| 6436 |
+
<< i.second.abbrev
|
| 6437 |
+
<< " which are both equivalent to\n"
|
| 6438 |
+
<< i.first.end << " UTC";
|
| 6439 |
+
```
|
| 6440 |
+
|
| 6441 |
+
[*Example 1*:
|
| 6442 |
+
|
| 6443 |
+
``` cpp
|
| 6444 |
+
#include <chrono>
|
| 6445 |
+
#include <iostream>
|
| 6446 |
+
|
| 6447 |
+
int main() {
|
| 6448 |
+
using namespace std::chrono;
|
| 6449 |
+
try {
|
| 6450 |
+
auto zt = zoned_time{"America/New_York",
|
| 6451 |
+
local_days{Sunday[2]/March/2016} + 2h + 30min};
|
| 6452 |
+
} catch (const nonexistent_local_time& e) {
|
| 6453 |
+
std::cout << e.what() << '\n';
|
| 6454 |
+
}
|
| 6455 |
+
}
|
| 6456 |
+
```
|
| 6457 |
+
|
| 6458 |
+
Produces the output:
|
| 6459 |
+
|
| 6460 |
+
``` text
|
| 6461 |
+
2016-03-13 02:30:00 is in a gap between
|
| 6462 |
+
2016-03-13 02:00:00 EST and
|
| 6463 |
+
2016-03-13 03:00:00 EDT which are both equivalent to
|
| 6464 |
+
2016-03-13 07:00:00 UTC
|
| 6465 |
+
```
|
| 6466 |
+
|
| 6467 |
+
— *end example*]
|
| 6468 |
+
|
| 6469 |
+
#### Class `ambiguous_local_time` <a id="time.zone.exception.ambig">[[time.zone.exception.ambig]]</a>
|
| 6470 |
+
|
| 6471 |
+
``` cpp
|
| 6472 |
+
namespace std::chrono {
|
| 6473 |
+
class ambiguous_local_time : public runtime_error {
|
| 6474 |
+
public:
|
| 6475 |
+
template<class Duration>
|
| 6476 |
+
ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
|
| 6477 |
+
};
|
| 6478 |
+
}
|
| 6479 |
+
```
|
| 6480 |
+
|
| 6481 |
+
`ambiguous_local_time` is thrown when an attempt is made to convert an
|
| 6482 |
+
ambiguous `local_time` to a `sys_time` without specifying
|
| 6483 |
+
`choose::earliest` or `choose::latest`.
|
| 6484 |
+
|
| 6485 |
+
``` cpp
|
| 6486 |
+
template<class Duration>
|
| 6487 |
+
ambiguous_local_time(const local_time<Duration>& tp, const local_info& i);
|
| 6488 |
+
```
|
| 6489 |
+
|
| 6490 |
+
*Preconditions:* `i.result == local_info::ambiguous` is `true`.
|
| 6491 |
+
|
| 6492 |
+
*Effects:* Initializes the base class with a sequence of `char`
|
| 6493 |
+
equivalent to that produced by `os.str()` initialized as shown below:
|
| 6494 |
+
|
| 6495 |
+
``` cpp
|
| 6496 |
+
ostringstream os;
|
| 6497 |
+
os << tp << " is ambiguous. It could be\n"
|
| 6498 |
+
<< tp << ' ' << i.first.abbrev << " == "
|
| 6499 |
+
<< tp - i.first.offset << " UTC or\n"
|
| 6500 |
+
<< tp << ' ' << i.second.abbrev << " == "
|
| 6501 |
+
<< tp - i.second.offset << " UTC";
|
| 6502 |
+
```
|
| 6503 |
+
|
| 6504 |
+
[*Example 1*:
|
| 6505 |
+
|
| 6506 |
+
``` cpp
|
| 6507 |
+
#include <chrono>
|
| 6508 |
+
#include <iostream>
|
| 6509 |
+
|
| 6510 |
+
int main() {
|
| 6511 |
+
using namespace std::chrono;
|
| 6512 |
+
try {
|
| 6513 |
+
auto zt = zoned_time{"America/New_York",
|
| 6514 |
+
local_days{Sunday[1]/November/2016} + 1h + 30min};
|
| 6515 |
+
} catch (const ambiguous_local_time& e) {
|
| 6516 |
+
std::cout << e.what() << '\n';
|
| 6517 |
+
}
|
| 6518 |
+
}
|
| 6519 |
+
```
|
| 6520 |
+
|
| 6521 |
+
Produces the output:
|
| 6522 |
+
|
| 6523 |
+
``` text
|
| 6524 |
+
2016-11-06 01:30:00 is ambiguous. It could be
|
| 6525 |
+
2016-11-06 01:30:00 EDT == 2016-11-06 05:30:00 UTC or
|
| 6526 |
+
2016-11-06 01:30:00 EST == 2016-11-06 06:30:00 UTC
|
| 6527 |
+
```
|
| 6528 |
+
|
| 6529 |
+
— *end example*]
|
| 6530 |
+
|
| 6531 |
+
### Information classes <a id="time.zone.info">[[time.zone.info]]</a>
|
| 6532 |
+
|
| 6533 |
+
#### Class `sys_info` <a id="time.zone.info.sys">[[time.zone.info.sys]]</a>
|
| 6534 |
+
|
| 6535 |
+
``` cpp
|
| 6536 |
+
namespace std::chrono {
|
| 6537 |
+
struct sys_info {
|
| 6538 |
+
sys_seconds begin;
|
| 6539 |
+
sys_seconds end;
|
| 6540 |
+
seconds offset;
|
| 6541 |
+
minutes save;
|
| 6542 |
+
string abbrev;
|
| 6543 |
+
};
|
| 6544 |
+
}
|
| 6545 |
+
```
|
| 6546 |
+
|
| 6547 |
+
A `sys_info` object can be obtained from the combination of a
|
| 6548 |
+
`time_zone` and either a `sys_time` or `local_time`. It can also be
|
| 6549 |
+
obtained from a `zoned_time`, which is effectively a pair of a
|
| 6550 |
+
`time_zone` and `sys_time`.
|
| 6551 |
+
|
| 6552 |
+
[*Note 1*: This type provides a low-level interface to time zone
|
| 6553 |
+
information. Typical conversions from `sys_time` to `local_time` will
|
| 6554 |
+
use this class implicitly, not explicitly. — *end note*]
|
| 6555 |
+
|
| 6556 |
+
The `begin` and `end` data members indicate that, for the associated
|
| 6557 |
+
`time_zone` and `time_point`, the `offset` and `abbrev` are in effect in
|
| 6558 |
+
the range \[`begin`, `end`). This information can be used to efficiently
|
| 6559 |
+
iterate the transitions of a `time_zone`.
|
| 6560 |
+
|
| 6561 |
+
The `offset` data member indicates the UTC offset in effect for the
|
| 6562 |
+
associated `time_zone` and `time_point`. The relationship between
|
| 6563 |
+
`local_time` and `sys_time` is:
|
| 6564 |
+
|
| 6565 |
+
``` cpp
|
| 6566 |
+
offset = local_time - sys_time
|
| 6567 |
+
```
|
| 6568 |
+
|
| 6569 |
+
The `save` data member is extra information not normally needed for
|
| 6570 |
+
conversion between `local_time` and `sys_time`. If `save != 0min`, this
|
| 6571 |
+
`sys_info` is said to be on “daylight saving” time, and `offset - save`
|
| 6572 |
+
suggests what offset this `time_zone` might use if it were off daylight
|
| 6573 |
+
saving time. However, this information should not be taken as
|
| 6574 |
+
authoritative. The only sure way to get such information is to query the
|
| 6575 |
+
`time_zone` with a `time_point` that returns a `sys_info` where
|
| 6576 |
+
`save == 0min`. There is no guarantee what `time_point` might return
|
| 6577 |
+
such a `sys_info` except that it is guaranteed not to be in the range
|
| 6578 |
+
\[`begin`, `end`) (if `save != 0min` for this `sys_info`).
|
| 6579 |
+
|
| 6580 |
+
The `abbrev` data member indicates the current abbreviation used for the
|
| 6581 |
+
associated `time_zone` and `time_point`. Abbreviations are not unique
|
| 6582 |
+
among the `time_zones`, and so one cannot reliably map abbreviations
|
| 6583 |
+
back to a `time_zone` and UTC offset.
|
| 6584 |
+
|
| 6585 |
+
``` cpp
|
| 6586 |
+
template<class charT, class traits>
|
| 6587 |
+
basic_ostream<charT, traits>&
|
| 6588 |
+
operator<<(basic_ostream<charT, traits>& os, const sys_info& r);
|
| 6589 |
+
```
|
| 6590 |
+
|
| 6591 |
+
*Effects:* Streams out the `sys_info` object `r` in an unspecified
|
| 6592 |
+
format.
|
| 6593 |
+
|
| 6594 |
+
*Returns:* `os`.
|
| 6595 |
+
|
| 6596 |
+
#### Class `local_info` <a id="time.zone.info.local">[[time.zone.info.local]]</a>
|
| 6597 |
+
|
| 6598 |
+
``` cpp
|
| 6599 |
+
namespace std::chrono {
|
| 6600 |
+
struct local_info {
|
| 6601 |
+
static constexpr int unique = 0;
|
| 6602 |
+
static constexpr int nonexistent = 1;
|
| 6603 |
+
static constexpr int ambiguous = 2;
|
| 6604 |
+
|
| 6605 |
+
int result;
|
| 6606 |
+
sys_info first;
|
| 6607 |
+
sys_info second;
|
| 6608 |
+
};
|
| 6609 |
+
}
|
| 6610 |
+
```
|
| 6611 |
+
|
| 6612 |
+
[*Note 1*: This type provides a low-level interface to time zone
|
| 6613 |
+
information. Typical conversions from `local_time` to `sys_time` will
|
| 6614 |
+
use this class implicitly, not explicitly. — *end note*]
|
| 6615 |
+
|
| 6616 |
+
Describes the result of converting a `local_time` to a `sys_time` as
|
| 6617 |
+
follows:
|
| 6618 |
+
|
| 6619 |
+
- When a `local_time` to `sys_time` conversion is unique,
|
| 6620 |
+
`result == unique`, `first` will be filled out with the correct
|
| 6621 |
+
`sys_info`, and `second` will be zero-initialized.
|
| 6622 |
+
- If the conversion stems from a nonexistent `local_time` then
|
| 6623 |
+
`result == nonexistent`, `first` will be filled out with the
|
| 6624 |
+
`sys_info` that ends just prior to the `local_time`, and `second` will
|
| 6625 |
+
be filled out with the `sys_info` that begins just after the
|
| 6626 |
+
`local_time`.
|
| 6627 |
+
- If the conversion stems from an ambiguous `local_time`, then
|
| 6628 |
+
`result == ambiguous`, `first` will be filled out with the `sys_info`
|
| 6629 |
+
that ends just after the `local_time`, and `second` will be filled out
|
| 6630 |
+
with the `sys_info` that starts just before the `local_time`.
|
| 6631 |
+
|
| 6632 |
+
``` cpp
|
| 6633 |
+
template<class charT, class traits>
|
| 6634 |
+
basic_ostream<charT, traits>&
|
| 6635 |
+
operator<<(basic_ostream<charT, traits>& os, const local_info& r);
|
| 6636 |
+
```
|
| 6637 |
+
|
| 6638 |
+
*Effects:* Streams out the `local_info` object `r` in an unspecified
|
| 6639 |
+
format.
|
| 6640 |
+
|
| 6641 |
+
*Returns:* `os`.
|
| 6642 |
+
|
| 6643 |
+
### Class `time_zone` <a id="time.zone.timezone">[[time.zone.timezone]]</a>
|
| 6644 |
+
|
| 6645 |
+
#### Overview <a id="time.zone.overview">[[time.zone.overview]]</a>
|
| 6646 |
+
|
| 6647 |
+
``` cpp
|
| 6648 |
+
namespace std::chrono {
|
| 6649 |
+
class time_zone {
|
| 6650 |
+
public:
|
| 6651 |
+
time_zone(time_zone&&) = default;
|
| 6652 |
+
time_zone& operator=(time_zone&&) = default;
|
| 6653 |
+
|
| 6654 |
+
// unspecified additional constructors
|
| 6655 |
+
|
| 6656 |
+
string_view name() const noexcept;
|
| 6657 |
+
|
| 6658 |
+
template<class Duration> sys_info get_info(const sys_time<Duration>& st) const;
|
| 6659 |
+
template<class Duration> local_info get_info(const local_time<Duration>& tp) const;
|
| 6660 |
+
|
| 6661 |
+
template<class Duration>
|
| 6662 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 6663 |
+
to_sys(const local_time<Duration>& tp) const;
|
| 6664 |
+
|
| 6665 |
+
template<class Duration>
|
| 6666 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 6667 |
+
to_sys(const local_time<Duration>& tp, choose z) const;
|
| 6668 |
+
|
| 6669 |
+
template<class Duration>
|
| 6670 |
+
local_time<common_type_t<Duration, seconds>>
|
| 6671 |
+
to_local(const sys_time<Duration>& tp) const;
|
| 6672 |
+
};
|
| 6673 |
+
}
|
| 6674 |
+
```
|
| 6675 |
+
|
| 6676 |
+
A `time_zone` represents all time zone transitions for a specific
|
| 6677 |
+
geographic area. `time_zone` construction is unspecified, and performed
|
| 6678 |
+
as part of database initialization.
|
| 6679 |
+
|
| 6680 |
+
[*Note 1*: `const time_zone` objects can be accessed via functions such
|
| 6681 |
+
as `locate_zone`. — *end note*]
|
| 6682 |
+
|
| 6683 |
+
#### Member functions <a id="time.zone.members">[[time.zone.members]]</a>
|
| 6684 |
+
|
| 6685 |
+
``` cpp
|
| 6686 |
+
string_view name() const noexcept;
|
| 6687 |
+
```
|
| 6688 |
+
|
| 6689 |
+
*Returns:* The name of the `time_zone`.
|
| 6690 |
+
|
| 6691 |
+
[*Example 1*: `"America/New_York"`. — *end example*]
|
| 6692 |
+
|
| 6693 |
+
``` cpp
|
| 6694 |
+
template<class Duration>
|
| 6695 |
+
sys_info get_info(const sys_time<Duration>& st) const;
|
| 6696 |
+
```
|
| 6697 |
+
|
| 6698 |
+
*Returns:* A `sys_info` `i` for which `st` is in the range \[`i.begin`,
|
| 6699 |
+
`i.end`).
|
| 6700 |
+
|
| 6701 |
+
``` cpp
|
| 6702 |
+
template<class Duration>
|
| 6703 |
+
local_info get_info(const local_time<Duration>& tp) const;
|
| 6704 |
+
```
|
| 6705 |
+
|
| 6706 |
+
*Returns:* A `local_info` for `tp`.
|
| 6707 |
+
|
| 6708 |
+
``` cpp
|
| 6709 |
+
template<class Duration>
|
| 6710 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 6711 |
+
to_sys(const local_time<Duration>& tp) const;
|
| 6712 |
+
```
|
| 6713 |
+
|
| 6714 |
+
*Returns:* A `sys_time` that is at least as fine as `seconds`, and will
|
| 6715 |
+
be finer if the argument `tp` has finer precision. This `sys_time` is
|
| 6716 |
+
the UTC equivalent of `tp` according to the rules of this `time_zone`.
|
| 6717 |
+
|
| 6718 |
+
*Throws:* If the conversion from `tp` to a `sys_time` is ambiguous,
|
| 6719 |
+
throws `ambiguous_local_time`. If the `tp` represents a non-existent
|
| 6720 |
+
time between two UTC `time_points`, throws `nonexistent_local_time`.
|
| 6721 |
+
|
| 6722 |
+
``` cpp
|
| 6723 |
+
template<class Duration>
|
| 6724 |
+
sys_time<common_type_t<Duration, seconds>>
|
| 6725 |
+
to_sys(const local_time<Duration>& tp, choose z) const;
|
| 6726 |
+
```
|
| 6727 |
+
|
| 6728 |
+
*Returns:* A `sys_time` that is at least as fine as `seconds`, and will
|
| 6729 |
+
be finer if the argument `tp` has finer precision. This `sys_time` is
|
| 6730 |
+
the UTC equivalent of `tp` according to the rules of this `time_zone`.
|
| 6731 |
+
If the conversion from `tp` to a `sys_time` is ambiguous, returns the
|
| 6732 |
+
earlier `sys_time` if `z == choose::earliest`, and returns the later
|
| 6733 |
+
`sys_time` if `z == choose::latest`. If the `tp` represents a
|
| 6734 |
+
non-existent time between two UTC `time_points`, then the two UTC
|
| 6735 |
+
`time_points` will be the same, and that UTC `time_point` will be
|
| 6736 |
+
returned.
|
| 6737 |
+
|
| 6738 |
+
``` cpp
|
| 6739 |
+
template<class Duration>
|
| 6740 |
+
local_time<common_type_t<Duration, seconds>>
|
| 6741 |
+
to_local(const sys_time<Duration>& tp) const;
|
| 6742 |
+
```
|
| 6743 |
+
|
| 6744 |
+
*Returns:* The `local_time` associated with `tp` and this `time_zone`.
|
| 6745 |
+
|
| 6746 |
+
#### Non-member functions <a id="time.zone.nonmembers">[[time.zone.nonmembers]]</a>
|
| 6747 |
+
|
| 6748 |
+
``` cpp
|
| 6749 |
+
bool operator==(const time_zone& x, const time_zone& y) noexcept;
|
| 6750 |
+
```
|
| 6751 |
+
|
| 6752 |
+
*Returns:* `x.name() == y.name()`.
|
| 6753 |
+
|
| 6754 |
+
``` cpp
|
| 6755 |
+
strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept;
|
| 6756 |
+
```
|
| 6757 |
+
|
| 6758 |
+
*Returns:* `x.name() <=> y.name()`.
|
| 6759 |
+
|
| 6760 |
+
### Class template `zoned_traits` <a id="time.zone.zonedtraits">[[time.zone.zonedtraits]]</a>
|
| 6761 |
+
|
| 6762 |
+
``` cpp
|
| 6763 |
+
namespace std::chrono {
|
| 6764 |
+
template<class T> struct zoned_traits {};
|
| 6765 |
+
}
|
| 6766 |
+
```
|
| 6767 |
+
|
| 6768 |
+
`zoned_traits` provides a means for customizing the behavior of
|
| 6769 |
+
`zoned_time<Duration, TimeZonePtr>` for the `zoned_time` default
|
| 6770 |
+
constructor, and constructors taking `string_view`. A specialization for
|
| 6771 |
+
`const time_zone*` is provided by the implementation:
|
| 6772 |
+
|
| 6773 |
+
``` cpp
|
| 6774 |
+
namespace std::chrono {
|
| 6775 |
+
template<> struct zoned_traits<const time_zone*> {
|
| 6776 |
+
static const time_zone* default_zone();
|
| 6777 |
+
static const time_zone* locate_zone(string_view name);
|
| 6778 |
+
};
|
| 6779 |
+
}
|
| 6780 |
+
```
|
| 6781 |
+
|
| 6782 |
+
``` cpp
|
| 6783 |
+
static const time_zone* default_zone();
|
| 6784 |
+
```
|
| 6785 |
+
|
| 6786 |
+
*Returns:* `std::chrono::locate_zone("UTC")`.
|
| 6787 |
+
|
| 6788 |
+
``` cpp
|
| 6789 |
+
static const time_zone* locate_zone(string_view name);
|
| 6790 |
+
```
|
| 6791 |
+
|
| 6792 |
+
*Returns:* `std::chrono::locate_zone(name)`.
|
| 6793 |
+
|
| 6794 |
+
### Class template `zoned_time` <a id="time.zone.zonedtime">[[time.zone.zonedtime]]</a>
|
| 6795 |
+
|
| 6796 |
+
#### Overview <a id="time.zone.zonedtime.overview">[[time.zone.zonedtime.overview]]</a>
|
| 6797 |
+
|
| 6798 |
+
``` cpp
|
| 6799 |
+
namespace std::chrono {
|
| 6800 |
+
template<class Duration, class TimeZonePtr = const time_zone*>
|
| 6801 |
+
class zoned_time {
|
| 6802 |
+
public:
|
| 6803 |
+
using duration = common_type_t<Duration, seconds>;
|
| 6804 |
+
|
| 6805 |
+
private:
|
| 6806 |
+
TimeZonePtr zone_; // exposition only
|
| 6807 |
+
sys_time<duration> tp_; // exposition only
|
| 6808 |
+
|
| 6809 |
+
using traits = zoned_traits<TimeZonePtr>; // exposition only
|
| 6810 |
+
|
| 6811 |
+
public:
|
| 6812 |
+
zoned_time();
|
| 6813 |
+
zoned_time(const zoned_time&) = default;
|
| 6814 |
+
zoned_time& operator=(const zoned_time&) = default;
|
| 6815 |
+
|
| 6816 |
+
zoned_time(const sys_time<Duration>& st);
|
| 6817 |
+
explicit zoned_time(TimeZonePtr z);
|
| 6818 |
+
explicit zoned_time(string_view name);
|
| 6819 |
+
|
| 6820 |
+
template<class Duration2>
|
| 6821 |
+
zoned_time(const zoned_time<Duration2, TimeZonePtr>& zt);
|
| 6822 |
+
|
| 6823 |
+
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
|
| 6824 |
+
zoned_time(string_view name, const sys_time<Duration>& st);
|
| 6825 |
+
|
| 6826 |
+
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6827 |
+
zoned_time(string_view name, const local_time<Duration>& tp);
|
| 6828 |
+
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 6829 |
+
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
| 6830 |
+
|
| 6831 |
+
template<class Duration2, class TimeZonePtr2>
|
| 6832 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt);
|
| 6833 |
+
template<class Duration2, class TimeZonePtr2>
|
| 6834 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
|
| 6835 |
+
|
| 6836 |
+
template<class Duration2, class TimeZonePtr2>
|
| 6837 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt);
|
| 6838 |
+
template<class Duration2, class TimeZonePtr2>
|
| 6839 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
|
| 6840 |
+
|
| 6841 |
+
zoned_time& operator=(const sys_time<Duration>& st);
|
| 6842 |
+
zoned_time& operator=(const local_time<Duration>& ut);
|
| 6843 |
+
|
| 6844 |
+
operator sys_time<duration>() const;
|
| 6845 |
+
explicit operator local_time<duration>() const;
|
| 6846 |
+
|
| 6847 |
+
TimeZonePtr get_time_zone() const;
|
| 6848 |
+
local_time<duration> get_local_time() const;
|
| 6849 |
+
sys_time<duration> get_sys_time() const;
|
| 6850 |
+
sys_info get_info() const;
|
| 6851 |
+
};
|
| 6852 |
+
|
| 6853 |
+
zoned_time() -> zoned_time<seconds>;
|
| 6854 |
+
|
| 6855 |
+
template<class Duration>
|
| 6856 |
+
zoned_time(sys_time<Duration>)
|
| 6857 |
+
-> zoned_time<common_type_t<Duration, seconds>>;
|
| 6858 |
+
|
| 6859 |
+
template<class TimeZonePtrOrName>
|
| 6860 |
+
using time-zone-representation = // exposition only
|
| 6861 |
+
conditional_t<is_convertible_v<TimeZonePtrOrName, string_view>,
|
| 6862 |
+
const time_zone*,
|
| 6863 |
+
remove_cvref_t<TimeZonePtrOrName>>;
|
| 6864 |
+
|
| 6865 |
+
template<class TimeZonePtrOrName>
|
| 6866 |
+
zoned_time(TimeZonePtrOrName&&)
|
| 6867 |
+
-> zoned_time<seconds, time-zone-representation<TimeZonePtrOrName>>;
|
| 6868 |
+
|
| 6869 |
+
template<class TimeZonePtrOrName, class Duration>
|
| 6870 |
+
zoned_time(TimeZonePtrOrName&&, sys_time<Duration>)
|
| 6871 |
+
-> zoned_time<common_type_t<Duration, seconds>,
|
| 6872 |
+
time-zone-representation<TimeZonePtrOrName>>;
|
| 6873 |
+
|
| 6874 |
+
template<class TimeZonePtrOrName, class Duration>
|
| 6875 |
+
zoned_time(TimeZonePtrOrName&&, local_time<Duration>,
|
| 6876 |
+
choose = choose::earliest)
|
| 6877 |
+
-> zoned_time<common_type_t<Duration, seconds>,
|
| 6878 |
+
time-zone-representation<TimeZonePtrOrName>>;
|
| 6879 |
+
|
| 6880 |
+
template<class Duration, class TimeZonePtrOrName, class TimeZonePtr2>
|
| 6881 |
+
zoned_time(TimeZonePtrOrName&&, zoned_time<Duration, TimeZonePtr2>,
|
| 6882 |
+
choose = choose::earliest)
|
| 6883 |
+
-> zoned_time<common_type_t<Duration, seconds>,
|
| 6884 |
+
time-zone-representation<TimeZonePtrOrName>>;
|
| 6885 |
+
}
|
| 6886 |
+
```
|
| 6887 |
+
|
| 6888 |
+
`zoned_time` represents a logical pairing of a `time_zone` and a
|
| 6889 |
+
`time_point` with precision `Duration`. `zoned_time<Duration>` maintains
|
| 6890 |
+
the invariant that it always refers to a valid time zone and represents
|
| 6891 |
+
a point in time that exists and is not ambiguous in that time zone.
|
| 6892 |
+
|
| 6893 |
+
If `Duration` is not a specialization of `chrono::duration`, the program
|
| 6894 |
+
is ill-formed.
|
| 6895 |
+
|
| 6896 |
+
Every constructor of `zoned_time` that accepts a `string_view` as its
|
| 6897 |
+
first parameter does not participate in class template argument
|
| 6898 |
+
deduction [[over.match.class.deduct]].
|
| 6899 |
+
|
| 6900 |
+
#### Constructors <a id="time.zone.zonedtime.ctor">[[time.zone.zonedtime.ctor]]</a>
|
| 6901 |
+
|
| 6902 |
+
``` cpp
|
| 6903 |
+
zoned_time();
|
| 6904 |
+
```
|
| 6905 |
+
|
| 6906 |
+
*Constraints:* `traits::default_zone()` is a well-formed expression.
|
| 6907 |
+
|
| 6908 |
+
*Effects:* Initializes `zone_` with `traits::default_zone()` and default
|
| 6909 |
+
constructs `tp_`.
|
| 6910 |
+
|
| 6911 |
+
``` cpp
|
| 6912 |
+
zoned_time(const sys_time<Duration>& st);
|
| 6913 |
+
```
|
| 6914 |
+
|
| 6915 |
+
*Constraints:* `traits::default_zone()` is a well-formed expression.
|
| 6916 |
+
|
| 6917 |
+
*Effects:* Initializes `zone_` with `traits::default_zone()` and `tp_`
|
| 6918 |
+
with `st`.
|
| 6919 |
+
|
| 6920 |
+
``` cpp
|
| 6921 |
+
explicit zoned_time(TimeZonePtr z);
|
| 6922 |
+
```
|
| 6923 |
+
|
| 6924 |
+
*Preconditions:* `z` refers to a time zone.
|
| 6925 |
+
|
| 6926 |
+
*Effects:* Initializes `zone_` with `std::move(z)` and default
|
| 6927 |
+
constructs `tp_`.
|
| 6928 |
+
|
| 6929 |
+
``` cpp
|
| 6930 |
+
explicit zoned_time(string_view name);
|
| 6931 |
+
```
|
| 6932 |
+
|
| 6933 |
+
*Constraints:* `traits::locate_zone(string_view{})` is a well-formed
|
| 6934 |
+
expression and `zoned_time` is constructible from the return type of
|
| 6935 |
+
`traits::locate_zone(string_view{})`.
|
| 6936 |
+
|
| 6937 |
+
*Effects:* Initializes `zone_` with `traits::locate_zone(name)` and
|
| 6938 |
+
default constructs `tp_`.
|
| 6939 |
+
|
| 6940 |
+
``` cpp
|
| 6941 |
+
template<class Duration2>
|
| 6942 |
+
zoned_time(const zoned_time<Duration2, TimeZonePtr>& y);
|
| 6943 |
+
```
|
| 6944 |
+
|
| 6945 |
+
*Constraints:*
|
| 6946 |
+
`is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
|
| 6947 |
+
|
| 6948 |
+
*Effects:* Initializes `zone_` with `y.zone_` and `tp_` with `y.tp_`.
|
| 6949 |
+
|
| 6950 |
+
``` cpp
|
| 6951 |
+
zoned_time(TimeZonePtr z, const sys_time<Duration>& st);
|
| 6952 |
+
```
|
| 6953 |
+
|
| 6954 |
+
*Preconditions:* `z` refers to a time zone.
|
| 6955 |
+
|
| 6956 |
+
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with `st`.
|
| 6957 |
+
|
| 6958 |
+
``` cpp
|
| 6959 |
+
zoned_time(string_view name, const sys_time<Duration>& st);
|
| 6960 |
+
```
|
| 6961 |
+
|
| 6962 |
+
*Constraints:* `zoned_time` is constructible from the return type of
|
| 6963 |
+
`traits::locate_zone(name)` and `st`.
|
| 6964 |
+
|
| 6965 |
+
*Effects:* Equivalent to construction with
|
| 6966 |
+
`{traits::locate_zone(name), st}`.
|
| 6967 |
+
|
| 6968 |
+
``` cpp
|
| 6969 |
+
zoned_time(TimeZonePtr z, const local_time<Duration>& tp);
|
| 6970 |
+
```
|
| 6971 |
+
|
| 6972 |
+
*Preconditions:* `z` refers to a time zone.
|
| 6973 |
+
|
| 6974 |
+
*Constraints:*
|
| 6975 |
+
|
| 6976 |
+
``` cpp
|
| 6977 |
+
is_convertible_v<
|
| 6978 |
+
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{})),
|
| 6979 |
+
sys_time<duration>>
|
| 6980 |
+
```
|
| 6981 |
+
|
| 6982 |
+
is `true`.
|
| 6983 |
+
|
| 6984 |
+
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 6985 |
+
`zone_->to_sys(tp)`.
|
| 6986 |
+
|
| 6987 |
+
``` cpp
|
| 6988 |
+
zoned_time(string_view name, const local_time<Duration>& tp);
|
| 6989 |
+
```
|
| 6990 |
+
|
| 6991 |
+
*Constraints:* `zoned_time` is constructible from the return type of
|
| 6992 |
+
`traits::locate_zone(name)` and `tp`.
|
| 6993 |
+
|
| 6994 |
+
*Effects:* Equivalent to construction with
|
| 6995 |
+
`{traits::locate_zone(name), tp}`.
|
| 6996 |
+
|
| 6997 |
+
``` cpp
|
| 6998 |
+
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
|
| 6999 |
+
```
|
| 7000 |
+
|
| 7001 |
+
*Preconditions:* `z` refers to a time zone.
|
| 7002 |
+
|
| 7003 |
+
*Constraints:*
|
| 7004 |
+
|
| 7005 |
+
``` cpp
|
| 7006 |
+
is_convertible_v<
|
| 7007 |
+
decltype(declval<TimeZonePtr&>()->to_sys(local_time<Duration>{}, choose::earliest)),
|
| 7008 |
+
sys_time<duration>>
|
| 7009 |
+
```
|
| 7010 |
+
|
| 7011 |
+
is `true`.
|
| 7012 |
+
|
| 7013 |
+
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 7014 |
+
`zone_->to_sys(tp, c)`.
|
| 7015 |
+
|
| 7016 |
+
``` cpp
|
| 7017 |
+
zoned_time(string_view name, const local_time<Duration>& tp, choose c);
|
| 7018 |
+
```
|
| 7019 |
+
|
| 7020 |
+
*Constraints:* `zoned_time` is constructible from the return type of
|
| 7021 |
+
`traits::locate_zone(name)`, `local_time<Duration>`, and `choose`.
|
| 7022 |
+
|
| 7023 |
+
*Effects:* Equivalent to construction with
|
| 7024 |
+
`{traits::locate_zone(name), tp, c}`.
|
| 7025 |
+
|
| 7026 |
+
``` cpp
|
| 7027 |
+
template<class Duration2, class TimeZonePtr2>
|
| 7028 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y);
|
| 7029 |
+
```
|
| 7030 |
+
|
| 7031 |
+
*Constraints:*
|
| 7032 |
+
`is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
|
| 7033 |
+
|
| 7034 |
+
*Preconditions:* `z` refers to a valid time zone.
|
| 7035 |
+
|
| 7036 |
+
*Effects:* Initializes `zone_` with `std::move(z)` and `tp_` with
|
| 7037 |
+
`y.tp_`.
|
| 7038 |
+
|
| 7039 |
+
``` cpp
|
| 7040 |
+
template<class Duration2, class TimeZonePtr2>
|
| 7041 |
+
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& y, choose);
|
| 7042 |
+
```
|
| 7043 |
+
|
| 7044 |
+
*Constraints:*
|
| 7045 |
+
`is_convertible_v<sys_time<Duration2>, sys_time<Duration>>` is `true`.
|
| 7046 |
+
|
| 7047 |
+
*Preconditions:* `z` refers to a valid time zone.
|
| 7048 |
+
|
| 7049 |
+
*Effects:* Equivalent to construction with `{z, y}`.
|
| 7050 |
+
|
| 7051 |
+
[*Note 1*: The `choose` parameter has no effect. — *end note*]
|
| 7052 |
+
|
| 7053 |
+
``` cpp
|
| 7054 |
+
template<class Duration2, class TimeZonePtr2>
|
| 7055 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y);
|
| 7056 |
+
```
|
| 7057 |
+
|
| 7058 |
+
*Constraints:* `zoned_time` is constructible from the return type of
|
| 7059 |
+
`traits::locate_zone(name)` and the type
|
| 7060 |
+
`zoned_time<Duration2, TimeZonePtr2>`.
|
| 7061 |
+
|
| 7062 |
+
*Effects:* Equivalent to construction with
|
| 7063 |
+
`{traits::locate_zone(name), y}`.
|
| 7064 |
+
|
| 7065 |
+
``` cpp
|
| 7066 |
+
template<class Duration2, class TimeZonePtr2>
|
| 7067 |
+
zoned_time(string_view name, const zoned_time<Duration2, TimeZonePtr2>& y, choose c);
|
| 7068 |
+
```
|
| 7069 |
+
|
| 7070 |
+
*Constraints:* `zoned_time` is constructible from the return type of
|
| 7071 |
+
`traits::locate_zone(name)`, the type
|
| 7072 |
+
`zoned_time<Duration2, TimeZonePtr2>`, and the type `choose`.
|
| 7073 |
+
|
| 7074 |
+
*Effects:* Equivalent to construction with
|
| 7075 |
+
`{traits::locate_zone(name), y, c}`.
|
| 7076 |
+
|
| 7077 |
+
[*Note 2*: The `choose` parameter has no effect. — *end note*]
|
| 7078 |
+
|
| 7079 |
+
#### Member functions <a id="time.zone.zonedtime.members">[[time.zone.zonedtime.members]]</a>
|
| 7080 |
+
|
| 7081 |
+
``` cpp
|
| 7082 |
+
zoned_time& operator=(const sys_time<Duration>& st);
|
| 7083 |
+
```
|
| 7084 |
+
|
| 7085 |
+
*Effects:* After assignment, `get_sys_time() == st`. This assignment has
|
| 7086 |
+
no effect on the return value of `get_time_zone()`.
|
| 7087 |
+
|
| 7088 |
+
*Returns:* `*this`.
|
| 7089 |
+
|
| 7090 |
+
``` cpp
|
| 7091 |
+
zoned_time& operator=(const local_time<Duration>& lt);
|
| 7092 |
+
```
|
| 7093 |
+
|
| 7094 |
+
*Effects:* After assignment, `get_local_time() == lt`. This assignment
|
| 7095 |
+
has no effect on the return value of `get_time_zone()`.
|
| 7096 |
+
|
| 7097 |
+
*Returns:* `*this`.
|
| 7098 |
+
|
| 7099 |
+
``` cpp
|
| 7100 |
+
operator sys_time<duration>() const;
|
| 7101 |
+
```
|
| 7102 |
+
|
| 7103 |
+
*Returns:* `get_sys_time()`.
|
| 7104 |
+
|
| 7105 |
+
``` cpp
|
| 7106 |
+
explicit operator local_time<duration>() const;
|
| 7107 |
+
```
|
| 7108 |
+
|
| 7109 |
+
*Returns:* `get_local_time()`.
|
| 7110 |
+
|
| 7111 |
+
``` cpp
|
| 7112 |
+
TimeZonePtr get_time_zone() const;
|
| 7113 |
+
```
|
| 7114 |
+
|
| 7115 |
+
*Returns:* `zone_`.
|
| 7116 |
+
|
| 7117 |
+
``` cpp
|
| 7118 |
+
local_time<duration> get_local_time() const;
|
| 7119 |
+
```
|
| 7120 |
+
|
| 7121 |
+
*Returns:* `zone_->to_local(tp_)`.
|
| 7122 |
+
|
| 7123 |
+
``` cpp
|
| 7124 |
+
sys_time<duration> get_sys_time() const;
|
| 7125 |
+
```
|
| 7126 |
+
|
| 7127 |
+
*Returns:* `tp_`.
|
| 7128 |
+
|
| 7129 |
+
``` cpp
|
| 7130 |
+
sys_info get_info() const;
|
| 7131 |
+
```
|
| 7132 |
+
|
| 7133 |
+
*Returns:* `zone_->get_info(tp_)`.
|
| 7134 |
+
|
| 7135 |
+
#### Non-member functions <a id="time.zone.zonedtime.nonmembers">[[time.zone.zonedtime.nonmembers]]</a>
|
| 7136 |
+
|
| 7137 |
+
``` cpp
|
| 7138 |
+
template<class Duration1, class Duration2, class TimeZonePtr>
|
| 7139 |
+
bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
|
| 7140 |
+
const zoned_time<Duration2, TimeZonePtr>& y);
|
| 7141 |
+
```
|
| 7142 |
+
|
| 7143 |
+
*Returns:* `x.zone_ == y.zone_ && x.tp_ == y.tp_`.
|
| 7144 |
+
|
| 7145 |
+
``` cpp
|
| 7146 |
+
template<class charT, class traits, class Duration, class TimeZonePtr>
|
| 7147 |
+
basic_ostream<charT, traits>&
|
| 7148 |
+
operator<<(basic_ostream<charT, traits>& os,
|
| 7149 |
+
const zoned_time<Duration, TimeZonePtr>& t);
|
| 7150 |
+
```
|
| 7151 |
+
|
| 7152 |
+
*Effects:* Streams the value returned from `t.get_local_time()` to `os`
|
| 7153 |
+
using the format `"%F %T %Z"`.
|
| 7154 |
+
|
| 7155 |
+
*Returns:* `os`.
|
| 7156 |
+
|
| 7157 |
+
### Class `leap_second` <a id="time.zone.leap">[[time.zone.leap]]</a>
|
| 7158 |
+
|
| 7159 |
+
#### Overview <a id="time.zone.leap.overview">[[time.zone.leap.overview]]</a>
|
| 7160 |
+
|
| 7161 |
+
``` cpp
|
| 7162 |
+
namespace std::chrono {
|
| 7163 |
+
class leap_second {
|
| 7164 |
+
public:
|
| 7165 |
+
leap_second(const leap_second&) = default;
|
| 7166 |
+
leap_second& operator=(const leap_second&) = default;
|
| 7167 |
+
|
| 7168 |
+
// unspecified additional constructors
|
| 7169 |
+
|
| 7170 |
+
constexpr sys_seconds date() const noexcept;
|
| 7171 |
+
constexpr seconds value() const noexcept;
|
| 7172 |
+
};
|
| 7173 |
+
}
|
| 7174 |
+
```
|
| 7175 |
+
|
| 7176 |
+
Objects of type `leap_second` representing the date and value of the
|
| 7177 |
+
leap second insertions are constructed and stored in the time zone
|
| 7178 |
+
database when initialized.
|
| 7179 |
+
|
| 7180 |
+
[*Example 1*:
|
| 7181 |
+
|
| 7182 |
+
``` cpp
|
| 7183 |
+
for (auto& l : get_tzdb().leap_seconds)
|
| 7184 |
+
if (l <= 2018y/March/17d)
|
| 7185 |
+
cout << l.date() << ": " << l.value() << '\n';
|
| 7186 |
+
```
|
| 7187 |
+
|
| 7188 |
+
Produces the output:
|
| 7189 |
+
|
| 7190 |
+
``` cpp
|
| 7191 |
+
1972-07-01 00:00:00: 1s
|
| 7192 |
+
1973-01-01 00:00:00: 1s
|
| 7193 |
+
1974-01-01 00:00:00: 1s
|
| 7194 |
+
1975-01-01 00:00:00: 1s
|
| 7195 |
+
1976-01-01 00:00:00: 1s
|
| 7196 |
+
1977-01-01 00:00:00: 1s
|
| 7197 |
+
1978-01-01 00:00:00: 1s
|
| 7198 |
+
1979-01-01 00:00:00: 1s
|
| 7199 |
+
1980-01-01 00:00:00: 1s
|
| 7200 |
+
1981-07-01 00:00:00: 1s
|
| 7201 |
+
1982-07-01 00:00:00: 1s
|
| 7202 |
+
1983-07-01 00:00:00: 1s
|
| 7203 |
+
1985-07-01 00:00:00: 1s
|
| 7204 |
+
1988-01-01 00:00:00: 1s
|
| 7205 |
+
1990-01-01 00:00:00: 1s
|
| 7206 |
+
1991-01-01 00:00:00: 1s
|
| 7207 |
+
1992-07-01 00:00:00: 1s
|
| 7208 |
+
1993-07-01 00:00:00: 1s
|
| 7209 |
+
1994-07-01 00:00:00: 1s
|
| 7210 |
+
1996-01-01 00:00:00: 1s
|
| 7211 |
+
1997-07-01 00:00:00: 1s
|
| 7212 |
+
1999-01-01 00:00:00: 1s
|
| 7213 |
+
2006-01-01 00:00:00: 1s
|
| 7214 |
+
2009-01-01 00:00:00: 1s
|
| 7215 |
+
2012-07-01 00:00:00: 1s
|
| 7216 |
+
2015-07-01 00:00:00: 1s
|
| 7217 |
+
2017-01-01 00:00:00: 1s
|
| 7218 |
+
```
|
| 7219 |
+
|
| 7220 |
+
— *end example*]
|
| 7221 |
+
|
| 7222 |
+
#### Member functions <a id="time.zone.leap.members">[[time.zone.leap.members]]</a>
|
| 7223 |
+
|
| 7224 |
+
``` cpp
|
| 7225 |
+
constexpr sys_seconds date() const noexcept;
|
| 7226 |
+
```
|
| 7227 |
+
|
| 7228 |
+
*Returns:* The date and time at which the leap second was inserted.
|
| 7229 |
+
|
| 7230 |
+
``` cpp
|
| 7231 |
+
constexpr seconds value() const noexcept;
|
| 7232 |
+
```
|
| 7233 |
+
|
| 7234 |
+
*Returns:* `+1s` to indicate a positive leap second or `-1s` to indicate
|
| 7235 |
+
a negative leap second.
|
| 7236 |
+
|
| 7237 |
+
[*Note 1*: All leap seconds inserted up through 2019 were positive leap
|
| 7238 |
+
seconds. — *end note*]
|
| 7239 |
+
|
| 7240 |
+
#### Non-member functions <a id="time.zone.leap.nonmembers">[[time.zone.leap.nonmembers]]</a>
|
| 7241 |
+
|
| 7242 |
+
``` cpp
|
| 7243 |
+
constexpr bool operator==(const leap_second& x, const leap_second& y) noexcept;
|
| 7244 |
+
```
|
| 7245 |
+
|
| 7246 |
+
*Returns:* `x.date() == y.date()`.
|
| 7247 |
+
|
| 7248 |
+
``` cpp
|
| 7249 |
+
constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y) noexcept;
|
| 7250 |
+
```
|
| 7251 |
+
|
| 7252 |
+
*Returns:* `x.date() <=> y.date()`.
|
| 7253 |
+
|
| 7254 |
+
``` cpp
|
| 7255 |
+
template<class Duration>
|
| 7256 |
+
constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7257 |
+
```
|
| 7258 |
+
|
| 7259 |
+
*Returns:* `x.date() == y`.
|
| 7260 |
+
|
| 7261 |
+
``` cpp
|
| 7262 |
+
template<class Duration>
|
| 7263 |
+
constexpr bool operator<(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7264 |
+
```
|
| 7265 |
+
|
| 7266 |
+
*Returns:* `x.date() < y`.
|
| 7267 |
+
|
| 7268 |
+
``` cpp
|
| 7269 |
+
template<class Duration>
|
| 7270 |
+
constexpr bool operator<(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
| 7271 |
+
```
|
| 7272 |
+
|
| 7273 |
+
*Returns:* `x < y.date()`.
|
| 7274 |
+
|
| 7275 |
+
``` cpp
|
| 7276 |
+
template<class Duration>
|
| 7277 |
+
constexpr bool operator>(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7278 |
+
```
|
| 7279 |
+
|
| 7280 |
+
*Returns:* `y < x`.
|
| 7281 |
+
|
| 7282 |
+
``` cpp
|
| 7283 |
+
template<class Duration>
|
| 7284 |
+
constexpr bool operator>(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
| 7285 |
+
```
|
| 7286 |
+
|
| 7287 |
+
*Returns:* `y < x`.
|
| 7288 |
+
|
| 7289 |
+
``` cpp
|
| 7290 |
+
template<class Duration>
|
| 7291 |
+
constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7292 |
+
```
|
| 7293 |
+
|
| 7294 |
+
*Returns:* `!(y < x)`.
|
| 7295 |
+
|
| 7296 |
+
``` cpp
|
| 7297 |
+
template<class Duration>
|
| 7298 |
+
constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
| 7299 |
+
```
|
| 7300 |
+
|
| 7301 |
+
*Returns:* `!(y < x)`.
|
| 7302 |
+
|
| 7303 |
+
``` cpp
|
| 7304 |
+
template<class Duration>
|
| 7305 |
+
constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7306 |
+
```
|
| 7307 |
+
|
| 7308 |
+
*Returns:* `!(x < y)`.
|
| 7309 |
+
|
| 7310 |
+
``` cpp
|
| 7311 |
+
template<class Duration>
|
| 7312 |
+
constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y) noexcept;
|
| 7313 |
+
```
|
| 7314 |
+
|
| 7315 |
+
*Returns:* `!(x < y)`.
|
| 7316 |
+
|
| 7317 |
+
``` cpp
|
| 7318 |
+
template<class Duration>
|
| 7319 |
+
requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
|
| 7320 |
+
constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y) noexcept;
|
| 7321 |
+
```
|
| 7322 |
+
|
| 7323 |
+
*Returns:* `x.date() <=> y`.
|
| 7324 |
+
|
| 7325 |
+
### Class `time_zone_link` <a id="time.zone.link">[[time.zone.link]]</a>
|
| 7326 |
+
|
| 7327 |
+
#### Overview <a id="time.zone.link.overview">[[time.zone.link.overview]]</a>
|
| 7328 |
+
|
| 7329 |
``` cpp
|
| 7330 |
+
namespace std::chrono {
|
| 7331 |
+
class time_zone_link {
|
| 7332 |
public:
|
| 7333 |
+
time_zone_link(time_zone_link&&) = default;
|
| 7334 |
+
time_zone_link& operator=(time_zone_link&&) = default;
|
| 7335 |
+
|
| 7336 |
+
// unspecified additional constructors
|
| 7337 |
+
|
| 7338 |
+
string_view name() const noexcept;
|
| 7339 |
+
string_view target() const noexcept;
|
| 7340 |
+
};
|
| 7341 |
+
}
|
| 7342 |
+
```
|
| 7343 |
+
|
| 7344 |
+
A `time_zone_link` specifies an alternative name for a `time_zone`.
|
| 7345 |
+
`time_zone_link`s are constructed when the time zone database is
|
| 7346 |
+
initialized.
|
| 7347 |
+
|
| 7348 |
+
#### Member functions <a id="time.zone.link.members">[[time.zone.link.members]]</a>
|
| 7349 |
+
|
| 7350 |
+
``` cpp
|
| 7351 |
+
string_view name() const noexcept;
|
| 7352 |
+
```
|
| 7353 |
+
|
| 7354 |
+
*Returns:* The alternative name for the time zone.
|
| 7355 |
+
|
| 7356 |
+
``` cpp
|
| 7357 |
+
string_view target() const noexcept;
|
| 7358 |
+
```
|
| 7359 |
+
|
| 7360 |
+
*Returns:* The name of the `time_zone` for which this `time_zone_link`
|
| 7361 |
+
provides an alternative name.
|
| 7362 |
+
|
| 7363 |
+
#### Non-member functions <a id="time.zone.link.nonmembers">[[time.zone.link.nonmembers]]</a>
|
| 7364 |
+
|
| 7365 |
+
``` cpp
|
| 7366 |
+
bool operator==(const time_zone_link& x, const time_zone_link& y) noexcept;
|
| 7367 |
+
```
|
| 7368 |
+
|
| 7369 |
+
*Returns:* `x.name() == y.name()`.
|
| 7370 |
+
|
| 7371 |
+
``` cpp
|
| 7372 |
+
strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y) noexcept;
|
| 7373 |
+
```
|
| 7374 |
+
|
| 7375 |
+
*Returns:* `x.name() <=> y.name()`.
|
| 7376 |
+
|
| 7377 |
+
## Formatting <a id="time.format">[[time.format]]</a>
|
| 7378 |
+
|
| 7379 |
+
Each `formatter` [[format.formatter]] specialization in the chrono
|
| 7380 |
+
library [[time.syn]] meets the requirements [[formatter.requirements]].
|
| 7381 |
+
The `parse` member functions of these formatters interpret the format
|
| 7382 |
+
specification as a *chrono-format-spec* according to the following
|
| 7383 |
+
syntax:
|
| 7384 |
+
|
| 7385 |
+
``` bnf
|
| 7386 |
+
chrono-format-spec
|
| 7387 |
+
fill-and-alignₒₚₜ widthₒₚₜ precisionₒₚₜ chrono-specsₒₚₜ
|
| 7388 |
+
```
|
| 7389 |
+
|
| 7390 |
+
``` bnf
|
| 7391 |
+
chrono-specs
|
| 7392 |
+
conversion-spec
|
| 7393 |
+
chrono-specs conversion-spec
|
| 7394 |
+
chrono-specs literal-char
|
| 7395 |
+
```
|
| 7396 |
|
| 7397 |
+
``` bnf
|
| 7398 |
+
literal-char
|
| 7399 |
+
any character other than \{, \}, or \%
|
| 7400 |
+
```
|
| 7401 |
+
|
| 7402 |
+
``` bnf
|
| 7403 |
+
conversion-spec
|
| 7404 |
+
'%' modifierₒₚₜ type
|
| 7405 |
+
```
|
| 7406 |
+
|
| 7407 |
+
``` bnf
|
| 7408 |
+
modifier one of
|
| 7409 |
+
'E O'
|
| 7410 |
+
```
|
| 7411 |
+
|
| 7412 |
+
``` bnf
|
| 7413 |
+
type one of
|
| 7414 |
+
'a A b B c C d D e F g G h H I j m M n'
|
| 7415 |
+
'p q Q r R S t T u U V w W x X y Y z Z %'
|
| 7416 |
+
```
|
| 7417 |
+
|
| 7418 |
+
The productions *fill-and-align*, *width*, and *precision* are described
|
| 7419 |
+
in [[format.string]]. Giving a *precision* specification in the
|
| 7420 |
+
*chrono-format-spec* is valid only for `std::chrono::duration` types
|
| 7421 |
+
where the representation type `Rep` is a floating-point type. For all
|
| 7422 |
+
other `Rep` types, an exception of type `format_error` is thrown if the
|
| 7423 |
+
*chrono-format-spec* contains a *precision* specification. All ordinary
|
| 7424 |
+
multibyte characters represented by *literal-char* are copied unchanged
|
| 7425 |
+
to the output.
|
| 7426 |
+
|
| 7427 |
+
Each conversion specifier *conversion-spec* is replaced by appropriate
|
| 7428 |
+
characters as described in [[time.format.spec]]. Some of the conversion
|
| 7429 |
+
specifiers depend on the locale that is passed to the formatting
|
| 7430 |
+
function if the latter takes one, or the global locale otherwise. If the
|
| 7431 |
+
formatted object does not contain the information the conversion
|
| 7432 |
+
specifier refers to, an exception of type `format_error` is thrown.
|
| 7433 |
+
|
| 7434 |
+
The result of formatting a `std::chrono::duration` instance holding a
|
| 7435 |
+
negative value, or an `hh_mm_ss` object `h` for which `h.is_negative()`
|
| 7436 |
+
is `true`, is equivalent to the output of the corresponding positive
|
| 7437 |
+
value, with a `STATICALLY-WIDEN<charT>("-")` character sequence placed
|
| 7438 |
+
before the replacement of the initial conversion specifier.
|
| 7439 |
+
|
| 7440 |
+
[*Example 1*:
|
| 7441 |
+
|
| 7442 |
+
``` cpp
|
| 7443 |
+
cout << format("{:%T}", -10'000s); // prints: -02:46:40
|
| 7444 |
+
cout << format("{:%H:%M:%S}", -10'000s); // prints: -02:46:40
|
| 7445 |
+
cout << format("minutes {:%M, hours %H, seconds %S}", -10'000s);
|
| 7446 |
+
// prints: minutes -46, hours 02, seconds 40
|
| 7447 |
+
```
|
| 7448 |
+
|
| 7449 |
+
— *end example*]
|
| 7450 |
+
|
| 7451 |
+
Unless explicitly requested, the result of formatting a chrono type does
|
| 7452 |
+
not contain time zone abbreviation and time zone offset information. If
|
| 7453 |
+
the information is available, the conversion specifiers `%Z` and `%z`
|
| 7454 |
+
will format this information (respectively).
|
| 7455 |
+
|
| 7456 |
+
[*Note 1*: If the information is not available and a `%Z` or `%z`
|
| 7457 |
+
conversion specifier appears in the *chrono-format-spec*, an exception
|
| 7458 |
+
of type `format_error` is thrown, as described above. — *end note*]
|
| 7459 |
+
|
| 7460 |
+
If the type being formatted does not contain the information that the
|
| 7461 |
+
format flag needs, an exception of type `format_error` is thrown.
|
| 7462 |
+
|
| 7463 |
+
[*Example 2*: A `duration` does not contain enough information to
|
| 7464 |
+
format as a `weekday`. — *end example*]
|
| 7465 |
+
|
| 7466 |
+
However, if a flag refers to a “time of day” (e.g. `%H`, `%I`, `%p`,
|
| 7467 |
+
etc.), then a specialization of `duration` is interpreted as the time of
|
| 7468 |
+
day elapsed since midnight.
|
| 7469 |
+
|
| 7470 |
+
**Table: Meaning of conversion specifiers** <a id="time.format.spec">[time.format.spec]</a>
|
| 7471 |
+
|
| 7472 |
+
| Specifier | Replacement |
|
| 7473 |
+
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| 7474 |
+
| `%a` | The locale's abbreviated weekday name. If the value does not contain a valid weekday, an exception of type `format_error` is thrown. |
|
| 7475 |
+
| `%A` | The locale's full weekday name. If the value does not contain a valid weekday, an exception of type `format_error` is thrown. |
|
| 7476 |
+
| `%b` | The locale's abbreviated month name. If the value does not contain a valid month, an exception of type `format_error` is thrown. |
|
| 7477 |
+
| `%B` | The locale's full month name. If the value does not contain a valid month, an exception of type `format_error` is thrown. |
|
| 7478 |
+
| `%c` | The locale's date and time representation. The modified command `%Ec` produces the locale's alternate date and time representation. |
|
| 7479 |
+
| `%C` | The year divided by 100 using floored division. If the result is a single decimal digit, it is prefixed with `0`. The modified command `%EC` produces the locale's alternative representation of the century. |
|
| 7480 |
+
| `%d` | The day of month as a decimal number. If the result is a single decimal digit, it is prefixed with `0`. The modified command `%Od` produces the locale's alternative representation. |
|
| 7481 |
+
| `%D` | Equivalent to `%m/%d/%y`. |
|
| 7482 |
+
| `%e` | The day of month as a decimal number. If the result is a single decimal digit, it is prefixed with a space. The modified command `%Oe` produces the locale's alternative representation. |
|
| 7483 |
+
| `%F` | Equivalent to `%Y-%m-%d`. |
|
| 7484 |
+
| `%g` | The last two decimal digits of the ISO week-based year. If the result is a single digit it is prefixed by `0`. |
|
| 7485 |
+
| `%G` | The ISO week-based year as a decimal number. If the result is less than four digits it is left-padded with `0` to four digits. |
|
| 7486 |
+
| `%h` | Equivalent to `%b`. |
|
| 7487 |
+
| `%H` | The hour (24-hour clock) as a decimal number. If the result is a single digit, it is prefixed with `0`. The modified command `%OH` produces the locale's alternative representation. |
|
| 7488 |
+
| `%I` | The hour (12-hour clock) as a decimal number. If the result is a single digit, it is prefixed with `0`. The modified command `%OI` produces the locale's alternative representation. |
|
| 7489 |
+
| `%j` | If the type being formatted is a specialization of `duration`, the decimal number of `days` without padding. Otherwise, the day of the year as a decimal number. Jan 1 is `001`. If the result is less than three digits, it is left-padded with `0` to three digits. |
|
| 7490 |
+
| `%m` | The month as a decimal number. Jan is `01`. If the result is a single digit, it is prefixed with `0`. The modified command `%Om` produces the locale's alternative representation. |
|
| 7491 |
+
| `%M` | The minute as a decimal number. If the result is a single digit, it is prefixed with `0`. The modified command `%OM` produces the locale's alternative representation. |
|
| 7492 |
+
| `%n` | A new-line character. |
|
| 7493 |
+
| `%p` | The locale's equivalent of the AM/PM designations associated with a 12-hour clock. |
|
| 7494 |
+
| `%q` | The duration's unit suffix as specified in [[time.duration.io]]. |
|
| 7495 |
+
| `%Q` | The duration's numeric value (as if extracted via `.count()`). |
|
| 7496 |
+
| `%r` | The locale's 12-hour clock time. |
|
| 7497 |
+
| `%R` | Equivalent to `%H:%M`. |
|
| 7498 |
+
| `%S` | Seconds as a decimal number. If the number of seconds is less than `10`, the result is prefixed with `0`. If the precision of the input cannot be exactly represented with seconds, then the format is a decimal floating-point number with a fixed format and a precision matching that of the precision of the input (or to a microseconds precision if the conversion to floating-point decimal seconds cannot be made within 18 fractional digits). The character for the decimal point is localized according to the locale. The modified command `%OS` produces the locale's alternative representation. |
|
| 7499 |
+
| `%t` | A horizontal-tab character. |
|
| 7500 |
+
| `%T` | Equivalent to `%H:%M:%S`. |
|
| 7501 |
+
| `%u` | The ISO weekday as a decimal number (`1`-`7`), where Monday is `1`. The modified command `%Ou` produces the locale's alternative representation. |
|
| 7502 |
+
| `%U` | The week number of the year as a decimal number. The first Sunday of the year is the first day of week `01`. Days of the same year prior to that are in week `00`. If the result is a single digit, it is prefixed with `0`. The modified command `%OU` produces the locale's alternative representation. |
|
| 7503 |
+
| `%V` | The ISO week-based week number as a decimal number. If the result is a single digit, it is prefixed with `0`. The modified command `%OV` produces the locale's alternative representation. |
|
| 7504 |
+
| `%w` | The weekday as a decimal number (`0`-`6`), where Sunday is `0`. The modified command `%Ow` produces the locale's alternative representation. |
|
| 7505 |
+
| `%W` | The week number of the year as a decimal number. The first Monday of the year is the first day of week `01`. Days of the same year prior to that are in week `00`. If the result is a single digit, it is prefixed with `0`. The modified command `%OW` produces the locale's alternative representation. |
|
| 7506 |
+
| `%x` | The locale's date representation. The modified command `%Ex` produces the locale's alternate date representation. |
|
| 7507 |
+
| `%X` | The locale's time representation. The modified command `%EX` produces the locale's alternate time representation. |
|
| 7508 |
+
| `%y` | The last two decimal digits of the year. If the result is a single digit it is prefixed by `0`. The modified command `%Oy` produces the locale's alternative representation. The modified command `%Ey` produces the locale's alternative representation of offset from `%EC` (year only). |
|
| 7509 |
+
| `%Y` | The year as a decimal number. If the result is less than four digits it is left-padded with `0` to four digits. The modified command `%EY` produces the locale's alternative full year representation. |
|
| 7510 |
+
| `%z` | The offset from UTC in the ISO 8601 format. For example `-0430` refers to 4 hours 30 minutes behind UTC. If the offset is zero, `+0000` is used. The modified commands `%Ez` and `%Oz` insert a `:` between the hours and minutes: `-04:30`. If the offset information is not available, an exception of type `format_error` is thrown. |
|
| 7511 |
+
| `%Z` | The time zone abbreviation. If the time zone abbreviation is not available, an exception of type `format_error` is thrown. |
|
| 7512 |
+
| `%%` | A `%` character. |
|
| 7513 |
+
|
| 7514 |
+
|
| 7515 |
+
If the *chrono-specs* is omitted, the chrono object is formatted as if
|
| 7516 |
+
by streaming it to `std::ostringstream os` and copying `os.str()`
|
| 7517 |
+
through the output iterator of the context with additional padding and
|
| 7518 |
+
adjustments as specified by the format specifiers.
|
| 7519 |
+
|
| 7520 |
+
[*Example 3*:
|
| 7521 |
+
|
| 7522 |
+
``` cpp
|
| 7523 |
+
string s = format("{:=>8}", 42ms); // value of s is "====42ms"
|
| 7524 |
+
```
|
| 7525 |
+
|
| 7526 |
+
— *end example*]
|
| 7527 |
+
|
| 7528 |
+
``` cpp
|
| 7529 |
+
template<class Duration, class charT>
|
| 7530 |
+
struct formatter<chrono::sys_time<Duration>, charT>;
|
| 7531 |
+
```
|
| 7532 |
+
|
| 7533 |
+
*Remarks:* If `%Z` is used, it is replaced with
|
| 7534 |
+
*`STATICALLY-WIDEN`*`<charT>("UTC")`. If `%z` (or a modified variant of
|
| 7535 |
+
`%z`) is used, an offset of `0min` is formatted.
|
| 7536 |
+
|
| 7537 |
+
``` cpp
|
| 7538 |
+
template<class Duration, class charT>
|
| 7539 |
+
struct formatter<chrono::utc_time<Duration>, charT>;
|
| 7540 |
+
```
|
| 7541 |
+
|
| 7542 |
+
*Remarks:* If `%Z` is used, it is replaced with
|
| 7543 |
+
*`STATICALLY-WIDEN`*`<charT>("UTC")`. If `%z` (or a modified variant of
|
| 7544 |
+
`%z`) is used, an offset of `0min` is formatted. If the argument
|
| 7545 |
+
represents a time during a positive leap second insertion, and if a
|
| 7546 |
+
seconds field is formatted, the integral portion of that format is
|
| 7547 |
+
*`STATICALLY-WIDEN`*`<charT>("60")`.
|
| 7548 |
+
|
| 7549 |
+
``` cpp
|
| 7550 |
+
template<class Duration, class charT>
|
| 7551 |
+
struct formatter<chrono::tai_time<Duration>, charT>;
|
| 7552 |
+
```
|
| 7553 |
+
|
| 7554 |
+
*Remarks:* If `%Z` is used, it is replaced with
|
| 7555 |
+
*`STATICALLY-WIDEN`*`<charT>("TAI")`. If `%z` (or a modified variant of
|
| 7556 |
+
`%z`) is used, an offset of `0min` is formatted. The date and time
|
| 7557 |
+
formatted are equivalent to those formatted by a `sys_time` initialized
|
| 7558 |
+
with
|
| 7559 |
+
|
| 7560 |
+
``` cpp
|
| 7561 |
+
sys_time<Duration>{tp.time_since_epoch()} -
|
| 7562 |
+
(sys_days{1970y/January/1} - sys_days{1958y/January/1})
|
| 7563 |
+
```
|
| 7564 |
+
|
| 7565 |
+
``` cpp
|
| 7566 |
+
template<class Duration, class charT>
|
| 7567 |
+
struct formatter<chrono::gps_time<Duration>, charT>;
|
| 7568 |
+
```
|
| 7569 |
+
|
| 7570 |
+
*Remarks:* If `%Z` is used, it is replaced with
|
| 7571 |
+
*`STATICALLY-WIDEN`*`<charT>("GPS")`. If `%z` (or a modified variant of
|
| 7572 |
+
`%z`) is used, an offset of `0min` is formatted. The date and time
|
| 7573 |
+
formatted are equivalent to those formatted by a `sys_time` initialized
|
| 7574 |
+
with
|
| 7575 |
+
|
| 7576 |
+
``` cpp
|
| 7577 |
+
sys_time<Duration>{tp.time_since_epoch()} +
|
| 7578 |
+
(sys_days{1980y/January/Sunday[1]} - sys_days{1970y/January/1})
|
| 7579 |
+
```
|
| 7580 |
+
|
| 7581 |
+
``` cpp
|
| 7582 |
+
template<class Duration, class charT>
|
| 7583 |
+
struct formatter<chrono::file_time<Duration>, charT>;
|
| 7584 |
+
```
|
| 7585 |
+
|
| 7586 |
+
*Remarks:* If `%Z` is used, it is replaced with
|
| 7587 |
+
*`STATICALLY-WIDEN`*`<charT>("UTC")`. If `%z` (or a modified variant of
|
| 7588 |
+
`%z`) is used, an offset of `0min` is formatted. The date and time
|
| 7589 |
+
formatted are equivalent to those formatted by a `sys_time` initialized
|
| 7590 |
+
with `clock_cast<system_clock>(t)`, or by a `utc_time` initialized with
|
| 7591 |
+
`clock_cast<utc_clock>(t)`, where `t` is the first argument to `format`.
|
| 7592 |
+
|
| 7593 |
+
``` cpp
|
| 7594 |
+
template<class Duration, class charT>
|
| 7595 |
+
struct formatter<chrono::local_time<Duration>, charT>;
|
| 7596 |
+
```
|
| 7597 |
+
|
| 7598 |
+
*Remarks:* If `%Z`, `%z`, or a modified version of `%z` is used, an
|
| 7599 |
+
exception of type `format_error` is thrown.
|
| 7600 |
+
|
| 7601 |
+
``` cpp
|
| 7602 |
+
template<class Duration> struct local-time-format-t { // exposition only
|
| 7603 |
+
local_time<Duration> time; // exposition only
|
| 7604 |
+
const string* abbrev; // exposition only
|
| 7605 |
+
const seconds* offset_sec; // exposition only
|
| 7606 |
+
};
|
| 7607 |
+
```
|
| 7608 |
+
|
| 7609 |
+
``` cpp
|
| 7610 |
+
template<class Duration>
|
| 7611 |
+
local-time-format-t<Duration>
|
| 7612 |
+
local_time_format(local_time<Duration> time, const string* abbrev = nullptr,
|
| 7613 |
+
const seconds* offset_sec = nullptr);
|
| 7614 |
+
```
|
| 7615 |
+
|
| 7616 |
+
*Returns:* `{time, abbrev, offset_sec}`.
|
| 7617 |
+
|
| 7618 |
+
``` cpp
|
| 7619 |
+
template<class Duration, class charT>
|
| 7620 |
+
struct formatter<chrono::local-time-format-t<Duration>, charT>;
|
| 7621 |
+
```
|
| 7622 |
+
|
| 7623 |
+
Let `f` be a *`local-time-format-t`*`<Duration>` object passed to
|
| 7624 |
+
`formatter::format`.
|
| 7625 |
+
|
| 7626 |
+
*Remarks:* If `%Z` is used, it is replaced with `*f.abbrev` if
|
| 7627 |
+
`f.abbrev` is not a null pointer value. If `%Z` is used and `f.abbrev`
|
| 7628 |
+
is a null pointer value, an exception of type `format_error` is thrown.
|
| 7629 |
+
If `%z` (or a modified variant of `%z`) is used, it is formatted with
|
| 7630 |
+
the value of `*f.offset_sec` if `f.offset_sec` is not a null pointer
|
| 7631 |
+
value. If `%z` (or a modified variant of `%z`) is used and
|
| 7632 |
+
`f.offset_sec` is a null pointer value, then an exception of type
|
| 7633 |
+
`format_error` is thrown.
|
| 7634 |
+
|
| 7635 |
+
``` cpp
|
| 7636 |
+
template<class Duration, class TimeZonePtr, class charT>
|
| 7637 |
+
struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>
|
| 7638 |
+
: formatter<chrono::local-time-format-t<Duration>, charT> {
|
| 7639 |
+
template<class FormatContext>
|
| 7640 |
+
typename FormatContext::iterator
|
| 7641 |
+
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
|
| 7642 |
};
|
| 7643 |
```
|
| 7644 |
|
| 7645 |
+
``` cpp
|
| 7646 |
+
template<class FormatContext>
|
| 7647 |
+
typename FormatContext::iterator
|
| 7648 |
+
format(const chrono::zoned_time<Duration, TimeZonePtr>& tp, FormatContext& ctx);
|
| 7649 |
+
```
|
| 7650 |
+
|
| 7651 |
+
*Effects:* Equivalent to:
|
| 7652 |
+
|
| 7653 |
+
``` cpp
|
| 7654 |
+
sys_info info = tp.get_info();
|
| 7655 |
+
return formatter<chrono::local-time-format-t<Duration>, charT>::
|
| 7656 |
+
format({tp.get_local_time(), &info.abbrev, &info.offset}, ctx);
|
| 7657 |
+
```
|
| 7658 |
+
|
| 7659 |
+
## Parsing <a id="time.parse">[[time.parse]]</a>
|
| 7660 |
+
|
| 7661 |
+
Each `parse` overload specified in this subclause calls `from_stream`
|
| 7662 |
+
unqualified, so as to enable argument dependent lookup
|
| 7663 |
+
[[basic.lookup.argdep]]. In the following paragraphs, let `is` denote an
|
| 7664 |
+
object of type `basic_istream<charT, traits>` and let `I` be
|
| 7665 |
+
`basic_istream<charT, traits>&`, where `charT` and `traits` are template
|
| 7666 |
+
parameters in that context.
|
| 7667 |
+
|
| 7668 |
+
``` cpp
|
| 7669 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7670 |
+
unspecified
|
| 7671 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp);
|
| 7672 |
+
```
|
| 7673 |
+
|
| 7674 |
+
*Constraints:* The expression
|
| 7675 |
+
|
| 7676 |
+
``` cpp
|
| 7677 |
+
from_stream(declval<basic_istream<charT, traits>&>(), fmt.c_str(), tp)
|
| 7678 |
+
```
|
| 7679 |
+
|
| 7680 |
+
is well-formed when treated as an unevaluated operand.
|
| 7681 |
+
|
| 7682 |
+
*Returns:* A manipulator such that the expression `is >> parse(fmt, tp)`
|
| 7683 |
+
has type `I`, has value `is`, and calls
|
| 7684 |
+
`from_stream(is, fmt.c_str(), tp)`.
|
| 7685 |
+
|
| 7686 |
+
``` cpp
|
| 7687 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7688 |
+
unspecified
|
| 7689 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7690 |
+
basic_string<charT, traits, Alloc>& abbrev);
|
| 7691 |
+
```
|
| 7692 |
+
|
| 7693 |
+
*Constraints:* The expression
|
| 7694 |
+
|
| 7695 |
+
``` cpp
|
| 7696 |
+
from_stream(declval<basic_istream<charT, traits>&>(), fmt.c_str(), tp, addressof(abbrev))
|
| 7697 |
+
```
|
| 7698 |
+
|
| 7699 |
+
is well-formed when treated as an unevaluated operand.
|
| 7700 |
+
|
| 7701 |
+
*Returns:* A manipulator such that the expression
|
| 7702 |
+
`is >> parse(fmt, tp, abbrev)` has type `I`, has value `is`, and calls
|
| 7703 |
+
`from_stream(is, fmt.c_str(), tp, addressof(abbrev))`.
|
| 7704 |
+
|
| 7705 |
+
``` cpp
|
| 7706 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7707 |
+
unspecified
|
| 7708 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7709 |
+
minutes& offset);
|
| 7710 |
+
```
|
| 7711 |
+
|
| 7712 |
+
*Constraints:* The expression
|
| 7713 |
+
|
| 7714 |
+
``` cpp
|
| 7715 |
+
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7716 |
+
fmt.c_str(), tp,
|
| 7717 |
+
declval<basic_string<charT, traits, Alloc>*>(),
|
| 7718 |
+
&offset)
|
| 7719 |
+
```
|
| 7720 |
+
|
| 7721 |
+
is well-formed when treated as an unevaluated operand.
|
| 7722 |
+
|
| 7723 |
+
*Returns:* A manipulator such that the expression
|
| 7724 |
+
`is >> parse(fmt, tp, offset)` has type `I`, has value `is`, and calls:
|
| 7725 |
+
|
| 7726 |
+
``` cpp
|
| 7727 |
+
from_stream(is,
|
| 7728 |
+
fmt.c_str(), tp,
|
| 7729 |
+
static_cast<basic_string<charT, traits, Alloc>*>(nullptr),
|
| 7730 |
+
&offset)
|
| 7731 |
+
```
|
| 7732 |
+
|
| 7733 |
+
``` cpp
|
| 7734 |
+
template<class charT, class traits, class Alloc, class Parsable>
|
| 7735 |
+
unspecified
|
| 7736 |
+
parse(const basic_string<charT, traits, Alloc>& fmt, Parsable& tp,
|
| 7737 |
+
basic_string<charT, traits, Alloc>& abbrev, minutes& offset);
|
| 7738 |
+
```
|
| 7739 |
+
|
| 7740 |
+
*Constraints:* The expression
|
| 7741 |
+
|
| 7742 |
+
``` cpp
|
| 7743 |
+
from_stream(declval<basic_istream<charT, traits>&>(),
|
| 7744 |
+
fmt.c_str(), tp, addressof(abbrev), &offset)
|
| 7745 |
+
```
|
| 7746 |
+
|
| 7747 |
+
is well-formed when treated as an unevaluated operand.
|
| 7748 |
+
|
| 7749 |
+
*Returns:* A manipulator such that the expression
|
| 7750 |
+
`is >> parse(fmt, tp, abbrev, offset)` has type `I`, has value `is`, and
|
| 7751 |
+
calls `from_stream(is, fmt.c_str(), tp, addressof(abbrev), &offset)`.
|
| 7752 |
+
|
| 7753 |
+
All `from_stream` overloads behave as unformatted input functions,
|
| 7754 |
+
except that they have an unspecified effect on the value returned by
|
| 7755 |
+
subsequent calls to `basic_istream<>::gcount()`. Each overload takes a
|
| 7756 |
+
format string containing ordinary characters and flags which have
|
| 7757 |
+
special meaning. Each flag begins with a `%`. Some flags can be modified
|
| 7758 |
+
by `E` or `O`. During parsing each flag interprets characters as parts
|
| 7759 |
+
of date and time types according to [[time.parse.spec]]. Some flags can
|
| 7760 |
+
be modified by a width parameter given as a positive decimal integer
|
| 7761 |
+
called out as `N` below which governs how many characters are parsed
|
| 7762 |
+
from the stream in interpreting the flag. All characters in the format
|
| 7763 |
+
string that are not represented in [[time.parse.spec]], except for
|
| 7764 |
+
white space, are parsed unchanged from the stream. A white space
|
| 7765 |
+
character matches zero or more white space characters in the input
|
| 7766 |
+
stream.
|
| 7767 |
+
|
| 7768 |
+
If the type being parsed cannot represent the information that the
|
| 7769 |
+
format flag refers to, `is.setstate(ios_base::failbit)` is called.
|
| 7770 |
+
|
| 7771 |
+
[*Example 1*: A `duration` cannot represent a
|
| 7772 |
+
`weekday`. — *end example*]
|
| 7773 |
+
|
| 7774 |
+
However, if a flag refers to a “time of day” (e.g. `%H`, `%I`, `%p`,
|
| 7775 |
+
etc.), then a specialization of `duration` is parsed as the time of day
|
| 7776 |
+
elapsed since midnight.
|
| 7777 |
+
|
| 7778 |
+
If the `from_stream` overload fails to parse everything specified by the
|
| 7779 |
+
format string, or if insufficient information is parsed to specify a
|
| 7780 |
+
complete duration, time point, or calendrical data structure,
|
| 7781 |
+
`setstate(ios_base::failbit)` is called on the `basic_istream`.
|
| 7782 |
+
|
| 7783 |
+
[*Note 1*: `%n`, `%t`, and a space can be combined to match a wide
|
| 7784 |
+
range of white-space patterns. For example, `"%n "` matches one or more
|
| 7785 |
+
white space characters, and `"%n%t%t"` matches one to three white space
|
| 7786 |
+
characters. — *end note*]
|
| 7787 |
+
|
| 7788 |
+
## Header `<ctime>` synopsis <a id="ctime.syn">[[ctime.syn]]</a>
|
| 7789 |
|
| 7790 |
``` cpp
|
| 7791 |
#define NULL see [support.types.nullptr]
|
| 7792 |
#define CLOCKS_PER_SEC see below
|
| 7793 |
#define TIME_UTC see below
|
|
|
|
| 7812 |
size_t strftime(char* s, size_t maxsize, const char* format, const struct tm* timeptr);
|
| 7813 |
}
|
| 7814 |
```
|
| 7815 |
|
| 7816 |
The contents of the header `<ctime>` are the same as the C standard
|
| 7817 |
+
library header `<time.h>`. [^1]
|
| 7818 |
|
| 7819 |
The functions `asctime`, `ctime`, `gmtime`, and `localtime` are not
|
| 7820 |
+
required to avoid data races [[res.on.data.races]].
|
| 7821 |
|
| 7822 |
+
See also: ISO C 7.27
|
| 7823 |
|
| 7824 |
+
<!-- Link reference definitions -->
|
| 7825 |
+
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 7826 |
+
[cpp17.equalitycomparable]: #cpp17.equalitycomparable
|
| 7827 |
+
[cpp17.lessthancomparable]: #cpp17.lessthancomparable
|
| 7828 |
+
[ctime.syn]: #ctime.syn
|
| 7829 |
+
[filesystems]: input.md#filesystems
|
| 7830 |
+
[format.formatter]: utilities.md#format.formatter
|
| 7831 |
+
[format.string]: utilities.md#format.string
|
| 7832 |
+
[formatter.requirements]: utilities.md#formatter.requirements
|
| 7833 |
+
[intro.multithread]: basic.md#intro.multithread
|
| 7834 |
+
[meta.rqmts]: utilities.md#meta.rqmts
|
| 7835 |
+
[numeric.requirements]: numerics.md#numeric.requirements
|
| 7836 |
+
[over.ics.rank]: over.md#over.ics.rank
|
| 7837 |
+
[over.match.class.deduct]: over.md#over.match.class.deduct
|
| 7838 |
+
[res.on.data.races]: library.md#res.on.data.races
|
| 7839 |
+
[swappable.requirements]: library.md#swappable.requirements
|
| 7840 |
+
[temp.deduct]: temp.md#temp.deduct
|
| 7841 |
+
[time]: #time
|
| 7842 |
+
[time.12]: #time.12
|
| 7843 |
+
[time.cal]: #time.cal
|
| 7844 |
+
[time.cal.day]: #time.cal.day
|
| 7845 |
+
[time.cal.day.members]: #time.cal.day.members
|
| 7846 |
+
[time.cal.day.nonmembers]: #time.cal.day.nonmembers
|
| 7847 |
+
[time.cal.day.overview]: #time.cal.day.overview
|
| 7848 |
+
[time.cal.general]: #time.cal.general
|
| 7849 |
+
[time.cal.last]: #time.cal.last
|
| 7850 |
+
[time.cal.md]: #time.cal.md
|
| 7851 |
+
[time.cal.md.members]: #time.cal.md.members
|
| 7852 |
+
[time.cal.md.nonmembers]: #time.cal.md.nonmembers
|
| 7853 |
+
[time.cal.md.overview]: #time.cal.md.overview
|
| 7854 |
+
[time.cal.mdlast]: #time.cal.mdlast
|
| 7855 |
+
[time.cal.month]: #time.cal.month
|
| 7856 |
+
[time.cal.month.members]: #time.cal.month.members
|
| 7857 |
+
[time.cal.month.nonmembers]: #time.cal.month.nonmembers
|
| 7858 |
+
[time.cal.month.overview]: #time.cal.month.overview
|
| 7859 |
+
[time.cal.mwd]: #time.cal.mwd
|
| 7860 |
+
[time.cal.mwd.members]: #time.cal.mwd.members
|
| 7861 |
+
[time.cal.mwd.nonmembers]: #time.cal.mwd.nonmembers
|
| 7862 |
+
[time.cal.mwd.overview]: #time.cal.mwd.overview
|
| 7863 |
+
[time.cal.mwdlast]: #time.cal.mwdlast
|
| 7864 |
+
[time.cal.mwdlast.members]: #time.cal.mwdlast.members
|
| 7865 |
+
[time.cal.mwdlast.nonmembers]: #time.cal.mwdlast.nonmembers
|
| 7866 |
+
[time.cal.mwdlast.overview]: #time.cal.mwdlast.overview
|
| 7867 |
+
[time.cal.operators]: #time.cal.operators
|
| 7868 |
+
[time.cal.wd]: #time.cal.wd
|
| 7869 |
+
[time.cal.wd.members]: #time.cal.wd.members
|
| 7870 |
+
[time.cal.wd.nonmembers]: #time.cal.wd.nonmembers
|
| 7871 |
+
[time.cal.wd.overview]: #time.cal.wd.overview
|
| 7872 |
+
[time.cal.wdidx]: #time.cal.wdidx
|
| 7873 |
+
[time.cal.wdidx.members]: #time.cal.wdidx.members
|
| 7874 |
+
[time.cal.wdidx.nonmembers]: #time.cal.wdidx.nonmembers
|
| 7875 |
+
[time.cal.wdidx.overview]: #time.cal.wdidx.overview
|
| 7876 |
+
[time.cal.wdlast]: #time.cal.wdlast
|
| 7877 |
+
[time.cal.wdlast.members]: #time.cal.wdlast.members
|
| 7878 |
+
[time.cal.wdlast.nonmembers]: #time.cal.wdlast.nonmembers
|
| 7879 |
+
[time.cal.wdlast.overview]: #time.cal.wdlast.overview
|
| 7880 |
+
[time.cal.year]: #time.cal.year
|
| 7881 |
+
[time.cal.year.members]: #time.cal.year.members
|
| 7882 |
+
[time.cal.year.nonmembers]: #time.cal.year.nonmembers
|
| 7883 |
+
[time.cal.year.overview]: #time.cal.year.overview
|
| 7884 |
+
[time.cal.ym]: #time.cal.ym
|
| 7885 |
+
[time.cal.ym.members]: #time.cal.ym.members
|
| 7886 |
+
[time.cal.ym.nonmembers]: #time.cal.ym.nonmembers
|
| 7887 |
+
[time.cal.ym.overview]: #time.cal.ym.overview
|
| 7888 |
+
[time.cal.ymd]: #time.cal.ymd
|
| 7889 |
+
[time.cal.ymd.members]: #time.cal.ymd.members
|
| 7890 |
+
[time.cal.ymd.nonmembers]: #time.cal.ymd.nonmembers
|
| 7891 |
+
[time.cal.ymd.overview]: #time.cal.ymd.overview
|
| 7892 |
+
[time.cal.ymdlast]: #time.cal.ymdlast
|
| 7893 |
+
[time.cal.ymdlast.members]: #time.cal.ymdlast.members
|
| 7894 |
+
[time.cal.ymdlast.nonmembers]: #time.cal.ymdlast.nonmembers
|
| 7895 |
+
[time.cal.ymdlast.overview]: #time.cal.ymdlast.overview
|
| 7896 |
+
[time.cal.ymwd]: #time.cal.ymwd
|
| 7897 |
+
[time.cal.ymwd.members]: #time.cal.ymwd.members
|
| 7898 |
+
[time.cal.ymwd.nonmembers]: #time.cal.ymwd.nonmembers
|
| 7899 |
+
[time.cal.ymwd.overview]: #time.cal.ymwd.overview
|
| 7900 |
+
[time.cal.ymwdlast]: #time.cal.ymwdlast
|
| 7901 |
+
[time.cal.ymwdlast.members]: #time.cal.ymwdlast.members
|
| 7902 |
+
[time.cal.ymwdlast.nonmembers]: #time.cal.ymwdlast.nonmembers
|
| 7903 |
+
[time.cal.ymwdlast.overview]: #time.cal.ymwdlast.overview
|
| 7904 |
+
[time.clock]: #time.clock
|
| 7905 |
+
[time.clock.cast]: #time.clock.cast
|
| 7906 |
+
[time.clock.cast.fn]: #time.clock.cast.fn
|
| 7907 |
+
[time.clock.cast.id]: #time.clock.cast.id
|
| 7908 |
+
[time.clock.cast.sys]: #time.clock.cast.sys
|
| 7909 |
+
[time.clock.cast.sys.utc]: #time.clock.cast.sys.utc
|
| 7910 |
+
[time.clock.cast.utc]: #time.clock.cast.utc
|
| 7911 |
+
[time.clock.conv]: #time.clock.conv
|
| 7912 |
+
[time.clock.file]: #time.clock.file
|
| 7913 |
+
[time.clock.file.members]: #time.clock.file.members
|
| 7914 |
+
[time.clock.file.nonmembers]: #time.clock.file.nonmembers
|
| 7915 |
+
[time.clock.file.overview]: #time.clock.file.overview
|
| 7916 |
+
[time.clock.gps]: #time.clock.gps
|
| 7917 |
+
[time.clock.gps.members]: #time.clock.gps.members
|
| 7918 |
+
[time.clock.gps.nonmembers]: #time.clock.gps.nonmembers
|
| 7919 |
+
[time.clock.gps.overview]: #time.clock.gps.overview
|
| 7920 |
+
[time.clock.hires]: #time.clock.hires
|
| 7921 |
+
[time.clock.local]: #time.clock.local
|
| 7922 |
+
[time.clock.req]: #time.clock.req
|
| 7923 |
+
[time.clock.steady]: #time.clock.steady
|
| 7924 |
+
[time.clock.system]: #time.clock.system
|
| 7925 |
+
[time.clock.system.members]: #time.clock.system.members
|
| 7926 |
+
[time.clock.system.nonmembers]: #time.clock.system.nonmembers
|
| 7927 |
+
[time.clock.system.overview]: #time.clock.system.overview
|
| 7928 |
+
[time.clock.tai]: #time.clock.tai
|
| 7929 |
+
[time.clock.tai.members]: #time.clock.tai.members
|
| 7930 |
+
[time.clock.tai.nonmembers]: #time.clock.tai.nonmembers
|
| 7931 |
+
[time.clock.tai.overview]: #time.clock.tai.overview
|
| 7932 |
+
[time.clock.utc]: #time.clock.utc
|
| 7933 |
+
[time.clock.utc.members]: #time.clock.utc.members
|
| 7934 |
+
[time.clock.utc.nonmembers]: #time.clock.utc.nonmembers
|
| 7935 |
+
[time.clock.utc.overview]: #time.clock.utc.overview
|
| 7936 |
+
[time.duration]: #time.duration
|
| 7937 |
+
[time.duration.alg]: #time.duration.alg
|
| 7938 |
+
[time.duration.arithmetic]: #time.duration.arithmetic
|
| 7939 |
+
[time.duration.cast]: #time.duration.cast
|
| 7940 |
+
[time.duration.comparisons]: #time.duration.comparisons
|
| 7941 |
+
[time.duration.cons]: #time.duration.cons
|
| 7942 |
+
[time.duration.io]: #time.duration.io
|
| 7943 |
+
[time.duration.literals]: #time.duration.literals
|
| 7944 |
+
[time.duration.nonmember]: #time.duration.nonmember
|
| 7945 |
+
[time.duration.observer]: #time.duration.observer
|
| 7946 |
+
[time.duration.special]: #time.duration.special
|
| 7947 |
+
[time.format]: #time.format
|
| 7948 |
+
[time.format.spec]: #time.format.spec
|
| 7949 |
+
[time.general]: #time.general
|
| 7950 |
+
[time.hms]: #time.hms
|
| 7951 |
+
[time.hms.members]: #time.hms.members
|
| 7952 |
+
[time.hms.nonmembers]: #time.hms.nonmembers
|
| 7953 |
+
[time.hms.overview]: #time.hms.overview
|
| 7954 |
+
[time.hms.width]: #time.hms.width
|
| 7955 |
+
[time.parse]: #time.parse
|
| 7956 |
+
[time.parse.spec]: #time.parse.spec
|
| 7957 |
+
[time.point]: #time.point
|
| 7958 |
+
[time.point.arithmetic]: #time.point.arithmetic
|
| 7959 |
+
[time.point.cast]: #time.point.cast
|
| 7960 |
+
[time.point.comparisons]: #time.point.comparisons
|
| 7961 |
+
[time.point.cons]: #time.point.cons
|
| 7962 |
+
[time.point.nonmember]: #time.point.nonmember
|
| 7963 |
+
[time.point.observer]: #time.point.observer
|
| 7964 |
+
[time.point.special]: #time.point.special
|
| 7965 |
+
[time.summary]: #time.summary
|
| 7966 |
+
[time.syn]: #time.syn
|
| 7967 |
+
[time.traits]: #time.traits
|
| 7968 |
+
[time.traits.duration.values]: #time.traits.duration.values
|
| 7969 |
+
[time.traits.is.clock]: #time.traits.is.clock
|
| 7970 |
+
[time.traits.is.fp]: #time.traits.is.fp
|
| 7971 |
+
[time.traits.specializations]: #time.traits.specializations
|
| 7972 |
+
[time.zone]: #time.zone
|
| 7973 |
+
[time.zone.db]: #time.zone.db
|
| 7974 |
+
[time.zone.db.access]: #time.zone.db.access
|
| 7975 |
+
[time.zone.db.list]: #time.zone.db.list
|
| 7976 |
+
[time.zone.db.remote]: #time.zone.db.remote
|
| 7977 |
+
[time.zone.db.tzdb]: #time.zone.db.tzdb
|
| 7978 |
+
[time.zone.exception]: #time.zone.exception
|
| 7979 |
+
[time.zone.exception.ambig]: #time.zone.exception.ambig
|
| 7980 |
+
[time.zone.exception.nonexist]: #time.zone.exception.nonexist
|
| 7981 |
+
[time.zone.general]: #time.zone.general
|
| 7982 |
+
[time.zone.info]: #time.zone.info
|
| 7983 |
+
[time.zone.info.local]: #time.zone.info.local
|
| 7984 |
+
[time.zone.info.sys]: #time.zone.info.sys
|
| 7985 |
+
[time.zone.leap]: #time.zone.leap
|
| 7986 |
+
[time.zone.leap.members]: #time.zone.leap.members
|
| 7987 |
+
[time.zone.leap.nonmembers]: #time.zone.leap.nonmembers
|
| 7988 |
+
[time.zone.leap.overview]: #time.zone.leap.overview
|
| 7989 |
+
[time.zone.link]: #time.zone.link
|
| 7990 |
+
[time.zone.link.members]: #time.zone.link.members
|
| 7991 |
+
[time.zone.link.nonmembers]: #time.zone.link.nonmembers
|
| 7992 |
+
[time.zone.link.overview]: #time.zone.link.overview
|
| 7993 |
+
[time.zone.members]: #time.zone.members
|
| 7994 |
+
[time.zone.nonmembers]: #time.zone.nonmembers
|
| 7995 |
+
[time.zone.overview]: #time.zone.overview
|
| 7996 |
+
[time.zone.timezone]: #time.zone.timezone
|
| 7997 |
+
[time.zone.zonedtime]: #time.zone.zonedtime
|
| 7998 |
+
[time.zone.zonedtime.ctor]: #time.zone.zonedtime.ctor
|
| 7999 |
+
[time.zone.zonedtime.members]: #time.zone.zonedtime.members
|
| 8000 |
+
[time.zone.zonedtime.nonmembers]: #time.zone.zonedtime.nonmembers
|
| 8001 |
+
[time.zone.zonedtime.overview]: #time.zone.zonedtime.overview
|
| 8002 |
+
[time.zone.zonedtraits]: #time.zone.zonedtraits
|
| 8003 |
+
|
| 8004 |
+
[^1]: `strftime` supports the C conversion specifiers `C`, `D`, `e`,
|
| 8005 |
+
`F`, `g`, `G`, `h`, `r`, `R`, `t`, `T`, `u`, `V`, and `z`, and the
|
| 8006 |
+
modifiers `E` and `O`.
|