19
19
#if CPPREFERENCE_STDVER>= 2011
20
20
#include <ratio>
21
21
#include <ctime> // for time_t
22
+ #include <iosfwd>
23
+ #include <string>
22
24
23
25
namespace std {
24
26
namespace chrono {
@@ -133,6 +135,12 @@ typedef duration<int, std::milli> milliseconds;
133
135
typedef duration<int> seconds;
134
136
typedef duration<int, std::ratio<60>> minutes;
135
137
typedef duration<int, std::ratio<3600>> hours;
138
+ #if CPPREFERENCE_STDVER >= 2020
139
+ using days = duration<int, ratio<86400>>;
140
+ using weeks = duration<int, ratio<604800>>;
141
+ using months = duration<int, ratio<2629746>>;
142
+ using years = duration<int, ratio<31556952>>;
143
+ #endif
136
144
137
145
template <class Rep>
138
146
struct treat_as_floating_point : std::is_floating_point<Rep> {};
@@ -251,6 +259,26 @@ public:
251
259
static std::chrono::system_clock::time_point from_time_t(std::time_t t);
252
260
};
253
261
262
+ #if CPPREFERENCE_STDVER >= 2020
263
+ template<class Duration>
264
+ using sys_time = time_point<system_clock, Duration>;
265
+
266
+ using sys_seconds = sys_time<seconds>;
267
+ using sys_days = sys_time<days>;
268
+
269
+ template <class CharT, class Traits, class Duration, class Alloc = allocator<CharT>>
270
+ basic_istream<CharT, Traits>&
271
+ from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt,
272
+ sys_time<Duration>& time_point,
273
+ basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
274
+ minutes* offset = nullptr);
275
+
276
+ template<class CharT, class Traits, class Duration>
277
+ basic_ostream<CharT, Traits>&
278
+ operator<<(basic_ostream<CharT, Traits>& os,
279
+ const sys_time<Duration>& time_point);
280
+ #endif
281
+
254
282
class steady_clock {
255
283
public:
256
284
typedef int rep; // SIMPLIFIED: actually unspecified
@@ -275,6 +303,82 @@ public:
275
303
static std::chrono::time_point<std::chrono::high_resolution_clock> now();
276
304
};
277
305
306
+ #if CPPREFERENCE_STDVER >= 2020
307
+ class utc_clock {
308
+ public:
309
+ using rep = int; // SIMPLIFIED: actually unspecified
310
+ using period = ratio<1>; // SIMPLIFIED: actually unspecified
311
+ using duration = std::chrono::duration<rep, period>;
312
+ using time_point = std::chrono::time_point<utc_clock>;
313
+
314
+ static time_point now();
315
+
316
+ template<class Duration>
317
+ static sys_time<common_type_t<Duration, seconds>>
318
+ to_sys(const std::chrono::time_point<utc_clock, Duration>& t);
319
+
320
+ template <class Duration>
321
+ static std::chrono::time_point<utc_clock, std::common_type_t<Duration, seconds>>
322
+ from_sys(const sys_time<Duration>& t);
323
+ };
324
+
325
+ template<class Duration>
326
+ using utc_time = time_point<utc_clock, Duration>;
327
+
328
+ using utc_seconds = utc_time<seconds>;
329
+
330
+ template <class CharT, class Traits, class Duration, class Alloc = allocator<CharT>>
331
+ basic_istream<CharT, Traits>&
332
+ from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt,
333
+ utc_time<Duration>& time_point,
334
+ basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
335
+ minutes* offset = nullptr);
336
+
337
+ template<class CharT, class Traits, class Duration>
338
+ basic_ostream<CharT, Traits>&
339
+ operator<<(basic_ostream<CharT, Traits>& os, const chrono::utc_time<Duration>& time_point);
340
+
341
+ class file_clock {
342
+ public:
343
+ using rep = int; // SIMPLIFIED: actually unspecified
344
+ using period = std::ratio<1>; // SIMPLIFIED: actually unspecified
345
+ using duration = duration<rep, period>;
346
+ using time_point = time_point<file_clock>;
347
+
348
+ static time_point now();
349
+
350
+ template<class Duration>
351
+ static sys_time<common_type_t<Duration, seconds>>
352
+ to_sys(const std::chrono::time_point<file_clock, Duration>& t);
353
+
354
+ template <class Duration>
355
+ static std::chrono::time_point<file_clock, std::common_type_t<Duration, seconds>>
356
+ from_sys(const sys_time<Duration>& t);
357
+
358
+ template<class Duration>
359
+ static utc_time<common_type_t<Duration, seconds>>
360
+ to_utc(const std::chrono::time_point<utc_clock, Duration>& t);
361
+
362
+ template <class Duration>
363
+ static std::chrono::time_point<file_clock, std::common_type_t<Duration, seconds>>
364
+ from_utc(const utc_time<Duration>& t);
365
+ };
366
+
367
+ template<class Duration>
368
+ using file_time = time_point<file_clock, Duration>;
369
+
370
+ template <class CharT, class Traits, class Duration, class Alloc = allocator<CharT>>
371
+ basic_istream<CharT, Traits>&
372
+ from_stream(basic_istream<CharT, Traits>& is, const CharT* fmt,
373
+ file_time<Duration>& time_point,
374
+ basic_string<CharT, Traits, Alloc>* abbrev = nullptr,
375
+ minutes* offset = nullptr);
376
+
377
+ template<class CharT, class Traits, class Duration>
378
+ basic_ostream<CharT, Traits>&
379
+ operator<<(basic_ostream<CharT, Traits>& os, const file_time<Duration>& time_point);
380
+ #endif
381
+
278
382
} // namespace chrono
279
383
} // namespace std
280
384
0 commit comments