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
18 #include <compare> // C++20
25 template <class ToDuration, class Rep, class Period>
28 duration_cast(const duration<Rep, Period>& fd);
30 template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {};
32 template <class Rep> inline constexpr bool treat_as_floating_point_v
33 = treat_as_floating_point<Rep>::value; // C++17
36 struct duration_values
39 static constexpr Rep zero(); // noexcept in C++20
40 static constexpr Rep max(); // noexcept in C++20
41 static constexpr Rep min(); // noexcept in C++20
46 template <class Rep, class Period = ratio<1>>
49 static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration");
50 static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio");
51 static_assert(Period::num > 0, "duration period must be positive");
54 typedef typename _Period::type period;
56 constexpr duration() = default;
58 constexpr explicit duration(const Rep2& r,
61 is_convertible<const Rep2&, rep>::value &&
62 (treat_as_floating_point<rep>::value ||
63 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value)
67 template <class Rep2, class Period2>
68 constexpr duration(const duration<Rep2, Period2>& d,
71 treat_as_floating_point<rep>::value ||
72 ratio_divide<Period2, period>::type::den == 1
77 constexpr rep count() const;
81 constexpr common_type<duration>::type operator+() const;
82 constexpr common_type<duration>::type operator-() const;
83 constexpr duration& operator++(); // constexpr in C++17
84 constexpr duration operator++(int); // constexpr in C++17
85 constexpr duration& operator--(); // constexpr in C++17
86 constexpr duration operator--(int); // constexpr in C++17
88 constexpr duration& operator+=(const duration& d); // constexpr in C++17
89 constexpr duration& operator-=(const duration& d); // constexpr in C++17
91 duration& operator*=(const rep& rhs); // constexpr in C++17
92 duration& operator/=(const rep& rhs); // constexpr in C++17
93 duration& operator%=(const rep& rhs); // constexpr in C++17
94 duration& operator%=(const duration& rhs); // constexpr in C++17
98 static constexpr duration zero(); // noexcept in C++20
99 static constexpr duration min(); // noexcept in C++20
100 static constexpr duration max(); // noexcept in C++20
103 typedef duration<long long, nano> nanoseconds;
104 typedef duration<long long, micro> microseconds;
105 typedef duration<long long, milli> milliseconds;
106 typedef duration<long long > seconds;
107 typedef duration< long, ratio< 60> > minutes;
108 typedef duration< long, ratio<3600> > hours;
110 template <class Clock, class Duration = typename Clock::duration>
115 typedef Duration duration;
116 typedef typename duration::rep rep;
117 typedef typename duration::period period;
119 duration d_; // exposition only
122 time_point(); // has value "epoch" // constexpr in C++14
123 explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14
126 template <class Duration2>
127 time_point(const time_point<clock, Duration2>& t); // constexpr in C++14
131 duration time_since_epoch() const; // constexpr in C++14
135 time_point& operator+=(const duration& d); // constexpr in C++17
136 time_point& operator-=(const duration& d); // constexpr in C++17
140 static constexpr time_point min(); // noexcept in C++20
141 static constexpr time_point max(); // noexcept in C++20
146 // common_type traits
147 template <class Rep1, class Period1, class Rep2, class Period2>
148 struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>;
150 template <class Clock, class Duration1, class Duration2>
151 struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>;
155 // duration arithmetic
156 template <class Rep1, class Period1, class Rep2, class Period2>
158 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
159 operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
160 template <class Rep1, class Period1, class Rep2, class Period2>
162 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
163 operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
164 template <class Rep1, class Period, class Rep2>
166 duration<typename common_type<Rep1, Rep2>::type, Period>
167 operator*(const duration<Rep1, Period>& d, const Rep2& s);
168 template <class Rep1, class Period, class Rep2>
170 duration<typename common_type<Rep1, Rep2>::type, Period>
171 operator*(const Rep1& s, const duration<Rep2, Period>& d);
172 template <class Rep1, class Period, class Rep2>
174 duration<typename common_type<Rep1, Rep2>::type, Period>
175 operator/(const duration<Rep1, Period>& d, const Rep2& s);
176 template <class Rep1, class Period1, class Rep2, class Period2>
178 typename common_type<Rep1, Rep2>::type
179 operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
181 // duration comparisons
182 template <class Rep1, class Period1, class Rep2, class Period2>
184 bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
185 template <class Rep1, class Period1, class Rep2, class Period2>
187 bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // removed in C++20
188 template <class Rep1, class Period1, class Rep2, class Period2>
190 bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
191 template <class Rep1, class Period1, class Rep2, class Period2>
193 bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
194 template <class Rep1, class Period1, class Rep2, class Period2>
196 bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
197 template <class Rep1, class Period1, class Rep2, class Period2>
199 bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
200 template<class Rep1, class Period1, class Rep2, class Period2>
201 requires three_way_comparable<typename CT::rep>
202 constexpr auto operator<=>(const duration<Rep1, Period1>& lhs,
203 const duration<Rep2, Period2>& rhs); // since C++20
206 template <class ToDuration, class Rep, class Period>
207 ToDuration duration_cast(const duration<Rep, Period>& d);
209 template <class ToDuration, class Rep, class Period>
210 constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17
211 template <class ToDuration, class Rep, class Period>
212 constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17
213 template <class ToDuration, class Rep, class Period>
214 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17
217 template<class charT, class traits, class Rep, class Period> // C++20
218 basic_ostream<charT, traits>&
219 operator<<(basic_ostream<charT, traits>& os,
220 const duration<Rep, Period>& d);
222 // time_point arithmetic (all constexpr in C++14)
223 template <class Clock, class Duration1, class Rep2, class Period2>
224 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
225 operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
226 template <class Rep1, class Period1, class Clock, class Duration2>
227 time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type>
228 operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs);
229 template <class Clock, class Duration1, class Rep2, class Period2>
230 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type>
231 operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs);
232 template <class Clock, class Duration1, class Duration2>
233 typename common_type<Duration1, Duration2>::type
234 operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
236 // time_point comparisons (all constexpr in C++14)
237 template <class Clock, class Duration1, class Duration2>
238 bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
239 template <class Clock, class Duration1, class Duration2>
240 bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); // removed in C++20
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, class Duration2>
248 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs);
249 template<class Clock, class Duration1,
250 three_way_comparable_with<Duration1> Duration2>
251 constexpr auto operator<=>(const time_point<Clock, Duration1>& lhs,
252 const time_point<Clock, Duration2>& rhs); // since C++20
254 // time_point_cast (constexpr in C++14)
256 template <class ToDuration, class Clock, class Duration>
257 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t);
259 template <class ToDuration, class Clock, class Duration>
260 constexpr time_point<Clock, ToDuration>
261 floor(const time_point<Clock, Duration>& tp); // C++17
263 template <class ToDuration, class Clock, class Duration>
264 constexpr time_point<Clock, ToDuration>
265 ceil(const time_point<Clock, Duration>& tp); // C++17
267 template <class ToDuration, class Clock, class Duration>
268 constexpr time_point<Clock, ToDuration>
269 round(const time_point<Clock, Duration>& tp); // C++17
271 template <class Rep, class Period>
272 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17
279 typedef microseconds duration;
280 typedef duration::rep rep;
281 typedef duration::period period;
282 typedef chrono::time_point<system_clock> time_point;
283 static const bool is_steady = false; // constexpr in C++14
285 static time_point now() noexcept;
286 static time_t to_time_t (const time_point& __t) noexcept;
287 static time_point from_time_t(time_t __t) noexcept;
290 template <class Duration>
291 using sys_time = time_point<system_clock, Duration>; // C++20
292 using sys_seconds = sys_time<seconds>; // C++20
293 using sys_days = sys_time<days>; // C++20
295 template<class charT, class traits, class Duration> // C++20
296 basic_ostream<charT, traits>&
297 operator<<(basic_ostream<charT, traits>& os, const sys_time<Duration>& tp);
299 template<class charT, class traits> // C++20
300 basic_ostream<charT, traits>&
301 operator<<(basic_ostream<charT, traits>& os, const sys_days& dp);
303 class file_clock // C++20
306 typedef see-below rep;
308 typedef chrono::duration<rep, period> duration;
309 typedef chrono::time_point<file_clock> time_point;
310 static constexpr bool is_steady = false;
312 static time_point now() noexcept;
314 template<class Duration>
315 static sys_time<see-below> to_sys(const file_time<Duration>&);
317 template<class Duration>
318 static file_time<see-below> from_sys(const sys_time<Duration>&);
321 template<class Duration>
322 using file_time = time_point<file_clock, Duration>; // C++20
324 template<class charT, class traits, class Duration> // C++20
325 basic_ostream<charT, traits>&
326 operator<<(basic_ostream<charT, traits>& os, const file_time<Duration>& tp);
331 typedef nanoseconds duration;
332 typedef duration::rep rep;
333 typedef duration::period period;
334 typedef chrono::time_point<steady_clock, duration> time_point;
335 static const bool is_steady = true; // constexpr in C++14
337 static time_point now() noexcept;
340 typedef steady_clock high_resolution_clock;
342 // 25.7.8, local time // C++20
344 template<class Duration>
345 using local_time = time_point<local_t, Duration>;
346 using local_seconds = local_time<seconds>;
347 using local_days = local_time<days>;
349 template<class charT, class traits, class Duration> // C++20
350 basic_ostream<charT, traits>&
351 operator<<(basic_ostream<charT, traits>& os, const local_time<Duration>& tp);
353 // 25.8.2, class last_spec // C++20
356 // 25.8.3, class day // C++20
359 constexpr bool operator==(const day& x, const day& y) noexcept;
360 constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept;
361 constexpr day operator+(const day& x, const days& y) noexcept;
362 constexpr day operator+(const days& x, const day& y) noexcept;
363 constexpr day operator-(const day& x, const days& y) noexcept;
364 constexpr days operator-(const day& x, const day& y) noexcept;
365 template<class charT, class traits>
366 basic_ostream<charT, traits>&
367 operator<<(basic_ostream<charT, traits>& os, const day& d);
369 // 25.8.4, class month // C++20
371 constexpr bool operator==(const month& x, const month& y) noexcept;
372 constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept;
374 constexpr month operator+(const month& x, const months& y) noexcept;
375 constexpr month operator+(const months& x, const month& y) noexcept;
376 constexpr month operator-(const month& x, const months& y) noexcept;
377 constexpr months operator-(const month& x, const month& y) noexcept;
378 template<class charT, class traits>
379 basic_ostream<charT, traits>&
380 operator<<(basic_ostream<charT, traits>& os, const month& m);
382 // 25.8.5, class year // C++20
384 constexpr bool operator==(const year& x, const year& y) noexcept;
385 constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept;
387 constexpr year operator+(const year& x, const years& y) noexcept;
388 constexpr year operator+(const years& x, const year& y) noexcept;
389 constexpr year operator-(const year& x, const years& y) noexcept;
390 constexpr years operator-(const year& x, const year& y) noexcept;
391 template<class charT, class traits>
392 basic_ostream<charT, traits>&
393 operator<<(basic_ostream<charT, traits>& os, const year& y);
395 // 25.8.6, class weekday // C++20
398 constexpr bool operator==(const weekday& x, const weekday& y) noexcept;
399 constexpr weekday operator+(const weekday& x, const days& y) noexcept;
400 constexpr weekday operator+(const days& x, const weekday& y) noexcept;
401 constexpr weekday operator-(const weekday& x, const days& y) noexcept;
402 constexpr days operator-(const weekday& x, const weekday& y) noexcept;
403 template<class charT, class traits>
404 basic_ostream<charT, traits>&
405 operator<<(basic_ostream<charT, traits>& os, const weekday& wd);
407 // 25.8.7, class weekday_indexed // C++20
409 class weekday_indexed;
410 constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept;
412 template<class charT, class traits>
413 basic_ostream<charT, traits>&
414 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi);
416 // 25.8.8, class weekday_last // C++20
419 constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept;
421 template<class charT, class traits>
422 basic_ostream<charT, traits>&
423 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl);
425 // 25.8.9, class month_day // C++20
428 constexpr bool operator==(const month_day& x, const month_day& y) noexcept;
429 constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept;
431 template<class charT, class traits>
432 basic_ostream<charT, traits>&
433 operator<<(basic_ostream<charT, traits>& os, const month_day& md);
435 // 25.8.10, class month_day_last // C++20
436 class month_day_last;
438 constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept;
439 constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept;
441 template<class charT, class traits>
442 basic_ostream<charT, traits>&
443 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl);
445 // 25.8.11, class month_weekday // C++20
448 constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept;
450 template<class charT, class traits>
451 basic_ostream<charT, traits>&
452 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd);
454 // 25.8.12, class month_weekday_last // C++20
455 class month_weekday_last;
457 constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept;
459 template<class charT, class traits>
460 basic_ostream<charT, traits>&
461 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl);
464 // 25.8.13, class year_month // C++20
467 constexpr bool operator==(const year_month& x, const year_month& y) noexcept;
468 constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept;
470 constexpr year_month operator+(const year_month& ym, const months& dm) noexcept;
471 constexpr year_month operator+(const months& dm, const year_month& ym) noexcept;
472 constexpr year_month operator-(const year_month& ym, const months& dm) noexcept;
473 constexpr months operator-(const year_month& x, const year_month& y) noexcept;
474 constexpr year_month operator+(const year_month& ym, const years& dy) noexcept;
475 constexpr year_month operator+(const years& dy, const year_month& ym) noexcept;
476 constexpr year_month operator-(const year_month& ym, const years& dy) noexcept;
478 template<class charT, class traits>
479 basic_ostream<charT, traits>&
480 operator<<(basic_ostream<charT, traits>& os, const year_month& ym);
482 // 25.8.14, class year_month_day class // C++20
485 constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept;
486 constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept;
488 constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept;
489 constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept;
490 constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept;
491 constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept;
492 constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept;
493 constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept;
495 template<class charT, class traits>
496 basic_ostream<charT, traits>&
497 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd);
499 // 25.8.15, class year_month_day_last // C++20
500 class year_month_day_last;
502 constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept;
503 constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept;
505 constexpr year_month_day_last
506 operator+(const year_month_day_last& ymdl, const months& dm) noexcept;
507 constexpr year_month_day_last
508 operator+(const months& dm, const year_month_day_last& ymdl) noexcept;
509 constexpr year_month_day_last
510 operator+(const year_month_day_last& ymdl, const years& dy) noexcept;
511 constexpr year_month_day_last
512 operator+(const years& dy, const year_month_day_last& ymdl) noexcept;
513 constexpr year_month_day_last
514 operator-(const year_month_day_last& ymdl, const months& dm) noexcept;
515 constexpr year_month_day_last
516 operator-(const year_month_day_last& ymdl, const years& dy) noexcept;
518 template<class charT, class traits>
519 basic_ostream<charT, traits>&
520 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl);
522 // 25.8.16, class year_month_weekday // C++20
523 class year_month_weekday;
525 constexpr bool operator==(const year_month_weekday& x,
526 const year_month_weekday& y) noexcept;
528 constexpr year_month_weekday
529 operator+(const year_month_weekday& ymwd, const months& dm) noexcept;
530 constexpr year_month_weekday
531 operator+(const months& dm, const year_month_weekday& ymwd) noexcept;
532 constexpr year_month_weekday
533 operator+(const year_month_weekday& ymwd, const years& dy) noexcept;
534 constexpr year_month_weekday
535 operator+(const years& dy, const year_month_weekday& ymwd) noexcept;
536 constexpr year_month_weekday
537 operator-(const year_month_weekday& ymwd, const months& dm) noexcept;
538 constexpr year_month_weekday
539 operator-(const year_month_weekday& ymwd, const years& dy) noexcept;
541 template<class charT, class traits>
542 basic_ostream<charT, traits>&
543 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd);
545 // 25.8.17, class year_month_weekday_last // C++20
546 class year_month_weekday_last;
548 constexpr bool operator==(const year_month_weekday_last& x,
549 const year_month_weekday_last& y) noexcept;
550 constexpr year_month_weekday_last
551 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
552 constexpr year_month_weekday_last
553 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept;
554 constexpr year_month_weekday_last
555 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
556 constexpr year_month_weekday_last
557 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept;
558 constexpr year_month_weekday_last
559 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept;
560 constexpr year_month_weekday_last
561 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept;
563 template<class charT, class traits>
564 basic_ostream<charT, traits>&
565 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl);
567 // 25.8.18, civil calendar conventional syntax operators // C++20
569 operator/(const year& y, const month& m) noexcept;
571 operator/(const year& y, int m) noexcept;
573 operator/(const month& m, const day& d) noexcept;
575 operator/(const month& m, int d) noexcept;
577 operator/(int m, const day& d) noexcept;
579 operator/(const day& d, const month& m) noexcept;
581 operator/(const day& d, int m) noexcept;
582 constexpr month_day_last
583 operator/(const month& m, last_spec) noexcept;
584 constexpr month_day_last
585 operator/(int m, last_spec) noexcept;
586 constexpr month_day_last
587 operator/(last_spec, const month& m) noexcept;
588 constexpr month_day_last
589 operator/(last_spec, int m) noexcept;
590 constexpr month_weekday
591 operator/(const month& m, const weekday_indexed& wdi) noexcept;
592 constexpr month_weekday
593 operator/(int m, const weekday_indexed& wdi) noexcept;
594 constexpr month_weekday
595 operator/(const weekday_indexed& wdi, const month& m) noexcept;
596 constexpr month_weekday
597 operator/(const weekday_indexed& wdi, int m) noexcept;
598 constexpr month_weekday_last
599 operator/(const month& m, const weekday_last& wdl) noexcept;
600 constexpr month_weekday_last
601 operator/(int m, const weekday_last& wdl) noexcept;
602 constexpr month_weekday_last
603 operator/(const weekday_last& wdl, const month& m) noexcept;
604 constexpr month_weekday_last
605 operator/(const weekday_last& wdl, int m) noexcept;
606 constexpr year_month_day
607 operator/(const year_month& ym, const day& d) noexcept;
608 constexpr year_month_day
609 operator/(const year_month& ym, int d) noexcept;
610 constexpr year_month_day
611 operator/(const year& y, const month_day& md) noexcept;
612 constexpr year_month_day
613 operator/(int y, const month_day& md) noexcept;
614 constexpr year_month_day
615 operator/(const month_day& md, const year& y) noexcept;
616 constexpr year_month_day
617 operator/(const month_day& md, int y) noexcept;
618 constexpr year_month_day_last
619 operator/(const year_month& ym, last_spec) noexcept;
620 constexpr year_month_day_last
621 operator/(const year& y, const month_day_last& mdl) noexcept;
622 constexpr year_month_day_last
623 operator/(int y, const month_day_last& mdl) noexcept;
624 constexpr year_month_day_last
625 operator/(const month_day_last& mdl, const year& y) noexcept;
626 constexpr year_month_day_last
627 operator/(const month_day_last& mdl, int y) noexcept;
628 constexpr year_month_weekday
629 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept;
630 constexpr year_month_weekday
631 operator/(const year& y, const month_weekday& mwd) noexcept;
632 constexpr year_month_weekday
633 operator/(int y, const month_weekday& mwd) noexcept;
634 constexpr year_month_weekday
635 operator/(const month_weekday& mwd, const year& y) noexcept;
636 constexpr year_month_weekday
637 operator/(const month_weekday& mwd, int y) noexcept;
638 constexpr year_month_weekday_last
639 operator/(const year_month& ym, const weekday_last& wdl) noexcept;
640 constexpr year_month_weekday_last
641 operator/(const year& y, const month_weekday_last& mwdl) noexcept;
642 constexpr year_month_weekday_last
643 operator/(int y, const month_weekday_last& mwdl) noexcept;
644 constexpr year_month_weekday_last
645 operator/(const month_weekday_last& mwdl, const year& y) noexcept;
646 constexpr year_month_weekday_last
647 operator/(const month_weekday_last& mwdl, int y) noexcept;
649 // 26.9, class template hh_mm_ss
650 template <class Duration>
653 bool is_neg; // exposition only
654 chrono::hours h; // exposition only
655 chrono::minutes m; // exposition only
656 chrono::seconds s; // exposition only
657 precision ss; // exposition only
660 static unsigned constexpr fractional_width = see below;
661 using precision = see below;
663 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {}
664 constexpr explicit hh_mm_ss(Duration d) noexcept;
666 constexpr bool is_negative() const noexcept;
667 constexpr chrono::hours hours() const noexcept;
668 constexpr chrono::minutes minutes() const noexcept;
669 constexpr chrono::seconds seconds() const noexcept;
670 constexpr precision subseconds() const noexcept;
672 constexpr explicit operator precision() const noexcept;
673 constexpr precision to_duration() const noexcept;
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); // C++20
680 // 26.10, 12/24 hour functions
681 constexpr bool is_am(hours const& h) noexcept;
682 constexpr bool is_pm(hours const& h) noexcept;
683 constexpr hours make12(const hours& h) noexcept;
684 constexpr hours make24(const hours& h, bool is_pm) noexcept;
686 // [time.zone.db], time zone database
687 struct tzdb { // C++20
689 vector<time_zone> zones;
690 vector<time_zone_link> links;
691 vector<leap_second> leap_seconds;
693 const time_zone* locate_zone(string_view tz_name) const;
694 const time_zone* current_zone() const;
697 class tzdb_list { // C++20
699 tzdb_list(const tzdb_list&) = delete;
700 tzdb_list& operator=(const tzdb_list&) = delete;
702 // unspecified additional constructors
704 class const_iterator;
706 const tzdb& front() const noexcept;
708 const_iterator erase_after(const_iterator p);
710 const_iterator begin() const noexcept;
711 const_iterator end() const noexcept;
713 const_iterator cbegin() const noexcept;
714 const_iterator cend() const noexcept;
717 // [time.zone.db.access], time zone database access
718 const tzdb& get_tzdb(); // C++20
719 tzdb_list& get_tzdb_list(); // C++20
720 const time_zone* locate_zone(string_view tz_name); // C++20
721 const time_zone* current_zone() // C++20
723 // [time.zone.db.remote], remote time zone database support
724 const tzdb& reload_tzdb(); // C++20
725 string remote_version(); // C++20
727 // [time.zone.exception], exception classes
728 class nonexistent_local_time; // C++20
729 class ambiguous_local_time; // C++20
731 // [time.zone.info], information classes
732 struct sys_info { // C++20
740 template<class charT, class traits> // C++20
741 basic_ostream<charT, traits>&
742 operator<<(basic_ostream<charT, traits>& os, const sys_info& si);
744 struct local_info { // C++20
745 static constexpr int unique = 0;
746 static constexpr int nonexistent = 1;
747 static constexpr int ambiguous = 2;
754 template<class charT, class traits> // C++20
755 basic_ostream<charT, traits>&
756 operator<<(basic_ostream<charT, traits>& os, const local_info& li);
758 // 25.10.5, class time_zone // C++20
759 enum class choose {earliest, latest};
761 time_zone(time_zone&&) = default;
762 time_zone& operator=(time_zone&&) = default;
764 // unspecified additional constructors
766 string_view name() const noexcept;
768 template<class Duration>
769 sys_info get_info(const sys_time<Duration>& st) const;
771 template<class Duration>
772 local_info get_info(const local_time<Duration>& tp) const;
774 template<class Duration>
775 sys_time<common_type_t<Duration, seconds>>
776 to_sys(const local_time<Duration>& tp) const;
778 template<class Duration>
779 sys_time<common_type_t<Duration, seconds>>
780 to_sys(const local_time<Duration>& tp, choose z) const;
782 template<class Duration>
783 local_time<common_type_t<Duration, seconds>>
784 to_local(const sys_time<Duration>& tp) const;
786 bool operator==(const time_zone& x, const time_zone& y) noexcept; // C++20
787 strong_ordering operator<=>(const time_zone& x, const time_zone& y) noexcept; // C++20
789 // [time.zone.zonedtraits], class template zoned_traits
790 template<class T> struct zoned_traits; // C++20
792 // [time.zone.zonedtime], class template zoned_time
793 template<class Duration, class TimeZonePtr = const time_zone*> // C++20
796 using zoned_seconds = zoned_time<seconds>; // C++20
798 template<class Duration1, class Duration2, class TimeZonePtr> // C++20
799 bool operator==(const zoned_time<Duration1, TimeZonePtr>& x,
800 const zoned_time<Duration2, TimeZonePtr>& y);
802 template<class charT, class traits, class Duration, class TimeZonePtr> // C++20
803 basic_ostream<charT, traits>&
804 operator<<(basic_ostream<charT, traits>& os,
805 const zoned_time<Duration, TimeZonePtr>& t);
807 // [time.zone.leap], leap second support
808 class leap_second { // C++20
810 leap_second(const leap_second&) = default;
811 leap_second& operator=(const leap_second&) = default;
813 // unspecified additional constructors
815 constexpr sys_seconds date() const noexcept;
816 constexpr seconds value() const noexcept;
819 constexpr bool operator==(const leap_second& x, const leap_second& y); // C++20
820 constexpr strong_ordering operator<=>(const leap_second& x, const leap_second& y);
822 template<class Duration> // C++20
823 constexpr bool operator==(const leap_second& x, const sys_time<Duration>& y);
824 template<class Duration> // C++20
825 constexpr bool operator< (const leap_second& x, const sys_time<Duration>& y);
826 template<class Duration> // C++20
827 constexpr bool operator< (const sys_time<Duration>& x, const leap_second& y);
828 template<class Duration> // C++20
829 constexpr bool operator> (const leap_second& x, const sys_time<Duration>& y);
830 template<class Duration> // C++20
831 constexpr bool operator> (const sys_time<Duration>& x, const leap_second& y);
832 template<class Duration> // C++20
833 constexpr bool operator<=(const leap_second& x, const sys_time<Duration>& y);
834 template<class Duration> // C++20
835 constexpr bool operator<=(const sys_time<Duration>& x, const leap_second& y);
836 template<class Duration> // C++20
837 constexpr bool operator>=(const leap_second& x, const sys_time<Duration>& y);
838 template<class Duration> // C++20
839 constexpr bool operator>=(const sys_time<Duration>& x, const leap_second& y);
840 template<class Duration> // C++20
841 requires three_way_comparable_with<sys_seconds, sys_time<Duration>>
842 constexpr auto operator<=>(const leap_second& x, const sys_time<Duration>& y);
844 // [time.zone.link], class time_zone_link
845 class time_zone_link { // C++20
847 time_zone_link(time_zone_link&&) = default;
848 time_zone_link& operator=(time_zone_link&&) = default;
850 // unspecified additional constructors
852 string_view name() const noexcept;
853 string_view target() const noexcept;
856 bool operator==(const time_zone_link& x, const time_zone_link& y); // C++20
857 strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y); // C++20
862 template<class Duration, class charT>
863 struct formatter<chrono::sys_time<Duration>, charT>; // C++20
864 template<class Duration, class charT>
865 struct formatter<chrono::filetime<Duration>, charT>; // C++20
866 template<class Duration, class charT>
867 struct formatter<chrono::local_time<Duration>, charT>; // C++20
868 template<class Rep, class Period, class charT>
869 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
870 template<class charT> struct formatter<chrono::day, charT>; // C++20
871 template<class charT> struct formatter<chrono::month, charT>; // C++20
872 template<class charT> struct formatter<chrono::year, charT>; // C++20
873 template<class charT> struct formatter<chrono::weekday, charT>; // C++20
874 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20
875 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20
876 template<class charT> struct formatter<chrono::month_day, charT>; // C++20
877 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20
878 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20
879 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20
880 template<class charT> struct formatter<chrono::year_month, charT>; // C++20
881 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20
882 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20
883 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20
884 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20
885 template<class Rep, class Period, class charT>
886 struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20
887 template<class charT> struct formatter<chrono::sys_info, charT>; // C++20
888 template<class charT> struct formatter<chrono::local_info, charT>; // C++20
889 template<class Duration, class TimeZonePtr, class charT> // C++20
890 struct formatter<chrono::zoned_time<Duration, TimeZonePtr>, charT>;
894 // calendrical constants
895 inline constexpr last_spec last{}; // C++20
896 inline constexpr chrono::weekday Sunday{0}; // C++20
897 inline constexpr chrono::weekday Monday{1}; // C++20
898 inline constexpr chrono::weekday Tuesday{2}; // C++20
899 inline constexpr chrono::weekday Wednesday{3}; // C++20
900 inline constexpr chrono::weekday Thursday{4}; // C++20
901 inline constexpr chrono::weekday Friday{5}; // C++20
902 inline constexpr chrono::weekday Saturday{6}; // C++20
904 inline constexpr chrono::month January{1}; // C++20
905 inline constexpr chrono::month February{2}; // C++20
906 inline constexpr chrono::month March{3}; // C++20
907 inline constexpr chrono::month April{4}; // C++20
908 inline constexpr chrono::month May{5}; // C++20
909 inline constexpr chrono::month June{6}; // C++20
910 inline constexpr chrono::month July{7}; // C++20
911 inline constexpr chrono::month August{8}; // C++20
912 inline constexpr chrono::month September{9}; // C++20
913 inline constexpr chrono::month October{10}; // C++20
914 inline constexpr chrono::month November{11}; // C++20
915 inline constexpr chrono::month December{12}; // C++20
918 inline namespace literals {
919 inline namespace chrono_literals {
920 constexpr chrono::hours operator ""h(unsigned long long); // C++14
921 constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14
922 constexpr chrono::minutes operator ""min(unsigned long long); // C++14
923 constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14
924 constexpr chrono::seconds operator ""s(unsigned long long); // C++14
925 constexpr chrono::duration<unspecified > operator ""s(long double); // C++14
926 constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14
927 constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14
928 constexpr chrono::microseconds operator ""us(unsigned long long); // C++14
929 constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14
930 constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14
931 constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14
932 constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20
933 constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20
944 #include <__chrono/duration.h>
945 #include <__chrono/file_clock.h>
946 #include <__chrono/high_resolution_clock.h>
947 #include <__chrono/steady_clock.h>
948 #include <__chrono/system_clock.h>
949 #include <__chrono/time_point.h>
951 #if _LIBCPP_STD_VER >= 20
952 # include <__chrono/calendar.h>
953 # include <__chrono/day.h>
954 # include <__chrono/exception.h>
955 # include <__chrono/hh_mm_ss.h>
956 # include <__chrono/literals.h>
957 # include <__chrono/local_info.h>
958 # include <__chrono/month.h>
959 # include <__chrono/month_weekday.h>
960 # include <__chrono/monthday.h>
961 # include <__chrono/sys_info.h>
962 # include <__chrono/weekday.h>
963 # include <__chrono/year.h>
964 # include <__chrono/year_month.h>
965 # include <__chrono/year_month_day.h>
966 # include <__chrono/year_month_weekday.h>
968 # if _LIBCPP_HAS_LOCALIZATION
969 # include <__chrono/formatter.h>
970 # include <__chrono/ostream.h>
971 # include <__chrono/parser_std_format_spec.h>
972 # include <__chrono/statically_widen.h>
975 # if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
976 # include <__chrono/leap_second.h>
977 # include <__chrono/time_zone.h>
978 # include <__chrono/time_zone_link.h>
979 # include <__chrono/tzdb.h>
980 # include <__chrono/tzdb_list.h>
981 # include <__chrono/zoned_time.h>
988 // standard-mandated includes
993 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
994 # pragma GCC system_header
997 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17
999 # include <stdexcept>
1000 # include <string_view>
1004 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
1006 # include <concepts>
1008 # include <forward_list>
1014 #if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20
1015 # include <charconv>
1016 # if _LIBCPP_HAS_LOCALIZATION
1022 #endif // _LIBCPP_CHRONO