1// -*- C++ -*- 2//===----------------------------------------------------------------------===// 3// 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 7// 8//===----------------------------------------------------------------------===// 9 10#ifndef _LIBCPP_CHRONO 11#define _LIBCPP_CHRONO 12 13/* 14 chrono synopsis 15 16namespace std 17{ 18namespace chrono 19{ 20 21template <class ToDuration, class Rep, class Period> 22constexpr 23ToDuration 24duration_cast(const duration<Rep, Period>& fd); 25 26template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {}; 27 28template <class Rep> inline constexpr bool treat_as_floating_point_v 29 = treat_as_floating_point<Rep>::value; // C++17 30 31template <class Rep> 32struct duration_values 33{ 34public: 35 static constexpr Rep zero(); // noexcept in C++20 36 static constexpr Rep max(); // noexcept in C++20 37 static constexpr Rep min(); // noexcept in C++20 38}; 39 40// duration 41 42template <class Rep, class Period = ratio<1>> 43class duration 44{ 45 static_assert(!__is_duration<Rep>::value, "A duration representation can not be a duration"); 46 static_assert(__is_ratio<Period>::value, "Second template parameter of duration must be a std::ratio"); 47 static_assert(Period::num > 0, "duration period must be positive"); 48public: 49 typedef Rep rep; 50 typedef typename _Period::type period; 51 52 constexpr duration() = default; 53 template <class Rep2> 54 constexpr explicit duration(const Rep2& r, 55 typename enable_if 56 < 57 is_convertible<Rep2, rep>::value && 58 (treat_as_floating_point<rep>::value || 59 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) 60 >::type* = 0); 61 62 // conversions 63 template <class Rep2, class Period2> 64 constexpr duration(const duration<Rep2, Period2>& d, 65 typename enable_if 66 < 67 treat_as_floating_point<rep>::value || 68 ratio_divide<Period2, period>::type::den == 1 69 >::type* = 0); 70 71 // observer 72 73 constexpr rep count() const; 74 75 // arithmetic 76 77 constexpr common_type<duration>::type operator+() const; 78 constexpr common_type<duration>::type operator-() const; 79 constexpr duration& operator++(); // constexpr in C++17 80 constexpr duration operator++(int); // constexpr in C++17 81 constexpr duration& operator--(); // constexpr in C++17 82 constexpr duration operator--(int); // constexpr in C++17 83 84 constexpr duration& operator+=(const duration& d); // constexpr in C++17 85 constexpr duration& operator-=(const duration& d); // constexpr in C++17 86 87 duration& operator*=(const rep& rhs); // constexpr in C++17 88 duration& operator/=(const rep& rhs); // constexpr in C++17 89 duration& operator%=(const rep& rhs); // constexpr in C++17 90 duration& operator%=(const duration& rhs); // constexpr in C++17 91 92 // special values 93 94 static constexpr duration zero(); // noexcept in C++20 95 static constexpr duration min(); // noexcept in C++20 96 static constexpr duration max(); // noexcept in C++20 97}; 98 99typedef duration<long long, nano> nanoseconds; 100typedef duration<long long, micro> microseconds; 101typedef duration<long long, milli> milliseconds; 102typedef duration<long long > seconds; 103typedef duration< long, ratio< 60> > minutes; 104typedef duration< long, ratio<3600> > hours; 105 106template <class Clock, class Duration = typename Clock::duration> 107class time_point 108{ 109public: 110 typedef Clock clock; 111 typedef Duration duration; 112 typedef typename duration::rep rep; 113 typedef typename duration::period period; 114private: 115 duration d_; // exposition only 116 117public: 118 time_point(); // has value "epoch" // constexpr in C++14 119 explicit time_point(const duration& d); // same as time_point() + d // constexpr in C++14 120 121 // conversions 122 template <class Duration2> 123 time_point(const time_point<clock, Duration2>& t); // constexpr in C++14 124 125 // observer 126 127 duration time_since_epoch() const; // constexpr in C++14 128 129 // arithmetic 130 131 time_point& operator+=(const duration& d); // constexpr in C++17 132 time_point& operator-=(const duration& d); // constexpr in C++17 133 134 // special values 135 136 static constexpr time_point min(); // noexcept in C++20 137 static constexpr time_point max(); // noexcept in C++20 138}; 139 140} // chrono 141 142// common_type traits 143template <class Rep1, class Period1, class Rep2, class Period2> 144 struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>; 145 146template <class Clock, class Duration1, class Duration2> 147 struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>; 148 149namespace chrono { 150 151// duration arithmetic 152template <class Rep1, class Period1, class Rep2, class Period2> 153 constexpr 154 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type 155 operator+(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 156template <class Rep1, class Period1, class Rep2, class Period2> 157 constexpr 158 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type 159 operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 160template <class Rep1, class Period, class Rep2> 161 constexpr 162 duration<typename common_type<Rep1, Rep2>::type, Period> 163 operator*(const duration<Rep1, Period>& d, const Rep2& s); 164template <class Rep1, class Period, class Rep2> 165 constexpr 166 duration<typename common_type<Rep1, Rep2>::type, Period> 167 operator*(const Rep1& s, const duration<Rep2, Period>& d); 168template <class Rep1, class Period, class Rep2> 169 constexpr 170 duration<typename common_type<Rep1, Rep2>::type, Period> 171 operator/(const duration<Rep1, Period>& d, const Rep2& s); 172template <class Rep1, class Period1, class Rep2, class Period2> 173 constexpr 174 typename common_type<Rep1, Rep2>::type 175 operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 176 177// duration comparisons 178template <class Rep1, class Period1, class Rep2, class Period2> 179 constexpr 180 bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 181template <class Rep1, class Period1, class Rep2, class Period2> 182 constexpr 183 bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 184template <class Rep1, class Period1, class Rep2, class Period2> 185 constexpr 186 bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 187template <class Rep1, class Period1, class Rep2, class Period2> 188 constexpr 189 bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 190template <class Rep1, class Period1, class Rep2, class Period2> 191 constexpr 192 bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 193template <class Rep1, class Period1, class Rep2, class Period2> 194 constexpr 195 bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 196 197// duration_cast 198template <class ToDuration, class Rep, class Period> 199 ToDuration duration_cast(const duration<Rep, Period>& d); 200 201template <class ToDuration, class Rep, class Period> 202 constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17 203template <class ToDuration, class Rep, class Period> 204 constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17 205template <class ToDuration, class Rep, class Period> 206 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 207 208// duration I/O is elsewhere 209 210// time_point arithmetic (all constexpr in C++14) 211template <class Clock, class Duration1, class Rep2, class Period2> 212 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 213 operator+(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); 214template <class Rep1, class Period1, class Clock, class Duration2> 215 time_point<Clock, typename common_type<duration<Rep1, Period1>, Duration2>::type> 216 operator+(const duration<Rep1, Period1>& lhs, const time_point<Clock, Duration2>& rhs); 217template <class Clock, class Duration1, class Rep2, class Period2> 218 time_point<Clock, typename common_type<Duration1, duration<Rep2, Period2>>::type> 219 operator-(const time_point<Clock, Duration1>& lhs, const duration<Rep2, Period2>& rhs); 220template <class Clock, class Duration1, class Duration2> 221 typename common_type<Duration1, Duration2>::type 222 operator-(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 223 224// time_point comparisons (all constexpr in C++14) 225template <class Clock, class Duration1, class Duration2> 226 bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 227template <class Clock, class Duration1, class Duration2> 228 bool operator!=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 229template <class Clock, class Duration1, class Duration2> 230 bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 231template <class Clock, class Duration1, class Duration2> 232 bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 233template <class Clock, class Duration1, class Duration2> 234 bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 235template <class Clock, class Duration1, class Duration2> 236 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 237 238// time_point_cast (constexpr in C++14) 239 240template <class ToDuration, class Clock, class Duration> 241 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); 242 243template <class ToDuration, class Clock, class Duration> 244 constexpr time_point<Clock, ToDuration> 245 floor(const time_point<Clock, Duration>& tp); // C++17 246 247template <class ToDuration, class Clock, class Duration> 248 constexpr time_point<Clock, ToDuration> 249 ceil(const time_point<Clock, Duration>& tp); // C++17 250 251template <class ToDuration, class Clock, class Duration> 252 constexpr time_point<Clock, ToDuration> 253 round(const time_point<Clock, Duration>& tp); // C++17 254 255template <class Rep, class Period> 256 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17 257 258// Clocks 259 260class system_clock 261{ 262public: 263 typedef microseconds duration; 264 typedef duration::rep rep; 265 typedef duration::period period; 266 typedef chrono::time_point<system_clock> time_point; 267 static const bool is_steady = false; // constexpr in C++14 268 269 static time_point now() noexcept; 270 static time_t to_time_t (const time_point& __t) noexcept; 271 static time_point from_time_t(time_t __t) noexcept; 272}; 273 274template <class Duration> 275 using sys_time = time_point<system_clock, Duration>; // C++20 276using sys_seconds = sys_time<seconds>; // C++20 277using sys_days = sys_time<days>; // C++20 278 279class file_clock // C++20 280{ 281public: 282 typedef see-below rep; 283 typedef nano period; 284 typedef chrono::duration<rep, period> duration; 285 typedef chrono::time_point<file_clock> time_point; 286 static constexpr bool is_steady = false; 287 288 static time_point now() noexcept; 289 290 template<class Duration> 291 static sys_time<see-below> to_sys(const file_time<Duration>&); 292 293 template<class Duration> 294 static file_time<see-below> from_sys(const sys_time<Duration>&); 295}; 296 297template<class Duration> 298 using file_time = time_point<file_clock, Duration>; // C++20 299 300class steady_clock 301{ 302public: 303 typedef nanoseconds duration; 304 typedef duration::rep rep; 305 typedef duration::period period; 306 typedef chrono::time_point<steady_clock, duration> time_point; 307 static const bool is_steady = true; // constexpr in C++14 308 309 static time_point now() noexcept; 310}; 311 312typedef steady_clock high_resolution_clock; 313 314// 25.7.8, local time // C++20 315struct local_t {}; 316template<class Duration> 317 using local_time = time_point<local_t, Duration>; 318using local_seconds = local_time<seconds>; 319using local_days = local_time<days>; 320 321// 25.8.2, class last_spec // C++20 322struct last_spec; 323 324// 25.8.3, class day // C++20 325 326class day; 327constexpr bool operator==(const day& x, const day& y) noexcept; 328constexpr bool operator!=(const day& x, const day& y) noexcept; 329constexpr bool operator< (const day& x, const day& y) noexcept; 330constexpr bool operator> (const day& x, const day& y) noexcept; 331constexpr bool operator<=(const day& x, const day& y) noexcept; 332constexpr bool operator>=(const day& x, const day& y) noexcept; 333constexpr day operator+(const day& x, const days& y) noexcept; 334constexpr day operator+(const days& x, const day& y) noexcept; 335constexpr day operator-(const day& x, const days& y) noexcept; 336constexpr days operator-(const day& x, const day& y) noexcept; 337 338// 25.8.4, class month // C++20 339class month; 340constexpr bool operator==(const month& x, const month& y) noexcept; 341constexpr bool operator!=(const month& x, const month& y) noexcept; 342constexpr bool operator< (const month& x, const month& y) noexcept; 343constexpr bool operator> (const month& x, const month& y) noexcept; 344constexpr bool operator<=(const month& x, const month& y) noexcept; 345constexpr bool operator>=(const month& x, const month& y) noexcept; 346constexpr month operator+(const month& x, const months& y) noexcept; 347constexpr month operator+(const months& x, const month& y) noexcept; 348constexpr month operator-(const month& x, const months& y) noexcept; 349constexpr months operator-(const month& x, const month& y) noexcept; 350 351// 25.8.5, class year // C++20 352class year; 353constexpr bool operator==(const year& x, const year& y) noexcept; 354constexpr bool operator!=(const year& x, const year& y) noexcept; 355constexpr bool operator< (const year& x, const year& y) noexcept; 356constexpr bool operator> (const year& x, const year& y) noexcept; 357constexpr bool operator<=(const year& x, const year& y) noexcept; 358constexpr bool operator>=(const year& x, const year& y) noexcept; 359constexpr year operator+(const year& x, const years& y) noexcept; 360constexpr year operator+(const years& x, const year& y) noexcept; 361constexpr year operator-(const year& x, const years& y) noexcept; 362constexpr years operator-(const year& x, const year& y) noexcept; 363 364// 25.8.6, class weekday // C++20 365class weekday; 366 367constexpr bool operator==(const weekday& x, const weekday& y) noexcept; 368constexpr bool operator!=(const weekday& x, const weekday& y) noexcept; 369constexpr weekday operator+(const weekday& x, const days& y) noexcept; 370constexpr weekday operator+(const days& x, const weekday& y) noexcept; 371constexpr weekday operator-(const weekday& x, const days& y) noexcept; 372constexpr days operator-(const weekday& x, const weekday& y) noexcept; 373 374// 25.8.7, class weekday_indexed // C++20 375 376class weekday_indexed; 377constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; 378constexpr bool operator!=(const weekday_indexed& x, const weekday_indexed& y) noexcept; 379 380// 25.8.8, class weekday_last // C++20 381class weekday_last; 382 383constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; 384constexpr bool operator!=(const weekday_last& x, const weekday_last& y) noexcept; 385 386// 25.8.9, class month_day // C++20 387class month_day; 388 389constexpr bool operator==(const month_day& x, const month_day& y) noexcept; 390constexpr bool operator!=(const month_day& x, const month_day& y) noexcept; 391constexpr bool operator< (const month_day& x, const month_day& y) noexcept; 392constexpr bool operator> (const month_day& x, const month_day& y) noexcept; 393constexpr bool operator<=(const month_day& x, const month_day& y) noexcept; 394constexpr bool operator>=(const month_day& x, const month_day& y) noexcept; 395 396 397// 25.8.10, class month_day_last // C++20 398class month_day_last; 399 400constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; 401constexpr bool operator!=(const month_day_last& x, const month_day_last& y) noexcept; 402constexpr bool operator< (const month_day_last& x, const month_day_last& y) noexcept; 403constexpr bool operator> (const month_day_last& x, const month_day_last& y) noexcept; 404constexpr bool operator<=(const month_day_last& x, const month_day_last& y) noexcept; 405constexpr bool operator>=(const month_day_last& x, const month_day_last& y) noexcept; 406 407// 25.8.11, class month_weekday // C++20 408class month_weekday; 409 410constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; 411constexpr bool operator!=(const month_weekday& x, const month_weekday& y) noexcept; 412 413// 25.8.12, class month_weekday_last // C++20 414class month_weekday_last; 415 416constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; 417constexpr bool operator!=(const month_weekday_last& x, const month_weekday_last& y) noexcept; 418 419 420// 25.8.13, class year_month // C++20 421class year_month; 422 423constexpr bool operator==(const year_month& x, const year_month& y) noexcept; 424constexpr bool operator!=(const year_month& x, const year_month& y) noexcept; 425constexpr bool operator< (const year_month& x, const year_month& y) noexcept; 426constexpr bool operator> (const year_month& x, const year_month& y) noexcept; 427constexpr bool operator<=(const year_month& x, const year_month& y) noexcept; 428constexpr bool operator>=(const year_month& x, const year_month& y) noexcept; 429 430constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; 431constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; 432constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; 433constexpr months operator-(const year_month& x, const year_month& y) noexcept; 434constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; 435constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; 436constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; 437 438// 25.8.14, class year_month_day class // C++20 439year_month_day; 440 441constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; 442constexpr bool operator!=(const year_month_day& x, const year_month_day& y) noexcept; 443constexpr bool operator< (const year_month_day& x, const year_month_day& y) noexcept; 444constexpr bool operator> (const year_month_day& x, const year_month_day& y) noexcept; 445constexpr bool operator<=(const year_month_day& x, const year_month_day& y) noexcept; 446constexpr bool operator>=(const year_month_day& x, const year_month_day& y) noexcept; 447 448constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; 449constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; 450constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; 451constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; 452constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; 453constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; 454 455 456// 25.8.15, class year_month_day_last // C++20 457class year_month_day_last; 458 459constexpr bool operator==(const year_month_day_last& x, 460 const year_month_day_last& y) noexcept; 461constexpr bool operator!=(const year_month_day_last& x, 462 const year_month_day_last& y) noexcept; 463constexpr bool operator< (const year_month_day_last& x, 464 const year_month_day_last& y) noexcept; 465constexpr bool operator> (const year_month_day_last& x, 466 const year_month_day_last& y) noexcept; 467constexpr bool operator<=(const year_month_day_last& x, 468 const year_month_day_last& y) noexcept; 469constexpr bool operator>=(const year_month_day_last& x, 470 const year_month_day_last& y) noexcept; 471 472constexpr year_month_day_last 473 operator+(const year_month_day_last& ymdl, const months& dm) noexcept; 474constexpr year_month_day_last 475 operator+(const months& dm, const year_month_day_last& ymdl) noexcept; 476constexpr year_month_day_last 477 operator+(const year_month_day_last& ymdl, const years& dy) noexcept; 478constexpr year_month_day_last 479 operator+(const years& dy, const year_month_day_last& ymdl) noexcept; 480constexpr year_month_day_last 481 operator-(const year_month_day_last& ymdl, const months& dm) noexcept; 482constexpr year_month_day_last 483 operator-(const year_month_day_last& ymdl, const years& dy) noexcept; 484 485// 25.8.16, class year_month_weekday // C++20 486class year_month_weekday; 487 488constexpr bool operator==(const year_month_weekday& x, 489 const year_month_weekday& y) noexcept; 490constexpr bool operator!=(const year_month_weekday& x, 491 const year_month_weekday& y) noexcept; 492 493constexpr year_month_weekday 494 operator+(const year_month_weekday& ymwd, const months& dm) noexcept; 495constexpr year_month_weekday 496 operator+(const months& dm, const year_month_weekday& ymwd) noexcept; 497constexpr year_month_weekday 498 operator+(const year_month_weekday& ymwd, const years& dy) noexcept; 499constexpr year_month_weekday 500 operator+(const years& dy, const year_month_weekday& ymwd) noexcept; 501constexpr year_month_weekday 502 operator-(const year_month_weekday& ymwd, const months& dm) noexcept; 503constexpr year_month_weekday 504 operator-(const year_month_weekday& ymwd, const years& dy) noexcept; 505 506// 25.8.17, class year_month_weekday_last // C++20 507class year_month_weekday_last; 508 509constexpr bool operator==(const year_month_weekday_last& x, 510 const year_month_weekday_last& y) noexcept; 511constexpr bool operator!=(const year_month_weekday_last& x, 512 const year_month_weekday_last& y) noexcept; 513constexpr year_month_weekday_last 514 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 515constexpr year_month_weekday_last 516 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; 517constexpr year_month_weekday_last 518 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 519constexpr year_month_weekday_last 520 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; 521constexpr year_month_weekday_last 522 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 523constexpr year_month_weekday_last 524 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 525 526// 25.8.18, civil calendar conventional syntax operators // C++20 527constexpr year_month 528 operator/(const year& y, const month& m) noexcept; 529constexpr year_month 530 operator/(const year& y, int m) noexcept; 531constexpr month_day 532 operator/(const month& m, const day& d) noexcept; 533constexpr month_day 534 operator/(const month& m, int d) noexcept; 535constexpr month_day 536 operator/(int m, const day& d) noexcept; 537constexpr month_day 538 operator/(const day& d, const month& m) noexcept; 539constexpr month_day 540 operator/(const day& d, int m) noexcept; 541constexpr month_day_last 542 operator/(const month& m, last_spec) noexcept; 543constexpr month_day_last 544 operator/(int m, last_spec) noexcept; 545constexpr month_day_last 546 operator/(last_spec, const month& m) noexcept; 547constexpr month_day_last 548 operator/(last_spec, int m) noexcept; 549constexpr month_weekday 550 operator/(const month& m, const weekday_indexed& wdi) noexcept; 551constexpr month_weekday 552 operator/(int m, const weekday_indexed& wdi) noexcept; 553constexpr month_weekday 554 operator/(const weekday_indexed& wdi, const month& m) noexcept; 555constexpr month_weekday 556 operator/(const weekday_indexed& wdi, int m) noexcept; 557constexpr month_weekday_last 558 operator/(const month& m, const weekday_last& wdl) noexcept; 559constexpr month_weekday_last 560 operator/(int m, const weekday_last& wdl) noexcept; 561constexpr month_weekday_last 562 operator/(const weekday_last& wdl, const month& m) noexcept; 563constexpr month_weekday_last 564 operator/(const weekday_last& wdl, int m) noexcept; 565constexpr year_month_day 566 operator/(const year_month& ym, const day& d) noexcept; 567constexpr year_month_day 568 operator/(const year_month& ym, int d) noexcept; 569constexpr year_month_day 570 operator/(const year& y, const month_day& md) noexcept; 571constexpr year_month_day 572 operator/(int y, const month_day& md) noexcept; 573constexpr year_month_day 574 operator/(const month_day& md, const year& y) noexcept; 575constexpr year_month_day 576 operator/(const month_day& md, int y) noexcept; 577constexpr year_month_day_last 578 operator/(const year_month& ym, last_spec) noexcept; 579constexpr year_month_day_last 580 operator/(const year& y, const month_day_last& mdl) noexcept; 581constexpr year_month_day_last 582 operator/(int y, const month_day_last& mdl) noexcept; 583constexpr year_month_day_last 584 operator/(const month_day_last& mdl, const year& y) noexcept; 585constexpr year_month_day_last 586 operator/(const month_day_last& mdl, int y) noexcept; 587constexpr year_month_weekday 588 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; 589constexpr year_month_weekday 590 operator/(const year& y, const month_weekday& mwd) noexcept; 591constexpr year_month_weekday 592 operator/(int y, const month_weekday& mwd) noexcept; 593constexpr year_month_weekday 594 operator/(const month_weekday& mwd, const year& y) noexcept; 595constexpr year_month_weekday 596 operator/(const month_weekday& mwd, int y) noexcept; 597constexpr year_month_weekday_last 598 operator/(const year_month& ym, const weekday_last& wdl) noexcept; 599constexpr year_month_weekday_last 600 operator/(const year& y, const month_weekday_last& mwdl) noexcept; 601constexpr year_month_weekday_last 602 operator/(int y, const month_weekday_last& mwdl) noexcept; 603constexpr year_month_weekday_last 604 operator/(const month_weekday_last& mwdl, const year& y) noexcept; 605constexpr year_month_weekday_last 606 operator/(const month_weekday_last& mwdl, int y) noexcept; 607 608// 26.9, class template hh_mm_ss 609template <class Duration> 610class hh_mm_ss 611{ 612 bool is_neg; // exposition only 613 chrono::hours h; // exposition only 614 chrono::minutes m; // exposition only 615 chrono::seconds s; // exposition only 616 precision ss; // exposition only 617 618public: 619 static unsigned constexpr fractional_width = see below; 620 using precision = see below; 621 622 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} 623 constexpr explicit hh_mm_ss(Duration d) noexcept; 624 625 constexpr bool is_negative() const noexcept; 626 constexpr chrono::hours hours() const noexcept; 627 constexpr chrono::minutes minutes() const noexcept; 628 constexpr chrono::seconds seconds() const noexcept; 629 constexpr precision subseconds() const noexcept; 630 631 constexpr explicit operator precision() const noexcept; 632 constexpr precision to_duration() const noexcept; 633}; 634 635// 26.10, 12/24 hour functions 636constexpr bool is_am(hours const& h) noexcept; 637constexpr bool is_pm(hours const& h) noexcept; 638constexpr hours make12(const hours& h) noexcept; 639constexpr hours make24(const hours& h, bool is_pm) noexcept; 640 641// 25.10.5, class time_zone // C++20 642enum class choose {earliest, latest}; 643class time_zone; 644bool operator==(const time_zone& x, const time_zone& y) noexcept; 645bool operator!=(const time_zone& x, const time_zone& y) noexcept; 646bool operator<(const time_zone& x, const time_zone& y) noexcept; 647bool operator>(const time_zone& x, const time_zone& y) noexcept; 648bool operator<=(const time_zone& x, const time_zone& y) noexcept; 649bool operator>=(const time_zone& x, const time_zone& y) noexcept; 650 651// calendrical constants 652inline constexpr last_spec last{}; // C++20 653inline constexpr chrono::weekday Sunday{0}; // C++20 654inline constexpr chrono::weekday Monday{1}; // C++20 655inline constexpr chrono::weekday Tuesday{2}; // C++20 656inline constexpr chrono::weekday Wednesday{3}; // C++20 657inline constexpr chrono::weekday Thursday{4}; // C++20 658inline constexpr chrono::weekday Friday{5}; // C++20 659inline constexpr chrono::weekday Saturday{6}; // C++20 660 661inline constexpr chrono::month January{1}; // C++20 662inline constexpr chrono::month February{2}; // C++20 663inline constexpr chrono::month March{3}; // C++20 664inline constexpr chrono::month April{4}; // C++20 665inline constexpr chrono::month May{5}; // C++20 666inline constexpr chrono::month June{6}; // C++20 667inline constexpr chrono::month July{7}; // C++20 668inline constexpr chrono::month August{8}; // C++20 669inline constexpr chrono::month September{9}; // C++20 670inline constexpr chrono::month October{10}; // C++20 671inline constexpr chrono::month November{11}; // C++20 672inline constexpr chrono::month December{12}; // C++20 673} // chrono 674 675inline namespace literals { 676 inline namespace chrono_literals { 677constexpr chrono::hours operator ""h(unsigned long long); // C++14 678constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14 679constexpr chrono::minutes operator ""min(unsigned long long); // C++14 680constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14 681constexpr chrono::seconds operator ""s(unsigned long long); // C++14 682constexpr chrono::duration<unspecified > operator ""s(long double); // C++14 683constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14 684constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14 685constexpr chrono::microseconds operator ""us(unsigned long long); // C++14 686constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14 687constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14 688constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14 689constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20 690constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20 691} // chrono_literals 692} // literals 693 694} // std 695*/ 696 697#include <__chrono/calendar.h> 698#include <__chrono/convert_to_timespec.h> 699#include <__chrono/duration.h> 700#include <__chrono/file_clock.h> 701#include <__chrono/high_resolution_clock.h> 702#include <__chrono/steady_clock.h> 703#include <__chrono/system_clock.h> 704#include <__chrono/time_point.h> 705#include <__config> 706#include <compare> 707#include <version> 708 709#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 710#pragma GCC system_header 711#endif 712 713#endif // _LIBCPP_CHRONO 714