2 //===----------------------------------------------------------------------===//
4 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5 // See https://llvm.org/LICENSE.txt for license information.
6 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
8 //===----------------------------------------------------------------------===//
10 #ifndef _LIBCPP_CHRONO
11 #define _LIBCPP_CHRONO
16 #include <compare> // C++20
23 template <class ToDuration, class Rep, class Period>
26 duration_cast(const duration<Rep, Period>& fd);
28 template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
30 template <class Rep> inline constexpr bool treat_as_floating_point_v
31 = treat_as_floating_point<Rep>::value; // C++17
34 struct duration_values
37 static constexpr Rep zero(); // noexcept in C++20
38 static constexpr Rep max(); // noexcept in C++20
39 static constexpr Rep min(); // noexcept in C++20
44 template <class Rep, class Period = ratio<1>>
47 static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
48 static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
49 static_assert(Period::num > 0, "duration period must be positive");
52 typedef typename _Period::type period;
54 constexpr duration() = default;
56 constexpr explicit duration(const Rep2& r,
59 is_convertible<Rep2, rep>::value &&
60 (treat_as_floating_point<rep>::value ||
61 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
65 template <class Rep2, class Period2>
66 constexpr duration(const duration<Rep2, Period2>& d,
69 treat_as_floating_point<rep>::value ||
70 ratio_divide<Period2, period>::type::den == 1
75 constexpr rep count() const;
79 constexpr common_type<duration>::type operator+() const;
80 constexpr common_type<duration>::type operator-() const;
81 constexpr duration& operator++(); // constexpr in C++17
82 constexpr duration operator++(int); // constexpr in C++17
83 constexpr duration& operator--(); // constexpr in C++17
84 constexpr duration operator--(int); // constexpr in C++17
86 constexpr duration& operator+=(const duration& d); // constexpr in C++17
87 constexpr duration& operator-=(const duration& d); // constexpr in C++17
89 duration& operator*=(const rep& rhs); // constexpr in C++17
90 duration& operator/=(const rep& rhs); // constexpr in C++17
91 duration& operator%=(const rep& rhs); // constexpr in C++17
92 duration& operator%=(const duration& rhs); // constexpr in C++17
96 static constexpr duration zero(); // noexcept in C++20
97 static constexpr duration min(); // noexcept in C++20
98 static constexpr duration max(); // noexcept in C++20
101 typedef duration<long long, nano> nanoseconds;
102 typedef duration<long long, micro> microseconds;
103 typedef duration<long long, milli> milliseconds;
104 typedef duration<long long > seconds;
105 typedef duration< long, ratio< 60> > minutes;
106 typedef duration< long, ratio<3600> > hours;
108 template <class Clock, class Duration = typename Clock::duration>
113 typedef Duration duration;
114 typedef typename duration::rep rep;
115 typedef typename duration::period period;
117 duration d_; // exposition only
120 time_point(); // has value "epoch" // constexpr in C++14
121 explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14
124 template <class Duration2>
125 time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
129 duration time_since_epoch() const; // constexpr in C++14
133 time_point& operator+=(const duration& d); // constexpr in C++17
134 time_point& operator-=(const duration& d); // constexpr in C++17
138 static constexpr time_point min(); // noexcept in C++20
139 static constexpr time_point max(); // noexcept in C++20
144 // common_type traits
145 template <class Rep1, class Period1, class Rep2, class Period2>
146 struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
148 template <class Clock, class Duration1, class Duration2>
149 struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
153 // duration arithmetic
154 template <class Rep1, class Period1, class Rep2, class Period2>
156 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
157 operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
158 template <class Rep1, class Period1, class Rep2, class Period2>
160 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
161 operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
162 template <class Rep1, class Period, class Rep2>
164 duration<typename common_type<Rep1, Rep2>::type, Period>
165 operator*(const duration<Rep1, Period>& d, const Rep2& s);
166 template <class Rep1, class Period, class Rep2>
168 duration<typename common_type<Rep1, Rep2>::type, Period>
169 operator*(const Rep1& s, const duration<Rep2, Period>& d);
170 template <class Rep1, class Period, class Rep2>
172 duration<typename common_type<Rep1, Rep2>::type, Period>
173 operator/(const duration<Rep1, Period>& d, const Rep2& s);
174 template <class Rep1, class Period1, class Rep2, class Period2>
176 typename common_type<Rep1, Rep2>::type
177 operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
179 // duration comparisons
180 template <class Rep1, class Period1, class Rep2, class Period2>
182 bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
183 template <class Rep1, class Period1, class Rep2, class Period2>
185 bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // removed in C++20
186 template <class Rep1, class Period1, class Rep2, class Period2>
188 bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
189 template <class Rep1, class Period1, class Rep2, class Period2>
191 bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
192 template <class Rep1, class Period1, class Rep2, class Period2>
194 bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
195 template <class Rep1, class Period1, class Rep2, class Period2>
197 bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
198 template<class Rep1, class Period1, class Rep2, class Period2>
199 requires three_way_comparable<typename CT::rep>
200 constexpr auto operator<=>(const duration<Rep1, Period1>& lhs,
201 const duration<Rep2, Period2>& rhs); // since C++20
204 template <class ToDuration, class Rep, class Period>
205 ToDuration duration_cast(const duration<Rep, Period>& d);
207 template <class ToDuration, class Rep, class Period>
208 constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
209 template <class ToDuration, class Rep, class Period>
210 constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
211 template <class ToDuration, class Rep, class Period>
212 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
215 template<class charT, class traits, class Rep, class Period> // C++20
216 basic_ostream<charT, traits>&
217 operator<<(basic_ostream<charT, traits>& os,
218 const duration<Rep, Period>& d);
220 // time_point arithmetic (all constexpr in C++14)
221 template <class Clock, class Duration1, class Rep2, class Period2>
222 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
223 operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
224 template <class Rep1, class Period1, class Clock, class Duration2>
225 time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
226 operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
227 template <class Clock, class Duration1, class Rep2, class Period2>
228 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
229 operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
230 template <class Clock, class Duration1, class Duration2>
231 typename common_type<Duration1, Duration2>::type
232 operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
234 // time_point comparisons (all constexpr in C++14)
235 template <class Clock, class Duration1, class Duration2>
236 bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
237 template <class Clock, class Duration1, class Duration2>
238 bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); // removed in C++20
239 template <class Clock, class Duration1, class Duration2>
240 bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
241 template <class Clock, class Duration1, class Duration2>
242 bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
243 template <class Clock, class Duration1, class Duration2>
244 bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
245 template <class Clock, class Duration1, class Duration2>
246 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
247 template<class Clock, class Duration1,
248 three_way_comparable_with<Duration1> Duration2>
249 constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
250 const time_point<Clock, Duration2>& rhs); // since C++20
252 // time_point_cast (constexpr in C++14)
254 template <class ToDuration, class Clock, class Duration>
255 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
257 template <class ToDuration, class Clock, class Duration>
258 constexpr time_point<Clock, ToDuration>
259 floor(const time_point<Clock, Duration>& tp); // C++17
261 template <class ToDuration, class Clock, class Duration>
262 constexpr time_point<Clock, ToDuration>
263 ceil(const time_point<Clock, Duration>& tp); // C++17
265 template <class ToDuration, class Clock, class Duration>
266 constexpr time_point<Clock, ToDuration>
267 round(const time_point<Clock, Duration>& tp); // C++17
269 template <class Rep, class Period>
270 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
277 typedef microseconds duration;
278 typedef duration::rep rep;
279 typedef duration::period period;
280 typedef chrono::time_point<system_clock> time_point;
281 static const bool is_steady = false; // constexpr in C++14
283 static time_point now() noexcept;
284 static time_t to_time_t (const time_point& __t) noexcept;
285 static time_point from_time_t(time_t __t) noexcept;
288 template <class Duration>
289 using sys_time = time_point<system_clock, Duration>; // C++20
290 using sys_seconds = sys_time<seconds>; // C++20
291 using sys_days = sys_time<days>; // C++20
293 template<class charT, class traits, class Duration> // C++20
294 basic_ostream<charT, traits>&
295 operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
297 class file_clock // C++20
300 typedef see-below rep;
302 typedef chrono::duration<rep, period> duration;
303 typedef chrono::time_point<file_clock> time_point;
304 static constexpr bool is_steady = false;
306 static time_point now() noexcept;
308 template<class Duration>
309 static sys_time<see-below> to_sys(const file_time<Duration>&);
311 template<class Duration>
312 static file_time<see-below> from_sys(const sys_time<Duration>&);
315 template<class Duration>
316 using file_time = time_point<file_clock, Duration>; // C++20
318 template<class charT, class traits, class Duration> // C++20
319 basic_ostream<charT, traits>&
320 operator<<(basic_ostream<charT, traits>& os, const file_time<Duration>& tp);
325 typedef nanoseconds duration;
326 typedef duration::rep rep;
327 typedef duration::period period;
328 typedef chrono::time_point<steady_clock, duration> time_point;
329 static const bool is_steady = true; // constexpr in C++14
331 static time_point now() noexcept;
334 typedef steady_clock high_resolution_clock;
336 // 25.7.8, local time // C++20
338 template<class Duration>
339 using local_time = time_point<local_t, Duration>;
340 using local_seconds = local_time<seconds>;
341 using local_days = local_time<days>;
343 template<class charT, class traits, class Duration> // C++20
344 basic_ostream<charT, traits>&
345 operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);
347 // 25.8.2, class last_spec // C++20
350 // 25.8.3, class day // C++20
353 constexpr bool operator==(const day& x, const day& y) noexcept;
354 constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
355 constexpr day operator+(const day& x, const days& y) noexcept;
356 constexpr day operator+(const days& x, const day& y) noexcept;
357 constexpr day operator-(const day& x, const days& y) noexcept;
358 constexpr days operator-(const day& x, const day& y) noexcept;
359 template<class charT, class traits>
360 basic_ostream<charT, traits>&
361 operator<<(basic_ostream<charT, traits>& os, const day& d);
363 // 25.8.4, class month // C++20
365 constexpr bool operator==(const month& x, const month& y) noexcept;
366 constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
368 constexpr month operator+(const month& x, const months& y) noexcept;
369 constexpr month operator+(const months& x, const month& y) noexcept;
370 constexpr month operator-(const month& x, const months& y) noexcept;
371 constexpr months operator-(const month& x, const month& y) noexcept;
372 template<class charT, class traits>
373 basic_ostream<charT, traits>&
374 operator<<(basic_ostream<charT, traits>& os, const month& m);
376 // 25.8.5, class year // C++20
378 constexpr bool operator==(const year& x, const year& y) noexcept;
379 constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
381 constexpr year operator+(const year& x, const years& y) noexcept;
382 constexpr year operator+(const years& x, const year& y) noexcept;
383 constexpr year operator-(const year& x, const years& y) noexcept;
384 constexpr years operator-(const year& x, const year& y) noexcept;
385 template<class charT, class traits>
386 basic_ostream<charT, traits>&
387 operator<<(basic_ostream<charT, traits>& os, const year& y);
389 // 25.8.6, class weekday // C++20
392 constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
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 template<class charT, class traits>
398 basic_ostream<charT, traits>&
399 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
401 // 25.8.7, class weekday_indexed // C++20
403 class weekday_indexed;
404 constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
406 template<class charT, class traits>
407 basic_ostream<charT, traits>&
408 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
410 // 25.8.8, class weekday_last // C++20
413 constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
415 template<class charT, class traits>
416 basic_ostream<charT, traits>&
417 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
419 // 25.8.9, class month_day // C++20
422 constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
423 constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
425 template<class charT, class traits>
426 basic_ostream<charT, traits>&
427 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
429 // 25.8.10, class month_day_last // C++20
430 class month_day_last;
432 constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
433 constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
435 template<class charT, class traits>
436 basic_ostream<charT, traits>&
437 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
439 // 25.8.11, class month_weekday // C++20
442 constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
444 template<class charT, class traits>
445 basic_ostream<charT, traits>&
446 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
448 // 25.8.12, class month_weekday_last // C++20
449 class month_weekday_last;
451 constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
453 template<class charT, class traits>
454 basic_ostream<charT, traits>&
455 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
458 // 25.8.13, class year_month // C++20
461 constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
462 constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
464 constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
465 constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
466 constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
467 constexpr months operator-(const year_month& x, const year_month& y) noexcept;
468 constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
469 constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
470 constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
472 template<class charT, class traits>
473 basic_ostream<charT, traits>&
474 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
476 // 25.8.14, class year_month_day class // C++20
479 constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
480 constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
482 constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
483 constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
484 constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
485 constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
486 constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
487 constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
489 template<class charT, class traits>
490 basic_ostream<charT, traits>&
491 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
493 // 25.8.15, class year_month_day_last // C++20
494 class year_month_day_last;
496 constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
497 constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
499 constexpr year_month_day_last
500 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
501 constexpr year_month_day_last
502 operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
503 constexpr year_month_day_last
504 operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
505 constexpr year_month_day_last
506 operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
507 constexpr year_month_day_last
508 operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
509 constexpr year_month_day_last
510 operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
512 template<class charT, class traits>
513 basic_ostream<charT, traits>&
514 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
516 // 25.8.16, class year_month_weekday // C++20
517 class year_month_weekday;
519 constexpr bool operator==(const year_month_weekday& x,
520 const year_month_weekday& y) noexcept;
522 constexpr year_month_weekday
523 operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
524 constexpr year_month_weekday
525 operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
526 constexpr year_month_weekday
527 operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
528 constexpr year_month_weekday
529 operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
530 constexpr year_month_weekday
531 operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
532 constexpr year_month_weekday
533 operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
535 template<class charT, class traits>
536 basic_ostream<charT, traits>&
537 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
539 // 25.8.17, class year_month_weekday_last // C++20
540 class year_month_weekday_last;
542 constexpr bool operator==(const year_month_weekday_last& x,
543 const year_month_weekday_last& y) noexcept;
544 constexpr year_month_weekday_last
545 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
546 constexpr year_month_weekday_last
547 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
548 constexpr year_month_weekday_last
549 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
550 constexpr year_month_weekday_last
551 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
552 constexpr year_month_weekday_last
553 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
554 constexpr year_month_weekday_last
555 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
557 template<class charT, class traits>
558 basic_ostream<charT, traits>&
559 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
561 // 25.8.18, civil calendar conventional syntax operators // C++20
563 operator/(const year& y, const month& m) noexcept;
565 operator/(const year& y, int m) noexcept;
567 operator/(const month& m, const day& d) noexcept;
569 operator/(const month& m, int d) noexcept;
571 operator/(int m, const day& d) noexcept;
573 operator/(const day& d, const month& m) noexcept;
575 operator/(const day& d, int m) noexcept;
576 constexpr month_day_last
577 operator/(const month& m, last_spec) noexcept;
578 constexpr month_day_last
579 operator/(int m, last_spec) noexcept;
580 constexpr month_day_last
581 operator/(last_spec, const month& m) noexcept;
582 constexpr month_day_last
583 operator/(last_spec, int m) noexcept;
584 constexpr month_weekday
585 operator/(const month& m, const weekday_indexed& wdi) noexcept;
586 constexpr month_weekday
587 operator/(int m, const weekday_indexed& wdi) noexcept;
588 constexpr month_weekday
589 operator/(const weekday_indexed& wdi, const month& m) noexcept;
590 constexpr month_weekday
591 operator/(const weekday_indexed& wdi, int m) noexcept;
592 constexpr month_weekday_last
593 operator/(const month& m, const weekday_last& wdl) noexcept;
594 constexpr month_weekday_last
595 operator/(int m, const weekday_last& wdl) noexcept;
596 constexpr month_weekday_last
597 operator/(const weekday_last& wdl, const month& m) noexcept;
598 constexpr month_weekday_last
599 operator/(const weekday_last& wdl, int m) noexcept;
600 constexpr year_month_day
601 operator/(const year_month& ym, const day& d) noexcept;
602 constexpr year_month_day
603 operator/(const year_month& ym, int d) noexcept;
604 constexpr year_month_day
605 operator/(const year& y, const month_day& md) noexcept;
606 constexpr year_month_day
607 operator/(int y, const month_day& md) noexcept;
608 constexpr year_month_day
609 operator/(const month_day& md, const year& y) noexcept;
610 constexpr year_month_day
611 operator/(const month_day& md, int y) noexcept;
612 constexpr year_month_day_last
613 operator/(const year_month& ym, last_spec) noexcept;
614 constexpr year_month_day_last
615 operator/(const year& y, const month_day_last& mdl) noexcept;
616 constexpr year_month_day_last
617 operator/(int y, const month_day_last& mdl) noexcept;
618 constexpr year_month_day_last
619 operator/(const month_day_last& mdl, const year& y) noexcept;
620 constexpr year_month_day_last
621 operator/(const month_day_last& mdl, int y) noexcept;
622 constexpr year_month_weekday
623 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
624 constexpr year_month_weekday
625 operator/(const year& y, const month_weekday& mwd) noexcept;
626 constexpr year_month_weekday
627 operator/(int y, const month_weekday& mwd) noexcept;
628 constexpr year_month_weekday
629 operator/(const month_weekday& mwd, const year& y) noexcept;
630 constexpr year_month_weekday
631 operator/(const month_weekday& mwd, int y) noexcept;
632 constexpr year_month_weekday_last
633 operator/(const year_month& ym, const weekday_last& wdl) noexcept;
634 constexpr year_month_weekday_last
635 operator/(const year& y, const month_weekday_last& mwdl) noexcept;
636 constexpr year_month_weekday_last
637 operator/(int y, const month_weekday_last& mwdl) noexcept;
638 constexpr year_month_weekday_last
639 operator/(const month_weekday_last& mwdl, const year& y) noexcept;
640 constexpr year_month_weekday_last
641 operator/(const month_weekday_last& mwdl, int y) noexcept;
643 // 26.9, class template hh_mm_ss
644 template <class Duration>
647 bool is_neg; // exposition only
648 chrono::hours h; // exposition only
649 chrono::minutes m; // exposition only
650 chrono::seconds s; // exposition only
651 precision ss; // exposition only
654 static unsigned constexpr fractional_width = see below;
655 using precision = see below;
657 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
658 constexpr explicit hh_mm_ss(Duration d) noexcept;
660 constexpr bool is_negative() const noexcept;
661 constexpr chrono::hours hours() const noexcept;
662 constexpr chrono::minutes minutes() const noexcept;
663 constexpr chrono::seconds seconds() const noexcept;
664 constexpr precision subseconds() const noexcept;
666 constexpr explicit operator precision() const noexcept;
667 constexpr precision to_duration() const noexcept;
670 template<class charT, class traits, class Duration>
671 basic_ostream<charT, traits>&
672 operator<<(basic_ostream<charT, traits>& os, const hh_mm_ss<Duration>& hms); // C++20
674 // 26.10, 12/24 hour functions
675 constexpr bool is_am(hours const& h) noexcept;
676 constexpr bool is_pm(hours const& h) noexcept;
677 constexpr hours make12(const hours& h) noexcept;
678 constexpr hours make24(const hours& h, bool is_pm) noexcept;
680 // 25.10.5, class time_zone // C++20
681 enum class choose {earliest, latest};
683 bool operator==(const time_zone& x, const time_zone& y) noexcept;
684 bool operator!=(const time_zone& x, const time_zone& y) noexcept;
685 bool operator<(const time_zone& x, const time_zone& y) noexcept;
686 bool operator>(const time_zone& x, const time_zone& y) noexcept;
687 bool operator<=(const time_zone& x, const time_zone& y) noexcept;
688 bool operator>=(const time_zone& x, const time_zone& y) noexcept;
692 template<class Duration, class charT>
693 struct formatter<chrono::sys_time<Duration>, charT>; // C++20
694 template<class Duration, class charT>
695 struct formatter<chrono::filetime<Duration>, charT>; // C++20
696 template<class Duration, class charT>
697 struct formatter<chrono::local_time<Duration>, charT>; // C++20
698 template<class Rep, class Period, class charT>
699 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
700 template<class charT> struct formatter<chrono::day, charT>; // C++20
701 template<class charT> struct formatter<chrono::month, charT>; // C++20
702 template<class charT> struct formatter<chrono::year, charT>; // C++20
703 template<class charT> struct formatter<chrono::weekday, charT>; // C++20
704 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20
705 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20
706 template<class charT> struct formatter<chrono::month_day, charT>; // C++20
707 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20
708 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20
709 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20
710 template<class charT> struct formatter<chrono::year_month, charT>; // C++20
711 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20
712 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20
713 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20
714 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
715 template<class Rep, class Period, class charT>
716 struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20
720 // calendrical constants
721 inline constexpr last_spec last{}; // C++20
722 inline constexpr chrono::weekday Sunday{0}; // C++20
723 inline constexpr chrono::weekday Monday{1}; // C++20
724 inline constexpr chrono::weekday Tuesday{2}; // C++20
725 inline constexpr chrono::weekday Wednesday{3}; // C++20
726 inline constexpr chrono::weekday Thursday{4}; // C++20
727 inline constexpr chrono::weekday Friday{5}; // C++20
728 inline constexpr chrono::weekday Saturday{6}; // C++20
730 inline constexpr chrono::month January{1}; // C++20
731 inline constexpr chrono::month February{2}; // C++20
732 inline constexpr chrono::month March{3}; // C++20
733 inline constexpr chrono::month April{4}; // C++20
734 inline constexpr chrono::month May{5}; // C++20
735 inline constexpr chrono::month June{6}; // C++20
736 inline constexpr chrono::month July{7}; // C++20
737 inline constexpr chrono::month August{8}; // C++20
738 inline constexpr chrono::month September{9}; // C++20
739 inline constexpr chrono::month October{10}; // C++20
740 inline constexpr chrono::month November{11}; // C++20
741 inline constexpr chrono::month December{12}; // C++20
744 inline namespace literals {
745 inline namespace chrono_literals {
746 constexpr chrono::hours operator ""h(unsigned long long); // C++14
747 constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
748 constexpr chrono::minutes operator ""min(unsigned long long); // C++14
749 constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
750 constexpr chrono::seconds operator ""s(unsigned long long); // C++14
751 constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
752 constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
753 constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
754 constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
755 constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
756 constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
757 constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
758 constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
759 constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
766 #include <__assert> // all public C++ headers provide the assertion handler
767 #include <__chrono/calendar.h>
768 #include <__chrono/convert_to_timespec.h>
769 #include <__chrono/convert_to_tm.h>
770 #include <__chrono/day.h>
771 #include <__chrono/duration.h>
772 #include <__chrono/file_clock.h>
773 #include <__chrono/hh_mm_ss.h>
774 #include <__chrono/high_resolution_clock.h>
775 #include <__chrono/literals.h>
776 #include <__chrono/month.h>
777 #include <__chrono/month_weekday.h>
778 #include <__chrono/monthday.h>
779 #include <__chrono/steady_clock.h>
780 #include <__chrono/system_clock.h>
781 #include <__chrono/time_point.h>
782 #include <__chrono/weekday.h>
783 #include <__chrono/year.h>
784 #include <__chrono/year_month.h>
785 #include <__chrono/year_month_day.h>
786 #include <__chrono/year_month_weekday.h>
790 // standard-mandated includes
795 #if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && _LIBCPP_STD_VER >= 20
796 # include <__chrono/formatter.h>
797 # include <__chrono/ostream.h>
798 # include <__chrono/parser_std_format_spec.h>
799 # include <__chrono/statically_widen.h>
803 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
804 # pragma GCC system_header
807 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
813 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
817 #endif // _LIBCPP_CHRONO