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// clang-format off 14 15/* 16 chrono synopsis 17 18#include <compare> // C++20 19 20namespace std 21{ 22namespace chrono 23{ 24 25template <class ToDuration, class Rep, class Period> 26constexpr 27ToDuration 28duration_cast(const duration<Rep, Period>& fd); 29 30template <class Rep> struct treat_as_floating_point : is_floating_point<Rep> {}; 31 32template <class Rep> inline constexpr bool treat_as_floating_point_v 33 = treat_as_floating_point<Rep>::value; // C++17 34 35template <class Rep> 36struct duration_values 37{ 38public: 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 42}; 43 44// duration 45 46template <class Rep, class Period = ratio<1>> 47class duration 48{ 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"); 52public: 53 typedef Rep rep; 54 typedef typename _Period::type period; 55 56 constexpr duration() = default; 57 template <class Rep2> 58 constexpr explicit duration(const Rep2& r, 59 typename enable_if 60 < 61 is_convertible<Rep2, rep>::value && 62 (treat_as_floating_point<rep>::value || 63 !treat_as_floating_point<rep>::value && !treat_as_floating_point<Rep2>::value) 64 >::type* = 0); 65 66 // conversions 67 template <class Rep2, class Period2> 68 constexpr duration(const duration<Rep2, Period2>& d, 69 typename enable_if 70 < 71 treat_as_floating_point<rep>::value || 72 ratio_divide<Period2, period>::type::den == 1 73 >::type* = 0); 74 75 // observer 76 77 constexpr rep count() const; 78 79 // arithmetic 80 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 87 88 constexpr duration& operator+=(const duration& d); // constexpr in C++17 89 constexpr duration& operator-=(const duration& d); // constexpr in C++17 90 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 95 96 // special values 97 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 101}; 102 103typedef duration<long long, nano> nanoseconds; 104typedef duration<long long, micro> microseconds; 105typedef duration<long long, milli> milliseconds; 106typedef duration<long long > seconds; 107typedef duration< long, ratio< 60> > minutes; 108typedef duration< long, ratio<3600> > hours; 109 110template <class Clock, class Duration = typename Clock::duration> 111class time_point 112{ 113public: 114 typedef Clock clock; 115 typedef Duration duration; 116 typedef typename duration::rep rep; 117 typedef typename duration::period period; 118private: 119 duration d_; // exposition only 120 121public: 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 124 125 // conversions 126 template <class Duration2> 127 time_point(const time_point<clock, Duration2>& t); // constexpr in C++14 128 129 // observer 130 131 duration time_since_epoch() const; // constexpr in C++14 132 133 // arithmetic 134 135 time_point& operator+=(const duration& d); // constexpr in C++17 136 time_point& operator-=(const duration& d); // constexpr in C++17 137 138 // special values 139 140 static constexpr time_point min(); // noexcept in C++20 141 static constexpr time_point max(); // noexcept in C++20 142}; 143 144} // chrono 145 146// common_type traits 147template <class Rep1, class Period1, class Rep2, class Period2> 148 struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>; 149 150template <class Clock, class Duration1, class Duration2> 151 struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>; 152 153namespace chrono { 154 155// duration arithmetic 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 Period1, class Rep2, class Period2> 161 constexpr 162 typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type 163 operator-(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 164template <class Rep1, class Period, class Rep2> 165 constexpr 166 duration<typename common_type<Rep1, Rep2>::type, Period> 167 operator*(const duration<Rep1, Period>& d, const Rep2& s); 168template <class Rep1, class Period, class Rep2> 169 constexpr 170 duration<typename common_type<Rep1, Rep2>::type, Period> 171 operator*(const Rep1& s, const duration<Rep2, Period>& d); 172template <class Rep1, class Period, class Rep2> 173 constexpr 174 duration<typename common_type<Rep1, Rep2>::type, Period> 175 operator/(const duration<Rep1, Period>& d, const Rep2& s); 176template <class Rep1, class Period1, class Rep2, class Period2> 177 constexpr 178 typename common_type<Rep1, Rep2>::type 179 operator/(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 180 181// duration comparisons 182template <class Rep1, class Period1, class Rep2, class Period2> 183 constexpr 184 bool operator==(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 185template <class Rep1, class Period1, class Rep2, class Period2> 186 constexpr 187 bool operator!=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); // removed in C++20 188template <class Rep1, class Period1, class Rep2, class Period2> 189 constexpr 190 bool operator< (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 191template <class Rep1, class Period1, class Rep2, class Period2> 192 constexpr 193 bool operator<=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 194template <class Rep1, class Period1, class Rep2, class Period2> 195 constexpr 196 bool operator> (const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 197template <class Rep1, class Period1, class Rep2, class Period2> 198 constexpr 199 bool operator>=(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs); 200template<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 204 205// duration_cast 206template <class ToDuration, class Rep, class Period> 207 ToDuration duration_cast(const duration<Rep, Period>& d); 208 209template <class ToDuration, class Rep, class Period> 210 constexpr ToDuration floor(const duration<Rep, Period>& d); // C++17 211template <class ToDuration, class Rep, class Period> 212 constexpr ToDuration ceil(const duration<Rep, Period>& d); // C++17 213template <class ToDuration, class Rep, class Period> 214 constexpr ToDuration round(const duration<Rep, Period>& d); // C++17 215 216// duration I/O 217template<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); 221 222// time_point arithmetic (all constexpr in C++14) 223template <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); 226template <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); 229template <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); 232template <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); 235 236// time_point comparisons (all constexpr in C++14) 237template <class Clock, class Duration1, class Duration2> 238 bool operator==(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 239template <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 241template <class Clock, class Duration1, class Duration2> 242 bool operator< (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 243template <class Clock, class Duration1, class Duration2> 244 bool operator<=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 245template <class Clock, class Duration1, class Duration2> 246 bool operator> (const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 247template <class Clock, class Duration1, class Duration2> 248 bool operator>=(const time_point<Clock, Duration1>& lhs, const time_point<Clock, Duration2>& rhs); 249template<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 253 254// time_point_cast (constexpr in C++14) 255 256template <class ToDuration, class Clock, class Duration> 257 time_point<Clock, ToDuration> time_point_cast(const time_point<Clock, Duration>& t); 258 259template <class ToDuration, class Clock, class Duration> 260 constexpr time_point<Clock, ToDuration> 261 floor(const time_point<Clock, Duration>& tp); // C++17 262 263template <class ToDuration, class Clock, class Duration> 264 constexpr time_point<Clock, ToDuration> 265 ceil(const time_point<Clock, Duration>& tp); // C++17 266 267template <class ToDuration, class Clock, class Duration> 268 constexpr time_point<Clock, ToDuration> 269 round(const time_point<Clock, Duration>& tp); // C++17 270 271template <class Rep, class Period> 272 constexpr duration<Rep, Period> abs(duration<Rep, Period> d); // C++17 273 274// Clocks 275 276class system_clock 277{ 278public: 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 284 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; 288}; 289 290template <class Duration> 291 using sys_time = time_point<system_clock, Duration>; // C++20 292using sys_seconds = sys_time<seconds>; // C++20 293using sys_days = sys_time<days>; // C++20 294 295template<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); 298 299template<class charT, class traits> // C++20 300 basic_ostream<charT, traits>& 301 operator<<(basic_ostream<charT, traits>& os, const sys_days& dp); 302 303class file_clock // C++20 304{ 305public: 306 typedef see-below rep; 307 typedef nano period; 308 typedef chrono::duration<rep, period> duration; 309 typedef chrono::time_point<file_clock> time_point; 310 static constexpr bool is_steady = false; 311 312 static time_point now() noexcept; 313 314 template<class Duration> 315 static sys_time<see-below> to_sys(const file_time<Duration>&); 316 317 template<class Duration> 318 static file_time<see-below> from_sys(const sys_time<Duration>&); 319}; 320 321template<class Duration> 322 using file_time = time_point<file_clock, Duration>; // C++20 323 324template<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); 327 328class steady_clock 329{ 330public: 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 336 337 static time_point now() noexcept; 338}; 339 340typedef steady_clock high_resolution_clock; 341 342// 25.7.8, local time // C++20 343struct local_t {}; 344template<class Duration> 345 using local_time = time_point<local_t, Duration>; 346using local_seconds = local_time<seconds>; 347using local_days = local_time<days>; 348 349template<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); 352 353// 25.8.2, class last_spec // C++20 354struct last_spec; 355 356// 25.8.3, class day // C++20 357 358class day; 359constexpr bool operator==(const day& x, const day& y) noexcept; 360constexpr strong_ordering operator<=>(const day& x, const day& y) noexcept; 361constexpr day operator+(const day& x, const days& y) noexcept; 362constexpr day operator+(const days& x, const day& y) noexcept; 363constexpr day operator-(const day& x, const days& y) noexcept; 364constexpr days operator-(const day& x, const day& y) noexcept; 365template<class charT, class traits> 366 basic_ostream<charT, traits>& 367 operator<<(basic_ostream<charT, traits>& os, const day& d); 368 369// 25.8.4, class month // C++20 370class month; 371constexpr bool operator==(const month& x, const month& y) noexcept; 372constexpr strong_ordering operator<=>(const month& x, const month& y) noexcept; 373 374constexpr month operator+(const month& x, const months& y) noexcept; 375constexpr month operator+(const months& x, const month& y) noexcept; 376constexpr month operator-(const month& x, const months& y) noexcept; 377constexpr months operator-(const month& x, const month& y) noexcept; 378template<class charT, class traits> 379 basic_ostream<charT, traits>& 380 operator<<(basic_ostream<charT, traits>& os, const month& m); 381 382// 25.8.5, class year // C++20 383class year; 384constexpr bool operator==(const year& x, const year& y) noexcept; 385constexpr strong_ordering operator<=>(const year& x, const year& y) noexcept; 386 387constexpr year operator+(const year& x, const years& y) noexcept; 388constexpr year operator+(const years& x, const year& y) noexcept; 389constexpr year operator-(const year& x, const years& y) noexcept; 390constexpr years operator-(const year& x, const year& y) noexcept; 391template<class charT, class traits> 392 basic_ostream<charT, traits>& 393 operator<<(basic_ostream<charT, traits>& os, const year& y); 394 395// 25.8.6, class weekday // C++20 396class weekday; 397 398constexpr bool operator==(const weekday& x, const weekday& y) noexcept; 399constexpr weekday operator+(const weekday& x, const days& y) noexcept; 400constexpr weekday operator+(const days& x, const weekday& y) noexcept; 401constexpr weekday operator-(const weekday& x, const days& y) noexcept; 402constexpr days operator-(const weekday& x, const weekday& y) noexcept; 403template<class charT, class traits> 404 basic_ostream<charT, traits>& 405 operator<<(basic_ostream<charT, traits>& os, const weekday& wd); 406 407// 25.8.7, class weekday_indexed // C++20 408 409class weekday_indexed; 410constexpr bool operator==(const weekday_indexed& x, const weekday_indexed& y) noexcept; 411 412template<class charT, class traits> 413 basic_ostream<charT, traits>& 414 operator<<(basic_ostream<charT, traits>& os, const weekday_indexed& wdi); 415 416// 25.8.8, class weekday_last // C++20 417class weekday_last; 418 419constexpr bool operator==(const weekday_last& x, const weekday_last& y) noexcept; 420 421template<class charT, class traits> 422 basic_ostream<charT, traits>& 423 operator<<(basic_ostream<charT, traits>& os, const weekday_last& wdl); 424 425// 25.8.9, class month_day // C++20 426class month_day; 427 428constexpr bool operator==(const month_day& x, const month_day& y) noexcept; 429constexpr strong_ordering operator<=>(const month_day& x, const month_day& y) noexcept; 430 431template<class charT, class traits> 432 basic_ostream<charT, traits>& 433 operator<<(basic_ostream<charT, traits>& os, const month_day& md); 434 435// 25.8.10, class month_day_last // C++20 436class month_day_last; 437 438constexpr bool operator==(const month_day_last& x, const month_day_last& y) noexcept; 439constexpr strong_ordering operator<=>(const month_day_last& x, const month_day_last& y) noexcept; 440 441template<class charT, class traits> 442 basic_ostream<charT, traits>& 443 operator<<(basic_ostream<charT, traits>& os, const month_day_last& mdl); 444 445// 25.8.11, class month_weekday // C++20 446class month_weekday; 447 448constexpr bool operator==(const month_weekday& x, const month_weekday& y) noexcept; 449 450template<class charT, class traits> 451 basic_ostream<charT, traits>& 452 operator<<(basic_ostream<charT, traits>& os, const month_weekday& mwd); 453 454// 25.8.12, class month_weekday_last // C++20 455class month_weekday_last; 456 457constexpr bool operator==(const month_weekday_last& x, const month_weekday_last& y) noexcept; 458 459template<class charT, class traits> 460 basic_ostream<charT, traits>& 461 operator<<(basic_ostream<charT, traits>& os, const month_weekday_last& mwdl); 462 463 464// 25.8.13, class year_month // C++20 465class year_month; 466 467constexpr bool operator==(const year_month& x, const year_month& y) noexcept; 468constexpr strong_ordering operator<=>(const year_month& x, const year_month& y) noexcept; 469 470constexpr year_month operator+(const year_month& ym, const months& dm) noexcept; 471constexpr year_month operator+(const months& dm, const year_month& ym) noexcept; 472constexpr year_month operator-(const year_month& ym, const months& dm) noexcept; 473constexpr months operator-(const year_month& x, const year_month& y) noexcept; 474constexpr year_month operator+(const year_month& ym, const years& dy) noexcept; 475constexpr year_month operator+(const years& dy, const year_month& ym) noexcept; 476constexpr year_month operator-(const year_month& ym, const years& dy) noexcept; 477 478template<class charT, class traits> 479 basic_ostream<charT, traits>& 480 operator<<(basic_ostream<charT, traits>& os, const year_month& ym); 481 482// 25.8.14, class year_month_day class // C++20 483year_month_day; 484 485constexpr bool operator==(const year_month_day& x, const year_month_day& y) noexcept; 486constexpr strong_ordering operator<=>(const year_month_day& x, const year_month_day& y) noexcept; 487 488constexpr year_month_day operator+(const year_month_day& ymd, const months& dm) noexcept; 489constexpr year_month_day operator+(const months& dm, const year_month_day& ymd) noexcept; 490constexpr year_month_day operator+(const year_month_day& ymd, const years& dy) noexcept; 491constexpr year_month_day operator+(const years& dy, const year_month_day& ymd) noexcept; 492constexpr year_month_day operator-(const year_month_day& ymd, const months& dm) noexcept; 493constexpr year_month_day operator-(const year_month_day& ymd, const years& dy) noexcept; 494 495template<class charT, class traits> 496 basic_ostream<charT, traits>& 497 operator<<(basic_ostream<charT, traits>& os, const year_month_day& ymd); 498 499// 25.8.15, class year_month_day_last // C++20 500class year_month_day_last; 501 502constexpr bool operator==(const year_month_day_last& x, const year_month_day_last& y) noexcept; 503constexpr strong_ordering operator<=>(const year_month_day_last_day& x, const year_month_day_last_day& y) noexcept; 504 505constexpr year_month_day_last 506 operator+(const year_month_day_last& ymdl, const months& dm) noexcept; 507constexpr year_month_day_last 508 operator+(const months& dm, const year_month_day_last& ymdl) noexcept; 509constexpr year_month_day_last 510 operator+(const year_month_day_last& ymdl, const years& dy) noexcept; 511constexpr year_month_day_last 512 operator+(const years& dy, const year_month_day_last& ymdl) noexcept; 513constexpr year_month_day_last 514 operator-(const year_month_day_last& ymdl, const months& dm) noexcept; 515constexpr year_month_day_last 516 operator-(const year_month_day_last& ymdl, const years& dy) noexcept; 517 518template<class charT, class traits> 519 basic_ostream<charT, traits>& 520 operator<<(basic_ostream<charT, traits>& os, const year_month_day_last& ymdl); 521 522// 25.8.16, class year_month_weekday // C++20 523class year_month_weekday; 524 525constexpr bool operator==(const year_month_weekday& x, 526 const year_month_weekday& y) noexcept; 527 528constexpr year_month_weekday 529 operator+(const year_month_weekday& ymwd, const months& dm) noexcept; 530constexpr year_month_weekday 531 operator+(const months& dm, const year_month_weekday& ymwd) noexcept; 532constexpr year_month_weekday 533 operator+(const year_month_weekday& ymwd, const years& dy) noexcept; 534constexpr year_month_weekday 535 operator+(const years& dy, const year_month_weekday& ymwd) noexcept; 536constexpr year_month_weekday 537 operator-(const year_month_weekday& ymwd, const months& dm) noexcept; 538constexpr year_month_weekday 539 operator-(const year_month_weekday& ymwd, const years& dy) noexcept; 540 541template<class charT, class traits> 542 basic_ostream<charT, traits>& 543 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday& ymwd); 544 545// 25.8.17, class year_month_weekday_last // C++20 546class year_month_weekday_last; 547 548constexpr bool operator==(const year_month_weekday_last& x, 549 const year_month_weekday_last& y) noexcept; 550constexpr year_month_weekday_last 551 operator+(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 552constexpr year_month_weekday_last 553 operator+(const months& dm, const year_month_weekday_last& ymwdl) noexcept; 554constexpr year_month_weekday_last 555 operator+(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 556constexpr year_month_weekday_last 557 operator+(const years& dy, const year_month_weekday_last& ymwdl) noexcept; 558constexpr year_month_weekday_last 559 operator-(const year_month_weekday_last& ymwdl, const months& dm) noexcept; 560constexpr year_month_weekday_last 561 operator-(const year_month_weekday_last& ymwdl, const years& dy) noexcept; 562 563template<class charT, class traits> 564 basic_ostream<charT, traits>& 565 operator<<(basic_ostream<charT, traits>& os, const year_month_weekday_last& ymwdl); 566 567// 25.8.18, civil calendar conventional syntax operators // C++20 568constexpr year_month 569 operator/(const year& y, const month& m) noexcept; 570constexpr year_month 571 operator/(const year& y, int m) noexcept; 572constexpr month_day 573 operator/(const month& m, const day& d) noexcept; 574constexpr month_day 575 operator/(const month& m, int d) noexcept; 576constexpr month_day 577 operator/(int m, const day& d) noexcept; 578constexpr month_day 579 operator/(const day& d, const month& m) noexcept; 580constexpr month_day 581 operator/(const day& d, int m) noexcept; 582constexpr month_day_last 583 operator/(const month& m, last_spec) noexcept; 584constexpr month_day_last 585 operator/(int m, last_spec) noexcept; 586constexpr month_day_last 587 operator/(last_spec, const month& m) noexcept; 588constexpr month_day_last 589 operator/(last_spec, int m) noexcept; 590constexpr month_weekday 591 operator/(const month& m, const weekday_indexed& wdi) noexcept; 592constexpr month_weekday 593 operator/(int m, const weekday_indexed& wdi) noexcept; 594constexpr month_weekday 595 operator/(const weekday_indexed& wdi, const month& m) noexcept; 596constexpr month_weekday 597 operator/(const weekday_indexed& wdi, int m) noexcept; 598constexpr month_weekday_last 599 operator/(const month& m, const weekday_last& wdl) noexcept; 600constexpr month_weekday_last 601 operator/(int m, const weekday_last& wdl) noexcept; 602constexpr month_weekday_last 603 operator/(const weekday_last& wdl, const month& m) noexcept; 604constexpr month_weekday_last 605 operator/(const weekday_last& wdl, int m) noexcept; 606constexpr year_month_day 607 operator/(const year_month& ym, const day& d) noexcept; 608constexpr year_month_day 609 operator/(const year_month& ym, int d) noexcept; 610constexpr year_month_day 611 operator/(const year& y, const month_day& md) noexcept; 612constexpr year_month_day 613 operator/(int y, const month_day& md) noexcept; 614constexpr year_month_day 615 operator/(const month_day& md, const year& y) noexcept; 616constexpr year_month_day 617 operator/(const month_day& md, int y) noexcept; 618constexpr year_month_day_last 619 operator/(const year_month& ym, last_spec) noexcept; 620constexpr year_month_day_last 621 operator/(const year& y, const month_day_last& mdl) noexcept; 622constexpr year_month_day_last 623 operator/(int y, const month_day_last& mdl) noexcept; 624constexpr year_month_day_last 625 operator/(const month_day_last& mdl, const year& y) noexcept; 626constexpr year_month_day_last 627 operator/(const month_day_last& mdl, int y) noexcept; 628constexpr year_month_weekday 629 operator/(const year_month& ym, const weekday_indexed& wdi) noexcept; 630constexpr year_month_weekday 631 operator/(const year& y, const month_weekday& mwd) noexcept; 632constexpr year_month_weekday 633 operator/(int y, const month_weekday& mwd) noexcept; 634constexpr year_month_weekday 635 operator/(const month_weekday& mwd, const year& y) noexcept; 636constexpr year_month_weekday 637 operator/(const month_weekday& mwd, int y) noexcept; 638constexpr year_month_weekday_last 639 operator/(const year_month& ym, const weekday_last& wdl) noexcept; 640constexpr year_month_weekday_last 641 operator/(const year& y, const month_weekday_last& mwdl) noexcept; 642constexpr year_month_weekday_last 643 operator/(int y, const month_weekday_last& mwdl) noexcept; 644constexpr year_month_weekday_last 645 operator/(const month_weekday_last& mwdl, const year& y) noexcept; 646constexpr year_month_weekday_last 647 operator/(const month_weekday_last& mwdl, int y) noexcept; 648 649// 26.9, class template hh_mm_ss 650template <class Duration> 651class hh_mm_ss 652{ 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 658 659public: 660 static unsigned constexpr fractional_width = see below; 661 using precision = see below; 662 663 constexpr hh_mm_ss() noexcept : hh_mm_ss{Duration::zero()} {} 664 constexpr explicit hh_mm_ss(Duration d) noexcept; 665 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; 671 672 constexpr explicit operator precision() const noexcept; 673 constexpr precision to_duration() const noexcept; 674}; 675 676template<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 679 680// 26.10, 12/24 hour functions 681constexpr bool is_am(hours const& h) noexcept; 682constexpr bool is_pm(hours const& h) noexcept; 683constexpr hours make12(const hours& h) noexcept; 684constexpr hours make24(const hours& h, bool is_pm) noexcept; 685 686// [time.zone.db], time zone database 687struct tzdb { // C++20 688 string version; 689}; 690 691class tzdb_list { // C++20 692public: 693 tzdb_list(const tzdb_list&) = delete; 694 tzdb_list& operator=(const tzdb_list&) = delete; 695 696 // unspecified additional constructors 697 698 class const_iterator; 699 700 const tzdb& front() const noexcept; 701 702 const_iterator erase_after(const_iterator p); 703 704 const_iterator begin() const noexcept; 705 const_iterator end() const noexcept; 706 707 const_iterator cbegin() const noexcept; 708 const_iterator cend() const noexcept; 709}; 710 711// [time.zone.db.access], time zone database access 712const tzdb& get_tzdb(); // C++20 713tzdb_list& get_tzdb_list(); // C++20 714 715// [time.zone.db.remote], remote time zone database support 716const tzdb& reload_tzdb(); // C++20 717string remote_version(); // C++20 718 719// 25.10.5, class time_zone // C++20 720enum class choose {earliest, latest}; 721class time_zone; 722bool operator==(const time_zone& x, const time_zone& y) noexcept; 723bool operator!=(const time_zone& x, const time_zone& y) noexcept; 724bool operator<(const time_zone& x, const time_zone& y) noexcept; 725bool operator>(const time_zone& x, const time_zone& y) noexcept; 726bool operator<=(const time_zone& x, const time_zone& y) noexcept; 727bool operator>=(const time_zone& x, const time_zone& y) noexcept; 728} // chrono 729 730namespace std { 731 template<class Duration, class charT> 732 struct formatter<chrono::sys_time<Duration>, charT>; // C++20 733 template<class Duration, class charT> 734 struct formatter<chrono::filetime<Duration>, charT>; // C++20 735 template<class Duration, class charT> 736 struct formatter<chrono::local_time<Duration>, charT>; // C++20 737 template<class Rep, class Period, class charT> 738 struct formatter<chrono::duration<Rep, Period>, charT>; // C++20 739 template<class charT> struct formatter<chrono::day, charT>; // C++20 740 template<class charT> struct formatter<chrono::month, charT>; // C++20 741 template<class charT> struct formatter<chrono::year, charT>; // C++20 742 template<class charT> struct formatter<chrono::weekday, charT>; // C++20 743 template<class charT> struct formatter<chrono::weekday_indexed, charT>; // C++20 744 template<class charT> struct formatter<chrono::weekday_last, charT>; // C++20 745 template<class charT> struct formatter<chrono::month_day, charT>; // C++20 746 template<class charT> struct formatter<chrono::month_day_last, charT>; // C++20 747 template<class charT> struct formatter<chrono::month_weekday, charT>; // C++20 748 template<class charT> struct formatter<chrono::month_weekday_last, charT>; // C++20 749 template<class charT> struct formatter<chrono::year_month, charT>; // C++20 750 template<class charT> struct formatter<chrono::year_month_day, charT>; // C++20 751 template<class charT> struct formatter<chrono::year_month_day_last, charT>; // C++20 752 template<class charT> struct formatter<chrono::year_month_weekday, charT>; // C++20 753 template<class charT> struct formatter<chrono::year_month_weekday_last, charT>; // C++20 754 template<class Rep, class Period, class charT> 755 struct formatter<chrono::hh_mm_ss<duration<Rep, Period>>, charT>; // C++20 756} // namespace std 757 758namespace chrono { 759// calendrical constants 760inline constexpr last_spec last{}; // C++20 761inline constexpr chrono::weekday Sunday{0}; // C++20 762inline constexpr chrono::weekday Monday{1}; // C++20 763inline constexpr chrono::weekday Tuesday{2}; // C++20 764inline constexpr chrono::weekday Wednesday{3}; // C++20 765inline constexpr chrono::weekday Thursday{4}; // C++20 766inline constexpr chrono::weekday Friday{5}; // C++20 767inline constexpr chrono::weekday Saturday{6}; // C++20 768 769inline constexpr chrono::month January{1}; // C++20 770inline constexpr chrono::month February{2}; // C++20 771inline constexpr chrono::month March{3}; // C++20 772inline constexpr chrono::month April{4}; // C++20 773inline constexpr chrono::month May{5}; // C++20 774inline constexpr chrono::month June{6}; // C++20 775inline constexpr chrono::month July{7}; // C++20 776inline constexpr chrono::month August{8}; // C++20 777inline constexpr chrono::month September{9}; // C++20 778inline constexpr chrono::month October{10}; // C++20 779inline constexpr chrono::month November{11}; // C++20 780inline constexpr chrono::month December{12}; // C++20 781} // chrono 782 783inline namespace literals { 784 inline namespace chrono_literals { 785constexpr chrono::hours operator ""h(unsigned long long); // C++14 786constexpr chrono::duration<unspecified , ratio<3600,1>> operator ""h(long double); // C++14 787constexpr chrono::minutes operator ""min(unsigned long long); // C++14 788constexpr chrono::duration<unspecified , ratio<60,1>> operator ""min(long double); // C++14 789constexpr chrono::seconds operator ""s(unsigned long long); // C++14 790constexpr chrono::duration<unspecified > operator ""s(long double); // C++14 791constexpr chrono::milliseconds operator ""ms(unsigned long long); // C++14 792constexpr chrono::duration<unspecified , milli> operator ""ms(long double); // C++14 793constexpr chrono::microseconds operator ""us(unsigned long long); // C++14 794constexpr chrono::duration<unspecified , micro> operator ""us(long double); // C++14 795constexpr chrono::nanoseconds operator ""ns(unsigned long long); // C++14 796constexpr chrono::duration<unspecified , nano> operator ""ns(long double); // C++14 797constexpr chrono::day operator ""d(unsigned long long d) noexcept; // C++20 798constexpr chrono::year operator ""y(unsigned long long y) noexcept; // C++20 799} // chrono_literals 800} // literals 801 802} // std 803*/ 804 805// clang-format on 806 807#include <__assert> // all public C++ headers provide the assertion handler 808#include <__chrono/calendar.h> 809#include <__chrono/convert_to_timespec.h> 810#include <__chrono/convert_to_tm.h> 811#include <__chrono/day.h> 812#include <__chrono/duration.h> 813#include <__chrono/file_clock.h> 814#include <__chrono/hh_mm_ss.h> 815#include <__chrono/high_resolution_clock.h> 816#include <__chrono/literals.h> 817#include <__chrono/month.h> 818#include <__chrono/month_weekday.h> 819#include <__chrono/monthday.h> 820#include <__chrono/steady_clock.h> 821#include <__chrono/system_clock.h> 822#include <__chrono/time_point.h> 823#include <__chrono/weekday.h> 824#include <__chrono/year.h> 825#include <__chrono/year_month.h> 826#include <__chrono/year_month_day.h> 827#include <__chrono/year_month_weekday.h> 828#include <__config> 829#include <version> 830 831// standard-mandated includes 832 833// [time.syn] 834#include <compare> 835 836#if !defined(_LIBCPP_HAS_NO_LOCALIZATION) && _LIBCPP_STD_VER >= 20 837# include <__chrono/formatter.h> 838# include <__chrono/ostream.h> 839# include <__chrono/parser_std_format_spec.h> 840# include <__chrono/statically_widen.h> 841#endif 842 843#if !defined(_LIBCPP_HAS_NO_TIME_ZONE_DATABASE) && !defined(_LIBCPP_HAS_NO_FILESYSTEM) && \ 844 !defined(_LIBCPP_HAS_NO_LOCALIZATION) 845# include <__chrono/tzdb.h> 846# include <__chrono/tzdb_list.h> 847#endif 848 849#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 850# pragma GCC system_header 851#endif 852 853#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 854# include <bit> 855# include <concepts> 856# include <cstring> 857# include <forward_list> 858# include <string> 859#endif 860 861#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER == 20 862# include <charconv> 863#endif 864 865#endif // _LIBCPP_CHRONO 866