30#ifndef _GLIBCXX_CHRONO
31#define _GLIBCXX_CHRONO 1
33#pragma GCC system_header
37#if __cplusplus < 201103L
43#if __cplusplus >= 202002L
49# include <bits/shared_ptr.h>
53#if __cplusplus >= 202002L
59namespace std _GLIBCXX_VISIBILITY(default)
61_GLIBCXX_BEGIN_NAMESPACE_VERSION
78#if __cplusplus >= 202002L
82 template<
typename _Duration>
91 template<
typename _Duration>
95 template<
typename _Duration>
99 template<
typename _Duration>
107 template<>
inline constexpr bool is_clock_v<utc_clock> =
true;
108 template<>
inline constexpr bool is_clock_v<tai_clock> =
true;
109 template<>
inline constexpr bool is_clock_v<gps_clock> =
true;
111 struct leap_second_info
117 template<
typename _Duration>
130 using rep = system_clock::rep;
131 using period = system_clock::period;
134 static constexpr bool is_steady =
false;
139 {
return from_sys(system_clock::now()); }
141 template<
typename _Duration>
147 const auto __li = chrono::get_leap_second_info(__t);
149 if (__li.is_leap_second)
150 __s = chrono::floor<seconds>(__s) +
seconds{1} - _CDur{1};
154 template<
typename _Duration>
169 using rep = system_clock::rep;
170 using period = system_clock::period;
173 static constexpr bool is_steady =
false;
179 {
return from_utc(utc_clock::now()); }
181 template<
typename _Duration>
190 template<
typename _Duration>
209 using rep = system_clock::rep;
210 using period = system_clock::period;
213 static constexpr bool is_steady =
false;
219 {
return from_utc(utc_clock::now()); }
221 template<
typename _Duration>
230 template<
typename _Duration>
241 template<
typename _DestClock,
typename _SourceClock>
242 struct clock_time_conversion
247 template<
typename _Clock>
248 struct clock_time_conversion<_Clock, _Clock>
250 template<
typename _Duration>
251 time_point<_Clock, _Duration>
252 operator()(
const time_point<_Clock, _Duration>& __t)
const
257 struct clock_time_conversion<system_clock, system_clock>
259 template<
typename _Duration>
261 operator()(
const sys_time<_Duration>& __t)
const
266 struct clock_time_conversion<utc_clock, utc_clock>
268 template<
typename _Duration>
270 operator()(
const utc_time<_Duration>& __t)
const
277 struct clock_time_conversion<utc_clock, system_clock>
279 template<
typename _Duration>
280 utc_time<common_type_t<_Duration, seconds>>
281 operator()(
const sys_time<_Duration>& __t)
const
282 {
return utc_clock::from_sys(__t); }
286 struct clock_time_conversion<system_clock, utc_clock>
288 template<
typename _Duration>
289 sys_time<common_type_t<_Duration, seconds>>
290 operator()(
const utc_time<_Duration>& __t)
const
291 {
return utc_clock::to_sys(__t); }
294 template<
typename _Tp,
typename _Clock>
295 inline constexpr bool __is_time_point_for_v =
false;
297 template<
typename _Clock,
typename _Duration>
298 inline constexpr bool
299 __is_time_point_for_v<time_point<_Clock, _Duration>, _Clock> =
true;
303 template<
typename _SourceClock>
304 struct clock_time_conversion<system_clock, _SourceClock>
306 template<
typename _Duration,
typename _Src = _SourceClock>
308 operator()(
const time_point<_SourceClock, _Duration>& __t)
const
309 ->
decltype(_Src::to_sys(__t))
311 using _Ret =
decltype(_SourceClock::to_sys(__t));
312 static_assert(__is_time_point_for_v<_Ret, system_clock>);
313 return _SourceClock::to_sys(__t);
317 template<
typename _DestClock>
318 struct clock_time_conversion<_DestClock, system_clock>
320 template<
typename _Duration,
typename _Dest = _DestClock>
322 operator()(
const sys_time<_Duration>& __t)
const
323 ->
decltype(_Dest::from_sys(__t))
325 using _Ret =
decltype(_DestClock::from_sys(__t));
326 static_assert(__is_time_point_for_v<_Ret, _DestClock>);
327 return _DestClock::from_sys(__t);
333 template<
typename _SourceClock>
334 struct clock_time_conversion<utc_clock, _SourceClock>
336 template<
typename _Duration,
typename _Src = _SourceClock>
338 operator()(
const time_point<_SourceClock, _Duration>& __t)
const
339 ->
decltype(_Src::to_utc(__t))
341 using _Ret =
decltype(_SourceClock::to_utc(__t));
342 static_assert(__is_time_point_for_v<_Ret, utc_clock>);
343 return _SourceClock::to_utc(__t);
347 template<
typename _DestClock>
348 struct clock_time_conversion<_DestClock, utc_clock>
350 template<
typename _Duration,
typename _Dest = _DestClock>
352 operator()(
const utc_time<_Duration>& __t)
const
353 ->
decltype(_Dest::from_utc(__t))
355 using _Ret =
decltype(_DestClock::from_utc(__t));
356 static_assert(__is_time_point_for_v<_Ret, _DestClock>);
357 return _DestClock::from_utc(__t);
364 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
365 concept __clock_convs
366 =
requires (
const time_point<_SourceClock, _Duration>& __t) {
367 clock_time_conversion<_DestClock, _SourceClock>{}(__t);
370 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
371 concept __clock_convs_sys
372 =
requires (
const time_point<_SourceClock, _Duration>& __t) {
373 clock_time_conversion<_DestClock, system_clock>{}(
374 clock_time_conversion<system_clock, _SourceClock>{}(__t));
377 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
378 concept __clock_convs_utc
379 =
requires (
const time_point<_SourceClock, _Duration>& __t) {
380 clock_time_conversion<_DestClock, utc_clock>{}(
381 clock_time_conversion<utc_clock, _SourceClock>{}(__t));
384 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
385 concept __clock_convs_sys_utc
386 =
requires (
const time_point<_SourceClock, _Duration>& __t) {
387 clock_time_conversion<_DestClock, utc_clock>{}(
388 clock_time_conversion<utc_clock, system_clock>{}(
389 clock_time_conversion<system_clock, _SourceClock>{}(__t)));
392 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
393 concept __clock_convs_utc_sys
394 =
requires (
const time_point<_SourceClock, _Duration>& __t) {
395 clock_time_conversion<_DestClock, system_clock>{}(
396 clock_time_conversion<system_clock, utc_clock>{}(
397 clock_time_conversion<utc_clock, _SourceClock>{}(__t)));
404 template<
typename _DestClock,
typename _SourceClock,
typename _Duration>
408 requires __detail::__clock_convs<_DestClock, _SourceClock, _Duration>
409 || __detail::__clock_convs_sys<_DestClock, _SourceClock, _Duration>
410 || __detail::__clock_convs_utc<_DestClock, _SourceClock, _Duration>
411 || __detail::__clock_convs_sys_utc<_DestClock, _SourceClock, _Duration>
412 || __detail::__clock_convs_utc_sys<_DestClock, _SourceClock, _Duration>
414 constexpr bool __direct
415 = __detail::__clock_convs<_DestClock, _SourceClock, _Duration>;
416 if constexpr (__direct)
418 return clock_time_conversion<_DestClock, _SourceClock>{}(__t);
422 constexpr bool __convert_via_sys_clock
423 = __detail::__clock_convs_sys<_DestClock, _SourceClock, _Duration>;
424 constexpr bool __convert_via_utc_clock
425 = __detail::__clock_convs_utc<_DestClock, _SourceClock, _Duration>;
426 if constexpr (__convert_via_sys_clock)
428 static_assert(!__convert_via_utc_clock,
429 "clock_cast requires a unique best conversion, but "
430 "conversion is possible via system_clock and also via"
432 return clock_time_conversion<_DestClock, system_clock>{}(
433 clock_time_conversion<system_clock, _SourceClock>{}(__t));
435 else if constexpr (__convert_via_utc_clock)
437 return clock_time_conversion<_DestClock, utc_clock>{}(
438 clock_time_conversion<utc_clock, _SourceClock>{}(__t));
442 constexpr bool __convert_via_sys_and_utc_clocks
443 = __detail::__clock_convs_sys_utc<_DestClock,
447 if constexpr (__convert_via_sys_and_utc_clocks)
449 constexpr bool __convert_via_utc_and_sys_clocks
450 = __detail::__clock_convs_utc_sys<_DestClock,
453 static_assert(!__convert_via_utc_and_sys_clocks,
454 "clock_cast requires a unique best conversion, but "
455 "conversion is possible via system_clock followed by "
456 "utc_clock, and also via utc_clock followed by "
458 return clock_time_conversion<_DestClock, utc_clock>{}(
459 clock_time_conversion<utc_clock, system_clock>{}(
460 clock_time_conversion<system_clock, _SourceClock>{}(__t)));
464 return clock_time_conversion<_DestClock, system_clock>{}(
465 clock_time_conversion<system_clock, utc_clock>{}(
466 clock_time_conversion<utc_clock, _SourceClock>{}(__t)));
479 class weekday_indexed;
482 class month_day_last;
484 class month_weekday_last;
486 class year_month_day;
487 class year_month_day_last;
488 class year_month_weekday;
489 class year_month_weekday_last;
493 explicit last_spec() =
default;
495 friend constexpr month_day_last
498 friend constexpr month_day_last
502 inline constexpr last_spec last{};
512 __modulo(
long long __n,
unsigned __d)
517 return (__d + (__n % __d)) % __d;
520 inline constexpr unsigned __days_per_month[12]
521 = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
535 day(
unsigned __d) noexcept
540 operator++() noexcept
547 operator++(
int)
noexcept
555 operator--() noexcept
562 operator--(
int)
noexcept
570 operator+=(
const days& __d)
noexcept
577 operator-=(
const days& __d)
noexcept
584 operator unsigned() const noexcept
589 {
return 1 <= _M_d && _M_d <= 31; }
591 friend constexpr bool
592 operator==(
const day& __x,
const day& __y)
noexcept
593 {
return unsigned{__x} ==
unsigned{__y}; }
595 friend constexpr strong_ordering
596 operator<=>(
const day& __x,
const day& __y)
noexcept
597 {
return unsigned{__x} <=>
unsigned{__y}; }
601 {
return day(
unsigned{__x} + __y.count()); }
605 {
return __y + __x; }
609 {
return __x + -__y; }
611 friend constexpr days
612 operator-(
const day& __x,
const day& __y)
noexcept
613 {
return days{int(
unsigned{__x}) -
int(
unsigned{__y})}; }
615 friend constexpr month_day
616 operator/(
const month& __m,
const day& __d)
noexcept;
618 friend constexpr month_day
619 operator/(
int __m,
const day& __d)
noexcept;
621 friend constexpr month_day
622 operator/(
const day& __d,
const month& __m)
noexcept;
624 friend constexpr month_day
625 operator/(
const day& __d,
int __m)
noexcept;
627 friend constexpr year_month_day
628 operator/(
const year_month& __ym,
const day& __d)
noexcept;
642 month(
unsigned __m) noexcept
647 operator++() noexcept
654 operator++(
int)
noexcept
662 operator--() noexcept
669 operator--(
int)
noexcept
677 operator+=(
const months& __m)
noexcept
684 operator-=(
const months& __m)
noexcept
691 operator unsigned() const noexcept
696 {
return 1 <= _M_m && _M_m <= 12; }
698 friend constexpr bool
699 operator==(
const month& __x,
const month& __y)
noexcept
700 {
return unsigned{__x} ==
unsigned{__y}; }
702 friend constexpr strong_ordering
703 operator<=>(
const month& __x,
const month& __y)
noexcept
704 {
return unsigned{__x} <=>
unsigned{__y}; }
706 friend constexpr month
709 auto __n =
static_cast<long long>(
unsigned{__x}) + (__y.count() - 1);
710 return month{__detail::__modulo(__n, 12) + 1};
713 friend constexpr month
715 {
return __y + __x; }
717 friend constexpr month
719 {
return __x + -__y; }
722 operator-(
const month& __x,
const month& __y)
noexcept
724 const auto __dm = int(
unsigned(__x)) - int(
unsigned(__y));
725 return months{__dm < 0 ? 12 + __dm : __dm};
728 friend constexpr year_month
729 operator/(
const year& __y,
const month& __m)
noexcept;
731 friend constexpr month_day
732 operator/(
const month& __m,
int __d)
noexcept;
734 friend constexpr month_day_last
735 operator/(
const month& __m, last_spec)
noexcept;
737 friend constexpr month_day_last
738 operator/(last_spec,
const month& __m)
noexcept;
740 friend constexpr month_weekday
741 operator/(
const month& __m,
const weekday_indexed& __wdi)
noexcept;
743 friend constexpr month_weekday
744 operator/(
const weekday_indexed& __wdi,
const month& __m)
noexcept;
746 friend constexpr month_weekday_last
747 operator/(
const month& __m,
const weekday_last& __wdl)
noexcept;
749 friend constexpr month_weekday_last
750 operator/(
const weekday_last& __wdl,
const month& __m)
noexcept;
753 inline constexpr month January{1};
754 inline constexpr month February{2};
755 inline constexpr month March{3};
756 inline constexpr month April{4};
757 inline constexpr month May{5};
758 inline constexpr month June{6};
759 inline constexpr month July{7};
760 inline constexpr month August{8};
761 inline constexpr month September{9};
762 inline constexpr month October{10};
763 inline constexpr month November{11};
764 inline constexpr month December{12};
777 year(
int __y) noexcept
778 : _M_y{
static_cast<short>(__y)}
781 static constexpr year
783 {
return year{-32767}; }
785 static constexpr year
787 {
return year{32767}; }
790 operator++() noexcept
797 operator++(
int)
noexcept
805 operator--() noexcept
812 operator--(
int)
noexcept
820 operator+=(
const years& __y)
noexcept
827 operator-=(
const years& __y)
noexcept
839 {
return year{-_M_y}; }
842 is_leap() const noexcept
860 constexpr uint32_t __multiplier = 42949673;
861 constexpr uint32_t __bound = 42949669;
862 constexpr uint32_t __max_dividend = 1073741799;
863 constexpr uint32_t __offset = __max_dividend / 2 / 100 * 100;
864 const bool __is_multiple_of_100
865 = __multiplier * (_M_y + __offset) < __bound;
866 return (_M_y & (__is_multiple_of_100 ? 15 : 3)) == 0;
870 operator int() const noexcept
875 {
return min()._M_y <= _M_y && _M_y <=
max()._M_y; }
877 friend constexpr bool
878 operator==(
const year& __x,
const year& __y)
noexcept
879 {
return int{__x} ==
int{__y}; }
881 friend constexpr strong_ordering
882 operator<=>(
const year& __x,
const year& __y)
noexcept
883 {
return int{__x} <=>
int{__y}; }
885 friend constexpr year
887 {
return year{
int{__x} +
static_cast<int>(__y.count())}; }
889 friend constexpr year
891 {
return __y + __x; }
893 friend constexpr year
895 {
return __x + -__y; }
897 friend constexpr years
898 operator-(
const year& __x,
const year& __y)
noexcept
899 {
return years{
int{__x} -
int{__y}}; }
901 friend constexpr year_month
902 operator/(
const year& __y,
int __m)
noexcept;
904 friend constexpr year_month_day
905 operator/(
const year& __y,
const month_day& __md)
noexcept;
907 friend constexpr year_month_day
908 operator/(
const month_day& __md,
const year& __y)
noexcept;
910 friend constexpr year_month_day_last
911 operator/(
const year& __y,
const month_day_last& __mdl)
noexcept;
913 friend constexpr year_month_day_last
914 operator/(
const month_day_last& __mdl,
const year& __y)
noexcept;
916 friend constexpr year_month_weekday
917 operator/(
const year& __y,
const month_weekday& __mwd)
noexcept;
919 friend constexpr year_month_weekday
920 operator/(
const month_weekday& __mwd,
const year& __y)
noexcept;
922 friend constexpr year_month_weekday_last
923 operator/(
const year& __y,
const month_weekday_last& __mwdl)
noexcept;
925 friend constexpr year_month_weekday_last
926 operator/(
const month_weekday_last& __mwdl,
const year& __y)
noexcept;
936 static constexpr weekday
937 _S_from_days(
const days& __d)
939 auto __n = __d.count();
940 return weekday(__n >= -4 ? (__n + 4) % 7 : (__n + 5) % 7 + 6);
947 weekday(
unsigned __wd) noexcept
948 : _M_wd(__wd == 7 ? 0 : __wd)
952 weekday(
const sys_days& __dp) noexcept
953 : weekday{_S_from_days(__dp.time_since_epoch())}
957 weekday(
const local_days& __dp) noexcept
958 : weekday{sys_days{__dp.time_since_epoch()}}
962 operator++() noexcept
969 operator++(
int)
noexcept
977 operator--() noexcept
984 operator--(
int)
noexcept
992 operator+=(
const days& __d)
noexcept
999 operator-=(
const days& __d)
noexcept
1001 *
this = *
this - __d;
1006 c_encoding() const noexcept
1010 iso_encoding() const noexcept
1011 {
return _M_wd == 0u ? 7u : _M_wd; }
1015 {
return _M_wd <= 6; }
1017 constexpr weekday_indexed
1018 operator[](
unsigned __index)
const noexcept;
1020 constexpr weekday_last
1021 operator[](last_spec)
const noexcept;
1023 friend constexpr bool
1024 operator==(
const weekday& __x,
const weekday& __y)
noexcept
1025 {
return __x._M_wd == __y._M_wd; }
1027 friend constexpr weekday
1030 auto __n =
static_cast<long long>(__x._M_wd) + __y.count();
1031 return weekday{__detail::__modulo(__n, 7)};
1034 friend constexpr weekday
1036 {
return __y + __x; }
1038 friend constexpr weekday
1040 {
return __x + -__y; }
1042 friend constexpr days
1043 operator-(
const weekday& __x,
const weekday& __y)
noexcept
1045 auto __n =
static_cast<long long>(__x._M_wd) - __y._M_wd;
1046 return days{__detail::__modulo(__n, 7)};
1050 inline constexpr weekday Sunday{0};
1051 inline constexpr weekday Monday{1};
1052 inline constexpr weekday Tuesday{2};
1053 inline constexpr weekday Wednesday{3};
1054 inline constexpr weekday Thursday{4};
1055 inline constexpr weekday Friday{5};
1056 inline constexpr weekday Saturday{6};
1060 class weekday_indexed
1063 chrono::weekday _M_wd;
1064 unsigned char _M_index;
1067 weekday_indexed() =
default;
1070 weekday_indexed(
const chrono::weekday& __wd,
unsigned __index) noexcept
1071 : _M_wd(__wd), _M_index(__index)
1074 constexpr chrono::weekday
1075 weekday() const noexcept
1079 index() const noexcept
1080 {
return _M_index; };
1084 {
return _M_wd.ok() && 1 <= _M_index && _M_index <= 5; }
1086 friend constexpr bool
1087 operator==(
const weekday_indexed& __x,
const weekday_indexed& __y)
noexcept
1088 {
return __x.weekday() == __y.weekday() && __x.index() == __y.index(); }
1090 friend constexpr month_weekday
1091 operator/(
const month& __m,
const weekday_indexed& __wdi)
noexcept;
1093 friend constexpr month_weekday
1094 operator/(
int __m,
const weekday_indexed& __wdi)
noexcept;
1096 friend constexpr month_weekday
1097 operator/(
const weekday_indexed& __wdi,
const month& __m)
noexcept;
1099 friend constexpr month_weekday
1100 operator/(
const weekday_indexed& __wdi,
int __m)
noexcept;
1102 friend constexpr year_month_weekday
1103 operator/(
const year_month& __ym,
const weekday_indexed& __wdi)
noexcept;
1106 constexpr weekday_indexed
1107 weekday::operator[](
unsigned __index)
const noexcept
1108 {
return {*
this, __index}; }
1115 chrono::weekday _M_wd;
1119 weekday_last(
const chrono::weekday& __wd) noexcept
1123 constexpr chrono::weekday
1124 weekday() const noexcept
1129 {
return _M_wd.ok(); }
1131 friend constexpr bool
1132 operator==(
const weekday_last& __x,
const weekday_last& __y)
noexcept
1133 {
return __x.weekday() == __y.weekday(); }
1135 friend constexpr month_weekday_last
1136 operator/(
int __m,
const weekday_last& __wdl)
noexcept;
1138 friend constexpr month_weekday_last
1139 operator/(
const weekday_last& __wdl,
int __m)
noexcept;
1141 friend constexpr year_month_weekday_last
1142 operator/(
const year_month& __ym,
const weekday_last& __wdl)
noexcept;
1145 constexpr weekday_last
1146 weekday::operator[](last_spec)
const noexcept
1147 {
return weekday_last{*
this}; }
1158 month_day() =
default;
1161 month_day(
const chrono::month& __m,
const chrono::day& __d) noexcept
1162 : _M_m{__m}, _M_d{__d}
1165 constexpr chrono::month
1166 month() const noexcept
1169 constexpr chrono::day
1170 day() const noexcept
1177 && 1u <= unsigned(_M_d)
1178 && unsigned(_M_d) <= __detail::__days_per_month[unsigned(_M_m) - 1];
1181 friend constexpr bool
1182 operator==(
const month_day& __x,
const month_day& __y)
noexcept
1183 {
return __x.month() == __y.month() && __x.day() == __y.day(); }
1185 friend constexpr strong_ordering
1186 operator<=>(
const month_day& __x,
const month_day& __y)
noexcept
1189 friend constexpr month_day
1190 operator/(
const chrono::month& __m,
const chrono::day& __d)
noexcept
1191 {
return {__m, __d}; }
1193 friend constexpr month_day
1194 operator/(
const chrono::month& __m,
int __d)
noexcept
1195 {
return {__m, chrono::day(
unsigned(__d))}; }
1197 friend constexpr month_day
1198 operator/(
int __m,
const chrono::day& __d)
noexcept
1199 {
return {chrono::month(
unsigned(__m)), __d}; }
1201 friend constexpr month_day
1202 operator/(
const chrono::day& __d,
const chrono::month& __m)
noexcept
1203 {
return {__m, __d}; }
1205 friend constexpr month_day
1206 operator/(
const chrono::day& __d,
int __m)
noexcept
1207 {
return {chrono::month(
unsigned(__m)), __d}; }
1209 friend constexpr year_month_day
1210 operator/(
int __y,
const month_day& __md)
noexcept;
1212 friend constexpr year_month_day
1213 operator/(
const month_day& __md,
int __y)
noexcept;
1218 class month_day_last
1225 month_day_last(
const chrono::month& __m) noexcept
1229 constexpr chrono::month
1230 month() const noexcept
1235 {
return _M_m.ok(); }
1237 friend constexpr bool
1238 operator==(
const month_day_last& __x,
const month_day_last& __y)
noexcept
1239 {
return __x.month() == __y.month(); }
1241 friend constexpr strong_ordering
1242 operator<=>(
const month_day_last& __x,
const month_day_last& __y)
noexcept
1245 friend constexpr month_day_last
1246 operator/(
const chrono::month& __m, last_spec)
noexcept
1247 {
return month_day_last{__m}; }
1249 friend constexpr month_day_last
1251 {
return chrono::month(
unsigned(__m)) / last; }
1253 friend constexpr month_day_last
1254 operator/(last_spec,
const chrono::month& __m)
noexcept
1255 {
return __m / last; }
1257 friend constexpr month_day_last
1259 {
return __m / last; }
1261 friend constexpr year_month_day_last
1262 operator/(
int __y,
const month_day_last& __mdl)
noexcept;
1264 friend constexpr year_month_day_last
1265 operator/(
const month_day_last& __mdl,
int __y)
noexcept;
1274 chrono::weekday_indexed _M_wdi;
1278 month_weekday(
const chrono::month& __m,
1279 const chrono::weekday_indexed& __wdi) noexcept
1280 : _M_m{__m}, _M_wdi{__wdi}
1283 constexpr chrono::month
1284 month() const noexcept
1287 constexpr chrono::weekday_indexed
1288 weekday_indexed() const noexcept
1293 {
return _M_m.ok() && _M_wdi.ok(); }
1295 friend constexpr bool
1296 operator==(
const month_weekday& __x,
const month_weekday& __y)
noexcept
1298 return __x.month() == __y.month()
1299 && __x.weekday_indexed() == __y.weekday_indexed();
1302 friend constexpr month_weekday
1304 const chrono::weekday_indexed& __wdi)
noexcept
1305 {
return {__m, __wdi}; }
1307 friend constexpr month_weekday
1308 operator/(
int __m,
const chrono::weekday_indexed& __wdi)
noexcept
1309 {
return chrono::month(
unsigned(__m)) / __wdi; }
1311 friend constexpr month_weekday
1312 operator/(
const chrono::weekday_indexed& __wdi,
1313 const chrono::month& __m)
noexcept
1314 {
return __m / __wdi; }
1316 friend constexpr month_weekday
1317 operator/(
const chrono::weekday_indexed& __wdi,
int __m)
noexcept
1318 {
return __m / __wdi; }
1320 friend constexpr year_month_weekday
1321 operator/(
int __y,
const month_weekday& __mwd)
noexcept;
1323 friend constexpr year_month_weekday
1324 operator/(
const month_weekday& __mwd,
int __y)
noexcept;
1329 class month_weekday_last
1333 chrono::weekday_last _M_wdl;
1337 month_weekday_last(
const chrono::month& __m,
1338 const chrono::weekday_last& __wdl) noexcept
1339 :_M_m{__m}, _M_wdl{__wdl}
1342 constexpr chrono::month
1343 month() const noexcept
1346 constexpr chrono::weekday_last
1347 weekday_last() const noexcept
1352 {
return _M_m.ok() && _M_wdl.ok(); }
1354 friend constexpr bool
1355 operator==(
const month_weekday_last& __x,
1356 const month_weekday_last& __y)
noexcept
1358 return __x.month() == __y.month()
1359 && __x.weekday_last() == __y.weekday_last();
1362 friend constexpr month_weekday_last
1364 const chrono::weekday_last& __wdl)
noexcept
1365 {
return {__m, __wdl}; }
1367 friend constexpr month_weekday_last
1368 operator/(
int __m,
const chrono::weekday_last& __wdl)
noexcept
1369 {
return chrono::month(
unsigned(__m)) / __wdl; }
1371 friend constexpr month_weekday_last
1372 operator/(
const chrono::weekday_last& __wdl,
1373 const chrono::month& __m)
noexcept
1374 {
return __m / __wdl; }
1376 friend constexpr month_weekday_last
1377 operator/(
const chrono::weekday_last& __wdl,
int __m)
noexcept
1378 {
return chrono::month(
unsigned(__m)) / __wdl; }
1380 friend constexpr year_month_weekday_last
1381 operator/(
int __y,
const month_weekday_last& __mwdl)
noexcept;
1383 friend constexpr year_month_weekday_last
1384 operator/(
const month_weekday_last& __mwdl,
int __y)
noexcept;
1403 using __months_years_conversion_disambiguator = void;
1413 year_month() =
default;
1416 year_month(
const chrono::year& __y,
const chrono::month& __m) noexcept
1417 : _M_y{__y}, _M_m{__m}
1420 constexpr chrono::year
1421 year() const noexcept
1424 constexpr chrono::month
1425 month() const noexcept
1428 template<
typename = __detail::__months_years_conversion_disambiguator>
1429 constexpr year_month&
1430 operator+=(
const months& __dm)
noexcept
1432 *
this = *
this + __dm;
1436 template<
typename = __detail::__months_years_conversion_disambiguator>
1437 constexpr year_month&
1438 operator-=(
const months& __dm)
noexcept
1440 *
this = *
this - __dm;
1444 constexpr year_month&
1445 operator+=(
const years& __dy)
noexcept
1447 *
this = *
this + __dy;
1451 constexpr year_month&
1452 operator-=(
const years& __dy)
noexcept
1454 *
this = *
this - __dy;
1460 {
return _M_y.ok() && _M_m.ok(); }
1462 friend constexpr bool
1463 operator==(
const year_month& __x,
const year_month& __y)
noexcept
1464 {
return __x.year() == __y.year() && __x.month() == __y.month(); }
1466 friend constexpr strong_ordering
1467 operator<=>(
const year_month& __x,
const year_month& __y)
noexcept
1470 template<
typename = __detail::__months_years_conversion_disambiguator>
1471 friend constexpr year_month
1475 auto __m = __ym.month() + __dm;
1476 auto __i = int(
unsigned(__ym.month())) - 1 + __dm.count();
1478 ? __ym.year() +
years{(__i - 11) / 12}
1479 : __ym.year() +
years{__i / 12});
1483 template<
typename = __detail::__months_years_conversion_disambiguator>
1484 friend constexpr year_month
1486 {
return __ym + __dm; }
1488 template<
typename = __detail::__months_years_conversion_disambiguator>
1489 friend constexpr year_month
1491 {
return __ym + -__dm; }
1494 operator-(
const year_month& __x,
const year_month& __y)
noexcept
1496 return (__x.year() - __y.year()
1497 +
months{static_cast<int>(unsigned{__x.month()})
1498 -
static_cast<int>(
unsigned{__y.month()})});
1501 friend constexpr year_month
1503 {
return (__ym.year() + __dy) / __ym.month(); }
1505 friend constexpr year_month
1507 {
return __ym + __dy; }
1509 friend constexpr year_month
1511 {
return __ym + -__dy; }
1513 friend constexpr year_month
1514 operator/(
const chrono::year& __y,
const chrono::month& __m)
noexcept
1515 {
return {__y, __m}; }
1517 friend constexpr year_month
1518 operator/(
const chrono::year& __y,
int __m)
noexcept
1519 {
return {__y, chrono::month(
unsigned(__m))}; }
1521 friend constexpr year_month_day
1522 operator/(
const year_month& __ym,
int __d)
noexcept;
1524 friend constexpr year_month_day_last
1525 operator/(
const year_month& __ym, last_spec)
noexcept;
1530 class year_month_day
1537 static constexpr year_month_day _S_from_days(
const days& __dp)
noexcept;
1539 constexpr days _M_days_since_epoch() const noexcept;
1542 year_month_day() = default;
1545 year_month_day(const chrono::year& __y, const chrono::month& __m,
1546 const chrono::day& __d) noexcept
1547 : _M_y{__y}, _M_m{__m}, _M_d{__d}
1551 year_month_day(
const year_month_day_last& __ymdl)
noexcept;
1554 year_month_day(
const sys_days& __dp) noexcept
1555 : year_month_day(_S_from_days(__dp.time_since_epoch()))
1559 year_month_day(
const local_days& __dp) noexcept
1560 : year_month_day(sys_days{__dp.time_since_epoch()})
1563 template<
typename = __detail::__months_years_conversion_disambiguator>
1564 constexpr year_month_day&
1565 operator+=(
const months& __m)
noexcept
1567 *
this = *
this + __m;
1571 template<
typename = __detail::__months_years_conversion_disambiguator>
1572 constexpr year_month_day&
1573 operator-=(
const months& __m)
noexcept
1575 *
this = *
this - __m;
1579 constexpr year_month_day&
1580 operator+=(
const years& __y)
noexcept
1582 *
this = *
this + __y;
1586 constexpr year_month_day&
1587 operator-=(
const years& __y)
noexcept
1589 *
this = *
this - __y;
1593 constexpr chrono::year
1594 year() const noexcept
1597 constexpr chrono::month
1598 month() const noexcept
1601 constexpr chrono::day
1602 day() const noexcept
1606 operator sys_days() const noexcept
1607 {
return sys_days{_M_days_since_epoch()}; }
1610 operator local_days() const noexcept
1611 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
1613 constexpr bool ok() const noexcept;
1615 friend constexpr
bool
1616 operator==(const year_month_day& __x, const year_month_day& __y) noexcept
1618 return __x.year() == __y.year()
1619 && __x.month() == __y.month()
1620 && __x.day() == __y.day();
1623 friend constexpr strong_ordering
1624 operator<=>(
const year_month_day& __x,
const year_month_day& __y)
noexcept
1627 template<
typename = __detail::__months_years_conversion_disambiguator>
1628 friend constexpr year_month_day
1630 {
return (__ymd.year() / __ymd.month() + __dm) / __ymd.day(); }
1632 template<
typename = __detail::__months_years_conversion_disambiguator>
1633 friend constexpr year_month_day
1635 {
return __ymd + __dm; }
1637 friend constexpr year_month_day
1638 operator+(
const year_month_day& __ymd,
const years& __dy)
noexcept
1639 {
return (__ymd.year() + __dy) / __ymd.month() / __ymd.day(); }
1641 friend constexpr year_month_day
1642 operator+(
const years& __dy,
const year_month_day& __ymd)
noexcept
1643 {
return __ymd + __dy; }
1645 template<
typename = __detail::__months_years_conversion_disambiguator>
1646 friend constexpr year_month_day
1648 {
return __ymd + -__dm; }
1650 friend constexpr year_month_day
1651 operator-(
const year_month_day& __ymd,
const years& __dy)
noexcept
1652 {
return __ymd + -__dy; }
1654 friend constexpr year_month_day
1655 operator/(
const year_month& __ym,
const chrono::day& __d)
noexcept
1656 {
return {__ym.year(), __ym.month(), __d}; }
1658 friend constexpr year_month_day
1659 operator/(
const year_month& __ym,
int __d)
noexcept
1660 {
return __ym / chrono::day{unsigned(__d)}; }
1662 friend constexpr year_month_day
1663 operator/(
const chrono::year& __y,
const month_day& __md)
noexcept
1664 {
return __y / __md.month() / __md.day(); }
1666 friend constexpr year_month_day
1667 operator/(
int __y,
const month_day& __md)
noexcept
1668 {
return chrono::year{__y} / __md; }
1670 friend constexpr year_month_day
1671 operator/(
const month_day& __md,
const chrono::year& __y)
noexcept
1672 {
return __y / __md; }
1674 friend constexpr year_month_day
1675 operator/(
const month_day& __md,
int __y)
noexcept
1676 {
return chrono::year(__y) / __md; }
1683 constexpr year_month_day
1684 year_month_day::_S_from_days(
const days& __dp)
noexcept
1686 constexpr auto __z2 =
static_cast<uint32_t
>(-1468000);
1687 constexpr auto __r2_e3 =
static_cast<uint32_t
>(536895458);
1689 const auto __r0 =
static_cast<uint32_t
>(__dp.count()) + __r2_e3;
1691 const auto __n1 = 4 * __r0 + 3;
1692 const auto __q1 = __n1 / 146097;
1693 const auto __r1 = __n1 % 146097 / 4;
1695 constexpr auto __p32 =
static_cast<uint64_t
>(1) << 32;
1696 const auto __n2 = 4 * __r1 + 3;
1697 const auto __u2 =
static_cast<uint64_t
>(2939745) * __n2;
1698 const auto __q2 =
static_cast<uint32_t
>(__u2 / __p32);
1699 const auto __r2 =
static_cast<uint32_t
>(__u2 % __p32) / 2939745 / 4;
1701 constexpr auto __p16 =
static_cast<uint32_t
>(1) << 16;
1702 const auto __n3 = 2141 * __r2 + 197913;
1703 const auto __q3 = __n3 / __p16;
1704 const auto __r3 = __n3 % __p16 / 2141;
1706 const auto __y0 = 100 * __q1 + __q2;
1707 const auto __m0 = __q3;
1708 const auto __d0 = __r3;
1710 const auto __j = __r2 >= 306;
1711 const auto __y1 = __y0 + __j;
1712 const auto __m1 = __j ? __m0 - 12 : __m0;
1713 const auto __d1 = __d0 + 1;
1715 return year_month_day{chrono::year{
static_cast<int>(__y1 + __z2)},
1716 chrono::month{__m1}, chrono::day{__d1}};
1724 year_month_day::_M_days_since_epoch() const noexcept
1726 auto constexpr __z2 =
static_cast<uint32_t
>(-1468000);
1727 auto constexpr __r2_e3 =
static_cast<uint32_t
>(536895458);
1729 const auto __y1 =
static_cast<uint32_t
>(
static_cast<int>(_M_y)) - __z2;
1730 const auto __m1 =
static_cast<uint32_t
>(
static_cast<unsigned>(_M_m));
1731 const auto __d1 =
static_cast<uint32_t
>(
static_cast<unsigned>(_M_d));
1733 const auto __j =
static_cast<uint32_t
>(__m1 < 3);
1734 const auto __y0 = __y1 - __j;
1735 const auto __m0 = __j ? __m1 + 12 : __m1;
1736 const auto __d0 = __d1 - 1;
1738 const auto __q1 = __y0 / 100;
1739 const auto __yc = 1461 * __y0 / 4 - __q1 + __q1 / 4;
1740 const auto __mc = (979 *__m0 - 2919) / 32;
1741 const auto __dc = __d0;
1743 return days{
static_cast<int32_t
>(__yc + __mc + __dc - __r2_e3)};
1748 class year_month_day_last
1752 chrono::month_day_last _M_mdl;
1756 year_month_day_last(
const chrono::year& __y,
1757 const chrono::month_day_last& __mdl) noexcept
1758 : _M_y{__y}, _M_mdl{__mdl}
1761 template<
typename = __detail::__months_years_conversion_disambiguator>
1762 constexpr year_month_day_last&
1763 operator+=(
const months& __m)
noexcept
1765 *
this = *
this + __m;
1769 template<
typename = __detail::__months_years_conversion_disambiguator>
1770 constexpr year_month_day_last&
1771 operator-=(
const months& __m)
noexcept
1773 *
this = *
this - __m;
1777 constexpr year_month_day_last&
1778 operator+=(
const years& __y)
noexcept
1780 *
this = *
this + __y;
1784 constexpr year_month_day_last&
1785 operator-=(
const years& __y)
noexcept
1787 *
this = *
this - __y;
1791 constexpr chrono::year
1792 year() const noexcept
1795 constexpr chrono::month
1796 month() const noexcept
1797 {
return _M_mdl.month(); }
1799 constexpr chrono::month_day_last
1800 month_day_last() const noexcept
1804 constexpr chrono::day
1805 day() const noexcept
1807 const auto __m =
static_cast<unsigned>(month());
1823 return chrono::day{__m != 2 ? ((__m ^ (__m >> 3)) & 1) | 30
1824 : _M_y.is_leap() ? 29 : 28};
1828 operator sys_days() const noexcept
1829 {
return sys_days{year() / month() / day()}; }
1832 operator local_days() const noexcept
1833 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
1837 {
return _M_y.ok() && _M_mdl.ok(); }
1839 friend constexpr bool
1840 operator==(
const year_month_day_last& __x,
1841 const year_month_day_last& __y)
noexcept
1843 return __x.year() == __y.year()
1844 && __x.month_day_last() == __y.month_day_last();
1847 friend constexpr strong_ordering
1848 operator<=>(
const year_month_day_last& __x,
1849 const year_month_day_last& __y)
noexcept
1852 template<
typename = __detail::__months_years_conversion_disambiguator>
1853 friend constexpr year_month_day_last
1854 operator+(
const year_month_day_last& __ymdl,
1855 const months& __dm)
noexcept
1856 {
return (__ymdl.year() / __ymdl.month() + __dm) / last; }
1858 template<
typename = __detail::__months_years_conversion_disambiguator>
1859 friend constexpr year_month_day_last
1861 const year_month_day_last& __ymdl)
noexcept
1862 {
return __ymdl + __dm; }
1864 template<
typename = __detail::__months_years_conversion_disambiguator>
1865 friend constexpr year_month_day_last
1866 operator-(
const year_month_day_last& __ymdl,
1867 const months& __dm)
noexcept
1868 {
return __ymdl + -__dm; }
1870 friend constexpr year_month_day_last
1871 operator+(
const year_month_day_last& __ymdl,
1872 const years& __dy)
noexcept
1873 {
return {__ymdl.year() + __dy, __ymdl.month_day_last()}; }
1875 friend constexpr year_month_day_last
1877 const year_month_day_last& __ymdl)
noexcept
1878 {
return __ymdl + __dy; }
1880 friend constexpr year_month_day_last
1881 operator-(
const year_month_day_last& __ymdl,
1882 const years& __dy)
noexcept
1883 {
return __ymdl + -__dy; }
1885 friend constexpr year_month_day_last
1886 operator/(
const year_month& __ym, last_spec)
noexcept
1887 {
return {__ym.year(), chrono::month_day_last{__ym.month()}}; }
1889 friend constexpr year_month_day_last
1891 const chrono::month_day_last& __mdl)
noexcept
1892 {
return {__y, __mdl}; }
1894 friend constexpr year_month_day_last
1895 operator/(
int __y,
const chrono::month_day_last& __mdl)
noexcept
1896 {
return chrono::year(__y) / __mdl; }
1898 friend constexpr year_month_day_last
1899 operator/(
const chrono::month_day_last& __mdl,
1900 const chrono::year& __y)
noexcept
1901 {
return __y / __mdl; }
1903 friend constexpr year_month_day_last
1904 operator/(
const chrono::month_day_last& __mdl,
int __y)
noexcept
1905 {
return chrono::year(__y) / __mdl; }
1910 year_month_day::year_month_day(
const year_month_day_last& __ymdl) noexcept
1911 : _M_y{__ymdl.year()}, _M_m{__ymdl.month()}, _M_d{__ymdl.day()}
1915 year_month_day::ok() const noexcept
1917 if (!_M_y.ok() || !_M_m.ok())
1919 return chrono::day{1} <= _M_d && _M_d <= (_M_y / _M_m / last).day();
1924 class year_month_weekday
1929 chrono::weekday_indexed _M_wdi;
1931 static constexpr year_month_weekday
1932 _S_from_sys_days(
const sys_days& __dp)
1934 year_month_day __ymd{__dp};
1935 chrono::weekday __wd{__dp};
1936 auto __index = __wd[(
unsigned{__ymd.day()} - 1) / 7 + 1];
1937 return {__ymd.year(), __ymd.month(), __index};
1941 year_month_weekday() =
default;
1944 year_month_weekday(
const chrono::year& __y,
const chrono::month& __m,
1945 const chrono::weekday_indexed& __wdi) noexcept
1946 : _M_y{__y}, _M_m{__m}, _M_wdi{__wdi}
1950 year_month_weekday(
const sys_days& __dp) noexcept
1951 : year_month_weekday{_S_from_sys_days(__dp)}
1955 year_month_weekday(
const local_days& __dp) noexcept
1956 : year_month_weekday{sys_days{__dp.time_since_epoch()}}
1959 template<
typename = __detail::__months_years_conversion_disambiguator>
1960 constexpr year_month_weekday&
1961 operator+=(
const months& __m)
noexcept
1963 *
this = *
this + __m;
1967 template<
typename = __detail::__months_years_conversion_disambiguator>
1968 constexpr year_month_weekday&
1969 operator-=(
const months& __m)
noexcept
1971 *
this = *
this - __m;
1975 constexpr year_month_weekday&
1976 operator+=(
const years& __y)
noexcept
1978 *
this = *
this + __y;
1982 constexpr year_month_weekday&
1983 operator-=(
const years& __y)
noexcept
1985 *
this = *
this - __y;
1989 constexpr chrono::year
1990 year() const noexcept
1993 constexpr chrono::month
1994 month() const noexcept
1997 constexpr chrono::weekday
1998 weekday() const noexcept
1999 {
return _M_wdi.weekday(); }
2002 index() const noexcept
2003 {
return _M_wdi.index(); }
2005 constexpr chrono::weekday_indexed
2006 weekday_indexed() const noexcept
2010 operator sys_days() const noexcept
2012 auto __d = sys_days{year() / month() / 1};
2013 return __d + (weekday() - chrono::weekday(__d)
2014 +
days{(
static_cast<int>(index())-1)*7});
2018 operator local_days() const noexcept
2019 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2024 if (!_M_y.ok() || !_M_m.ok() || !_M_wdi.ok())
2026 if (_M_wdi.index() <= 4)
2028 days __d = (_M_wdi.weekday()
2029 - chrono::weekday{sys_days{_M_y / _M_m / 1}}
2030 +
days((_M_wdi.index()-1)*7 + 1));
2031 __glibcxx_assert(__d.count() >= 1);
2032 return (
unsigned)__d.count() <= (unsigned)(_M_y / _M_m / last).day();
2035 friend constexpr bool
2036 operator==(
const year_month_weekday& __x,
2037 const year_month_weekday& __y)
noexcept
2039 return __x.year() == __y.year()
2040 && __x.month() == __y.month()
2041 && __x.weekday_indexed() == __y.weekday_indexed();
2044 template<
typename = __detail::__months_years_conversion_disambiguator>
2045 friend constexpr year_month_weekday
2046 operator+(
const year_month_weekday& __ymwd,
const months& __dm)
noexcept
2048 return ((__ymwd.year() / __ymwd.month() + __dm)
2049 / __ymwd.weekday_indexed());
2052 template<
typename = __detail::__months_years_conversion_disambiguator>
2053 friend constexpr year_month_weekday
2054 operator+(
const months& __dm,
const year_month_weekday& __ymwd)
noexcept
2055 {
return __ymwd + __dm; }
2057 friend constexpr year_month_weekday
2058 operator+(
const year_month_weekday& __ymwd,
const years& __dy)
noexcept
2059 {
return {__ymwd.year() + __dy, __ymwd.month(), __ymwd.weekday_indexed()}; }
2061 friend constexpr year_month_weekday
2062 operator+(
const years& __dy,
const year_month_weekday& __ymwd)
noexcept
2063 {
return __ymwd + __dy; }
2065 template<
typename = __detail::__months_years_conversion_disambiguator>
2066 friend constexpr year_month_weekday
2067 operator-(
const year_month_weekday& __ymwd,
const months& __dm)
noexcept
2068 {
return __ymwd + -__dm; }
2070 friend constexpr year_month_weekday
2071 operator-(
const year_month_weekday& __ymwd,
const years& __dy)
noexcept
2072 {
return __ymwd + -__dy; }
2074 friend constexpr year_month_weekday
2076 const chrono::weekday_indexed& __wdi)
noexcept
2077 {
return {__ym.year(), __ym.month(), __wdi}; }
2079 friend constexpr year_month_weekday
2080 operator/(
const chrono::year& __y,
const month_weekday& __mwd)
noexcept
2081 {
return {__y, __mwd.month(), __mwd.weekday_indexed()}; }
2083 friend constexpr year_month_weekday
2084 operator/(
int __y,
const month_weekday& __mwd)
noexcept
2085 {
return chrono::year(__y) / __mwd; }
2087 friend constexpr year_month_weekday
2088 operator/(
const month_weekday& __mwd,
const chrono::year& __y)
noexcept
2089 {
return __y / __mwd; }
2091 friend constexpr year_month_weekday
2092 operator/(
const month_weekday& __mwd,
int __y)
noexcept
2093 {
return chrono::year(__y) / __mwd; }
2098 class year_month_weekday_last
2103 chrono::weekday_last _M_wdl;
2107 year_month_weekday_last(
const chrono::year& __y,
const chrono::month& __m,
2108 const chrono::weekday_last& __wdl) noexcept
2109 : _M_y{__y}, _M_m{__m}, _M_wdl{__wdl}
2112 template<
typename = __detail::__months_years_conversion_disambiguator>
2113 constexpr year_month_weekday_last&
2114 operator+=(
const months& __m)
noexcept
2116 *
this = *
this + __m;
2120 template<
typename = __detail::__months_years_conversion_disambiguator>
2121 constexpr year_month_weekday_last&
2122 operator-=(
const months& __m)
noexcept
2124 *
this = *
this - __m;
2128 constexpr year_month_weekday_last&
2129 operator+=(
const years& __y)
noexcept
2131 *
this = *
this + __y;
2135 constexpr year_month_weekday_last&
2136 operator-=(
const years& __y)
noexcept
2138 *
this = *
this - __y;
2142 constexpr chrono::year
2143 year() const noexcept
2146 constexpr chrono::month
2147 month() const noexcept
2150 constexpr chrono::weekday
2151 weekday() const noexcept
2152 {
return _M_wdl.weekday(); }
2154 constexpr chrono::weekday_last
2155 weekday_last() const noexcept
2159 operator sys_days() const noexcept
2161 const auto __d = sys_days{_M_y / _M_m / last};
2162 return sys_days{(__d - (chrono::weekday{__d}
2163 - _M_wdl.weekday())).time_since_epoch()};
2167 operator local_days() const noexcept
2168 {
return local_days{sys_days{*
this}.time_since_epoch()}; }
2172 {
return _M_y.ok() && _M_m.ok() && _M_wdl.ok(); }
2174 friend constexpr bool
2175 operator==(
const year_month_weekday_last& __x,
2176 const year_month_weekday_last& __y)
noexcept
2178 return __x.year() == __y.year()
2179 && __x.month() == __y.month()
2180 && __x.weekday_last() == __y.weekday_last();
2183 template<
typename = __detail::__months_years_conversion_disambiguator>
2184 friend constexpr year_month_weekday_last
2185 operator+(
const year_month_weekday_last& __ymwdl,
2186 const months& __dm)
noexcept
2188 return ((__ymwdl.year() / __ymwdl.month() + __dm)
2189 / __ymwdl.weekday_last());
2192 template<
typename = __detail::__months_years_conversion_disambiguator>
2193 friend constexpr year_month_weekday_last
2195 const year_month_weekday_last& __ymwdl)
noexcept
2196 {
return __ymwdl + __dm; }
2198 friend constexpr year_month_weekday_last
2199 operator+(
const year_month_weekday_last& __ymwdl,
2200 const years& __dy)
noexcept
2201 {
return {__ymwdl.year() + __dy, __ymwdl.month(), __ymwdl.weekday_last()}; }
2203 friend constexpr year_month_weekday_last
2205 const year_month_weekday_last& __ymwdl)
noexcept
2206 {
return __ymwdl + __dy; }
2208 template<
typename = __detail::__months_years_conversion_disambiguator>
2209 friend constexpr year_month_weekday_last
2210 operator-(
const year_month_weekday_last& __ymwdl,
2211 const months& __dm)
noexcept
2212 {
return __ymwdl + -__dm; }
2214 friend constexpr year_month_weekday_last
2215 operator-(
const year_month_weekday_last& __ymwdl,
2216 const years& __dy)
noexcept
2217 {
return __ymwdl + -__dy; }
2219 friend constexpr year_month_weekday_last
2221 const chrono::weekday_last& __wdl)
noexcept
2222 {
return {__ym.year(), __ym.month(), __wdl}; }
2224 friend constexpr year_month_weekday_last
2226 const chrono::month_weekday_last& __mwdl)
noexcept
2227 {
return {__y, __mwdl.month(), __mwdl.weekday_last()}; }
2229 friend constexpr year_month_weekday_last
2230 operator/(
int __y,
const chrono::month_weekday_last& __mwdl)
noexcept
2231 {
return chrono::year(__y) / __mwdl; }
2233 friend constexpr year_month_weekday_last
2234 operator/(
const chrono::month_weekday_last& __mwdl,
2235 const chrono::year& __y)
noexcept
2236 {
return __y / __mwdl; }
2238 friend constexpr year_month_weekday_last
2239 operator/(
const chrono::month_weekday_last& __mwdl,
int __y)
noexcept
2240 {
return chrono::year(__y) / __mwdl; }
2249 __pow10(
unsigned __n)
2257 template<
typename _Duration>
struct __utc_leap_second;
2268 template<
typename _Duration>
2271 static_assert( __is_duration<_Duration>::value );
2274 static consteval int
2275 _S_fractional_width()
2277 auto __den = _Duration::period::den;
2278 const int __multiplicity_2 = std::__countr_zero((uintmax_t)__den);
2279 __den >>= __multiplicity_2;
2280 int __multiplicity_5 = 0;
2281 while ((__den % 5) == 0)
2289 int __width = (__multiplicity_2 > __multiplicity_5
2290 ? __multiplicity_2 : __multiplicity_5);
2297 hh_mm_ss(_Duration __d,
bool __is_neg) noexcept
2298 : _M_h (duration_cast<chrono::hours>(__d)),
2299 _M_m (duration_cast<chrono::minutes>(__d -
hours())),
2300 _M_s (duration_cast<chrono::seconds>(__d -
hours() -
minutes())),
2304 if constexpr (treat_as_floating_point_v<typename precision::rep>)
2305 _M_ss._M_r = __ss.count();
2306 else if constexpr (precision::period::den != 1)
2307 _M_ss._M_r = duration_cast<precision>(__ss).count();
2311 static constexpr unsigned fractional_width = {_S_fractional_width()};
2315 chrono::seconds::rep>,
2316 ratio<1, __detail::__pow10(fractional_width)>>;
2318 constexpr hh_mm_ss()
noexcept =
default;
2326 is_negative()
const noexcept
2328 if constexpr (!_S_is_unsigned)
2335 hours()
const noexcept
2347 subseconds()
const noexcept
2348 {
return static_cast<precision>(_M_ss); }
2352 {
return to_duration(); }
2355 to_duration()
const noexcept
2357 if constexpr (!_S_is_unsigned)
2359 return -(_M_h + _M_m + _M_s + subseconds());
2360 return _M_h + _M_m + _M_s + subseconds();
2364 static constexpr bool _S_is_unsigned
2365 = __and_v<is_integral<typename _Duration::rep>,
2368 template<
typename _Ratio>
2372 template<
typename _Dur>
2375 typename _Dur::rep _M_r{};
2378 operator _Dur()
const noexcept
2379 {
return _Dur(_M_r); }
2383 template<
typename _Rep>
2384 requires (!treat_as_floating_point_v<_Rep>)
2393 template<
typename _Tp>
2394 static constexpr bool __fits
2398 template<
typename _Rep,
typename _Period>
2399 requires (!treat_as_floating_point_v<_Rep>)
2402 || __fits<unsigned char>)
2403 struct __subseconds<
duration<_Rep, _Period>>
2405 unsigned char _M_r{};
2412 template<
typename _Rep,
typename _Period>
2413 requires (!treat_as_floating_point_v<_Rep>)
2416 || __fits<uint_least32_t>)
2417 struct __subseconds<
duration<_Rep, _Period>>
2419 uint_least32_t _M_r{};
2430 __subseconds<precision> _M_ss{};
2432 template<
typename>
friend struct __detail::__utc_leap_second;
2439 template<
typename _Duration>
2440 struct __utc_leap_second
2444 : _M_date(chrono::floor<
days>(__s)), _M_time(__s - _M_date)
2450 hh_mm_ss<common_type_t<_Duration, days>> _M_time;
2458 is_am(
const hours& __h)
noexcept
2459 {
return 0h <= __h && __h <= 11h; }
2462 is_pm(
const hours& __h)
noexcept
2463 {
return 12h <= __h && __h <= 23h; }
2466 make12(
const hours& __h)
noexcept
2476 make24(
const hours& __h,
bool __is_pm)
noexcept
2494#if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
2510 static constexpr int unique = 0;
2511 static constexpr int nonexistent = 1;
2512 static constexpr int ambiguous = 2;
2519 class nonexistent_local_time :
public runtime_error
2522 template<
typename _Duration>
2523 nonexistent_local_time(
const local_time<_Duration>& __tp,
2524 const local_info& __i)
2525 : runtime_error(_S_make_what_str(__tp, __i))
2526 { __glibcxx_assert(__i.result == local_info::nonexistent); }
2529 template<
typename _Duration>
2531 _S_make_what_str(
const local_time<_Duration>& __tp,
2532 const local_info& __i)
2535 __os << __tp <<
" is in a gap between\n"
2536 << local_seconds(__i.first.end.time_since_epoch())
2537 + __i.first.offset <<
' ' << __i.first.abbrev <<
" and\n"
2538 << local_seconds(__i.second.begin.time_since_epoch())
2539 + __i.second.offset <<
' ' << __i.second.abbrev
2540 <<
" which are both equivalent to\n"
2541 << __i.first.end <<
" UTC";
2546 class ambiguous_local_time :
public runtime_error
2549 template<
typename _Duration>
2550 ambiguous_local_time(
const local_time<_Duration>& __tp,
2551 const local_info& __i)
2552 : runtime_error(_S_make_what_str(__tp, __i))
2553 { __glibcxx_assert(__i.result == local_info::ambiguous); }
2556 template<
typename _Duration>
2558 _S_make_what_str(
const local_time<_Duration>& __tp,
2559 const local_info& __i)
2562 __os << __tp <<
" is ambiguous. It could be\n"
2563 << __tp <<
' ' << __i.first.abbrev <<
" == "
2564 << __tp - __i.first.offset <<
" UTC or\n"
2565 << __tp <<
' ' << __i.second.abbrev <<
" == "
2566 << __tp - __i.second.offset <<
" UTC";
2571 template<
typename _Duration>
2573 __throw_bad_local_time(
const local_time<_Duration>& __tp,
2574 const local_info& __i)
2577 if (__i.result == local_info::nonexistent)
2578 throw nonexistent_local_time(__tp, __i);
2579 throw ambiguous_local_time(__tp, __i);
2585 enum class choose { earliest, latest };
2590 time_zone(time_zone&&) =
default;
2591 time_zone& operator=(time_zone&&) =
default;
2596 string_view name() const noexcept {
return _M_name; }
2598 template<
typename _Duration>
2600 get_info(
const sys_time<_Duration>& __st)
const
2601 {
return _M_get_sys_info(chrono::floor<seconds>(__st)); }
2603 template<
typename _Duration>
2605 get_info(
const local_time<_Duration>& __tp)
const
2606 {
return _M_get_local_info(chrono::floor<seconds>(__tp)); }
2608 template<
typename _Duration>
2609 sys_time<common_type_t<_Duration, seconds>>
2610 to_sys(
const local_time<_Duration>& __tp)
const
2612 local_info __info = get_info(__tp);
2614 if (__info.result != local_info::unique)
2615 __throw_bad_local_time(__tp, __info);
2617 return sys_time<_Duration>(__tp.time_since_epoch())
2618 - __info.first.offset;
2621 template<
typename _Duration>
2622 sys_time<common_type_t<_Duration, seconds>>
2623 to_sys(
const local_time<_Duration>& __tp, choose __z)
const
2625 local_info __info = get_info(__tp);
2627 if (__info.result == local_info::nonexistent)
2628 return __info.first.end;
2630 sys_time<_Duration> __st(__tp.time_since_epoch());
2632 if (__info.result == local_info::ambiguous && __z == choose::latest)
2633 return __st - __info.second.offset;
2636 return __st - __info.first.offset;
2639 template<
typename _Duration>
2640 local_time<common_type_t<_Duration, seconds>>
2641 to_local(
const sys_time<_Duration>& __tp)
const
2643 auto __d = (__tp + get_info(__tp).offset).time_since_epoch();
2644 return local_time<common_type_t<_Duration, seconds>>(__d);
2647 [[nodiscard]]
friend bool
2648 operator==(
const time_zone& __x,
const time_zone& __y)
noexcept
2649 {
return __x._M_name == __y._M_name; }
2651 [[nodiscard]]
friend strong_ordering
2652 operator<=>(
const time_zone& __x,
const time_zone& __y)
noexcept
2653 {
return __x._M_name <=> __y._M_name; }
2656 sys_info _M_get_sys_info(sys_seconds)
const;
2657 local_info _M_get_local_info(local_seconds)
const;
2659 friend const tzdb& reload_tzdb();
2661 friend class tzdb_list;
2665 explicit time_zone(unique_ptr<_Impl> __p);
2667 unique_ptr<_Impl> _M_impl;
2670 const time_zone* locate_zone(string_view __tz_name);
2671 const time_zone* current_zone();
2705 using value_type = tzdb;
2706 using reference =
const tzdb&;
2707 using pointer =
const tzdb*;
2708 using difference_type = ptrdiff_t;
2718 pointer operator->()
const noexcept {
return &**
this; }
2730 void* _M_reserved =
nullptr;
2760 const_iterator cbegin() const noexcept {
return begin(); }
2761 const_iterator cend() const noexcept {
return end(); }
2764 constexpr explicit tzdb_list(nullptr_t);
2766 friend tzdb_list& get_tzdb_list();
2767 friend const tzdb& get_tzdb();
2768 friend const tzdb& reload_tzdb();
2770 friend class leap_second;
2771 friend struct time_zone::_Impl;
2772 friend class time_zone_link;
2775 class time_zone_link
2778 time_zone_link(time_zone_link&&) =
default;
2779 time_zone_link& operator=(time_zone_link&&) =
default;
2781 string_view name() const noexcept {
return _M_name; }
2782 string_view target() const noexcept {
return _M_target; }
2785 operator==(
const time_zone_link& __x,
const time_zone_link& __y)
noexcept
2786 {
return __x.name() == __y.name(); }
2788 friend strong_ordering
2789 operator<=>(
const time_zone_link& __x,
const time_zone_link& __y)
noexcept
2790 {
return __x.name() <=> __y.name(); }
2793 friend const tzdb& reload_tzdb();
2794 friend class tzdb_list::_Node;
2796 explicit time_zone_link(nullptr_t) { }
2805 leap_second(
const leap_second&) =
default;
2806 leap_second& operator=(
const leap_second&) =
default;
2809 constexpr sys_seconds
2810 date() const noexcept
2812 if (_M_s >= _M_s.zero()) [[likely]]
2813 return sys_seconds(_M_s);
2814 return sys_seconds(-_M_s);
2819 value() const noexcept
2821 if (_M_s >= _M_s.zero()) [[likely]]
2828 [[nodiscard]]
friend constexpr bool
2829 operator==(
const leap_second&,
const leap_second&)
noexcept =
default;
2831 [[nodiscard]]
friend constexpr strong_ordering
2832 operator<=>(
const leap_second& __x,
const leap_second& __y)
noexcept
2833 {
return __x.date() <=> __y.date(); }
2835 template<
typename _Duration>
2836 [[nodiscard]]
friend constexpr bool
2837 operator==(
const leap_second& __x,
2838 const sys_time<_Duration>& __y)
noexcept
2839 {
return __x.date() == __y; }
2841 template<
typename _Duration>
2842 [[nodiscard]]
friend constexpr bool
2843 operator<(
const leap_second& __x,
2844 const sys_time<_Duration>& __y)
noexcept
2845 {
return __x.date() < __y; }
2847 template<
typename _Duration>
2848 [[nodiscard]]
friend constexpr bool
2849 operator<(
const sys_time<_Duration>& __x,
2850 const leap_second& __y)
noexcept
2851 {
return __x < __y.date(); }
2853 template<
typename _Duration>
2854 [[nodiscard]]
friend constexpr bool
2855 operator>(
const leap_second& __x,
2856 const sys_time<_Duration>& __y)
noexcept
2857 {
return __y < __x.date(); }
2859 template<
typename _Duration>
2860 [[nodiscard]]
friend constexpr bool
2861 operator>(
const sys_time<_Duration>& __x,
2862 const leap_second& __y)
noexcept
2863 {
return __y.date() < __x; }
2865 template<
typename _Duration>
2866 [[nodiscard]]
friend constexpr bool
2867 operator<=(
const leap_second& __x,
2868 const sys_time<_Duration>& __y)
noexcept
2869 {
return !(__y < __x.date()); }
2871 template<
typename _Duration>
2872 [[nodiscard]]
friend constexpr bool
2873 operator<=(
const sys_time<_Duration>& __x,
2874 const leap_second& __y)
noexcept
2875 {
return !(__y.date() < __x); }
2877 template<
typename _Duration>
2878 [[nodiscard]]
friend constexpr bool
2879 operator>=(
const leap_second& __x,
2880 const sys_time<_Duration>& __y)
noexcept
2881 {
return !(__x.date() < __y); }
2883 template<
typename _Duration>
2884 [[nodiscard]]
friend constexpr bool
2885 operator>=(
const sys_time<_Duration>& __x,
2886 const leap_second& __y)
noexcept
2887 {
return !(__x < __y.date()); }
2889 template<three_way_comparable_with<seconds> _Duration>
2890 [[nodiscard]]
friend constexpr auto
2891 operator<=>(
const leap_second& __x,
2892 const sys_time<_Duration>& __y)
noexcept
2893 {
return __x.date() <=> __y; }
2896 explicit leap_second(seconds::rep __s) : _M_s(__s) { }
2898 friend class tzdb_list::_Node;
2900 friend const tzdb& reload_tzdb();
2902 template<
typename _Duration>
2903 friend leap_second_info
2904 get_leap_second_info(
const utc_time<_Duration>&);
2909 template<
class _Tp>
struct zoned_traits { };
2912 struct zoned_traits<const time_zone*>
2914 static const time_zone*
2916 {
return std::chrono::locate_zone(
"UTC"); }
2918 static const time_zone*
2919 locate_zone(string_view __name)
2920 {
return std::chrono::locate_zone(__name); }
2926 _GLIBCXX_STD_C::vector<time_zone> zones;
2927 _GLIBCXX_STD_C::vector<time_zone_link> links;
2928 _GLIBCXX_STD_C::vector<leap_second> leap_seconds;
2931 locate_zone(string_view __tz_name)
const;
2934 current_zone()
const;
2937 friend const tzdb& reload_tzdb();
2938 friend class time_zone;
2939 friend class tzdb_list::_Node;
2942 tzdb_list& get_tzdb_list();
2943 const tzdb& get_tzdb();
2945 const tzdb& reload_tzdb();
2946 string remote_version();
2948 template<
typename _Duration,
typename _TimeZonePtr = const time_zone*>
2951 static_assert(__is_duration_v<_Duration>);
2953 using _Traits = zoned_traits<_TimeZonePtr>;
2957 using string_view = type_identity_t<std::string_view>;
2960 using duration = common_type_t<_Duration, seconds>;
2962 zoned_time()
requires requires { _Traits::default_zone(); }
2965 zoned_time(
const zoned_time&) =
default;
2966 zoned_time& operator=(
const zoned_time&) =
default;
2968 zoned_time(
const sys_time<_Duration>& __st)
2969 requires requires { _Traits::default_zone(); }
2974 zoned_time(_TimeZonePtr __z) : _M_zone(
std::move(__z)) { }
2977 zoned_time(string_view __name)
2981 : _M_zone(_Traits::locate_zone(__name))
2984 template<
typename _Duration2>
2985 zoned_time(
const zoned_time<_Duration2, _TimeZonePtr>& __zt)
2986 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
2987 : _M_zone(__zt._M_zone), _M_tp(__zt._M_tp)
2990 zoned_time(_TimeZonePtr __z,
const sys_time<_Duration>& __st)
2991 : _M_zone(
std::move(__z)), _M_tp(__st)
2994 zoned_time(string_view __name,
const sys_time<_Duration>& __st)
2995 : zoned_time(_Traits::locate_zone(__name), __st)
2998 zoned_time(_TimeZonePtr __z,
const local_time<_Duration>& __tp)
3000 { __z->to_sys(__tp) } -> convertible_to<sys_time<_Duration>>;
3002 : _M_zone(
std::move(__z)), _M_tp(_M_zone->to_sys(__tp))
3005 zoned_time(string_view __name,
const local_time<_Duration>& __tp)
3006 requires requires (_TimeZonePtr __z) {
3007 { _Traits::locate_zone(__name) } -> convertible_to<_TimeZonePtr>;
3008 { __z->to_sys(__tp) } -> convertible_to<sys_time<_Duration>>;
3010 : zoned_time(_Traits::locate_zone(__name), __tp)
3013 zoned_time(_TimeZonePtr __z,
const local_time<_Duration>& __tp,
3016 { __z->to_sys(__tp, __c) } -> convertible_to<sys_time<_Duration>>;
3018 : _M_zone(
std::move(__z)), _M_tp(_M_zone->to_sys(__tp, __c))
3021 zoned_time(string_view __name,
const local_time<_Duration>& __tp,
3023 requires requires (_TimeZonePtr __z) {
3024 { _Traits::locate_zone(__name) } -> convertible_to<_TimeZonePtr>;
3025 { __z->to_sys(__tp, __c) } -> convertible_to<sys_time<_Duration>>;
3027 : _M_zone(_Traits::locate_zone(__name)),
3028 _M_tp(_M_zone->to_sys(__tp, __c))
3031 template<
typename _Duration2,
typename _TimeZonePtr2>
3032 zoned_time(_TimeZonePtr __z,
3033 const zoned_time<_Duration2, _TimeZonePtr2>& __zt)
3034 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
3035 : _M_zone(__z), _M_tp(__zt._M_tp)
3038 template<
typename _Duration2,
typename _TimeZonePtr2>
3039 zoned_time(_TimeZonePtr __z,
3040 const zoned_time<_Duration2, _TimeZonePtr2>& __zt,
3042 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
3043 : _M_zone(__z), _M_tp(__zt._M_tp)
3046 template<
typename _Duration2,
typename _TimeZonePtr2>
3047 zoned_time(string_view __name,
3048 const zoned_time<_Duration2, _TimeZonePtr2>& __zt)
3049 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
3051 { _Traits::locate_zone(__name) } -> convertible_to<_TimeZonePtr>;
3053 : _M_zone(_Traits::locate_zone(__name)), _M_tp(__zt._M_tp)
3056 template<
typename _Duration2,
typename _TimeZonePtr2>
3057 zoned_time(string_view __name,
3058 const zoned_time<_Duration2, _TimeZonePtr2>& __zt,
3060 requires is_convertible_v<sys_time<_Duration2>, sys_time<_Duration>>
3062 { _Traits::locate_zone(__name) } -> convertible_to<_TimeZonePtr>;
3064 : _M_zone(_Traits::locate_zone(__name)), _M_tp(__zt._M_tp)
3068 operator=(
const sys_time<_Duration>& __st)
3075 operator=(
const local_time<_Duration>& __lt)
3077 _M_tp = _M_zone->to_sys(__lt);
3082 operator sys_time<duration>()
const {
return _M_tp; }
3085 explicit operator local_time<duration>()
const
3086 {
return get_local_time(); }
3090 get_time_zone()
const
3094 local_time<duration>
3095 get_local_time()
const
3096 {
return _M_zone->to_local(_M_tp); }
3100 get_sys_time()
const
3106 {
return _M_zone->get_info(_M_tp); }
3108 [[nodiscard]]
friend bool
3109 operator==(
const zoned_time&,
const zoned_time&) =
default;
3112 _TimeZonePtr _M_zone{ _Traits::default_zone() };
3113 sys_time<duration> _M_tp{};
3115 template<
typename _Duration2,
typename _TimeZonePtr2>
3116 friend class zoned_time;
3119 zoned_time() -> zoned_time<seconds>;
3121 template<
typename _Duration>
3122 zoned_time(sys_time<_Duration>)
3123 -> zoned_time<common_type_t<_Duration, seconds>>;
3126 template<
typename _TimeZonePtrOrName>
3127 using __time_zone_representation
3128 = __conditional_t<is_convertible_v<_TimeZonePtrOrName, string_view>,
3130 remove_cvref_t<_TimeZonePtrOrName>>;
3133 template<
typename _TimeZonePtrOrName>
3134 zoned_time(_TimeZonePtrOrName&&)
3135 -> zoned_time<seconds, __time_zone_representation<_TimeZonePtrOrName>>;
3137 template<
typename _TimeZonePtrOrName,
typename _Duration>
3138 zoned_time(_TimeZonePtrOrName&&, sys_time<_Duration>)
3139 -> zoned_time<common_type_t<_Duration, seconds>,
3140 __time_zone_representation<_TimeZonePtrOrName>>;
3142 template<
typename _TimeZonePtrOrName,
typename _Duration>
3143 zoned_time(_TimeZonePtrOrName&&, local_time<_Duration>,
3144 choose = choose::earliest)
3145 -> zoned_time<common_type_t<_Duration, seconds>,
3146 __time_zone_representation<_TimeZonePtrOrName>>;
3148 template<
typename _Duration,
typename _TimeZonePtrOrName,
3149 typename _TimeZonePtr2>
3150 zoned_time(_TimeZonePtrOrName&&, zoned_time<_Duration, _TimeZonePtr2>,
3151 choose = choose::earliest)
3152 -> zoned_time<common_type_t<_Duration, seconds>,
3153 __time_zone_representation<_TimeZonePtrOrName>>;
3155 template<
typename _Dur1,
typename _TZPtr1,
typename _Dur2,
typename _TZPtr2>
3158 operator==(
const zoned_time<_Dur1, _TZPtr1>& __x,
3159 const zoned_time<_Dur2, _TZPtr2>& __y)
3161 return __x.get_time_zone() == __y.get_time_zone()
3162 && __x.get_sys_time() == __y.get_sys_time();
3165 using zoned_seconds = zoned_time<seconds>;
3170 inline leap_second_info
3171 __get_leap_second_info(sys_seconds __ss,
bool __is_utc)
3173 if (__ss < sys_seconds{}) [[unlikely]]
3176 const seconds::rep __leaps[] {
3207 const sys_seconds __expires(1687910400s);
3209#if _GLIBCXX_USE_CXX11_ABI || ! _GLIBCXX_USE_DUAL_ABI
3210 if (__ss > __expires)
3215 auto __db = get_tzdb_list().begin();
3216 auto __first = __db->leap_seconds.begin() + __n;
3217 auto __last = __db->leap_seconds.end();
3218 auto __pos = std::upper_bound(__first, __last, __ss);
3220 for (
auto __i = __first; __i != __pos; ++__i)
3221 __elapsed += __i->value();
3228 if (__pos != __first && __ss < __pos[-1])
3230 if ((__ss + 1s) >= __pos[-1])
3231 return {
true, __elapsed};
3232 __elapsed -= __pos[-1].value();
3235 return {
false, __elapsed};
3240 seconds::rep __s = __ss.time_since_epoch().count();
3241 const seconds::rep* __first =
std::begin(__leaps);
3242 const seconds::rep* __last =
std::end(__leaps);
3245 if (__s > (__last[-1] + (__last - __first) + 1))
3246 return {
false,
seconds(__last - __first) };
3248 auto __pos = std::upper_bound(__first, __last, __s);
3249 seconds __elapsed{__pos - __first};
3253 __s -= __elapsed.count();
3255 if (__pos != __first && __s < __pos[-1])
3257 if ((__s + 1) >= __pos[-1])
3258 return {
true, __elapsed};
3262 return {
false, __elapsed};
3267 template<
typename _Duration>
3269 inline leap_second_info
3270 get_leap_second_info(
const utc_time<_Duration>& __ut)
3272 auto __s = chrono::duration_cast<seconds>(__ut.time_since_epoch());
3273 return __detail::__get_leap_second_info(sys_seconds(__s),
true);
3276 template<
typename _Duration>
3278 inline utc_time<common_type_t<_Duration, seconds>>
3279 utc_clock::from_sys(
const sys_time<_Duration>& __t)
3281 using _CDur = common_type_t<_Duration, seconds>;
3282 auto __s = chrono::time_point_cast<seconds>(__t);
3283 const auto __li = __detail::__get_leap_second_info(__s,
false);
3284 return utc_time<_CDur>{__t.time_since_epoch()} + __li.elapsed;
3291#if __cplusplus >= 202002L
3292 inline namespace literals
3294 inline namespace chrono_literals
3298#pragma GCC diagnostic push
3299#pragma GCC diagnostic ignored "-Wliteral-suffix"
3302 constexpr chrono::day
3303 operator""d(
unsigned long long __d)
noexcept
3304 {
return chrono::day{
static_cast<unsigned>(__d)}; }
3308 constexpr chrono::year
3309 operator""y(
unsigned long long __y)
noexcept
3310 {
return chrono::year{
static_cast<int>(__y)}; }
3311#pragma GCC diagnostic pop
3317_GLIBCXX_END_NAMESPACE_VERSION
3320#if __cplusplus >= 202002L
bool operator==(const error_code &__lhs, const error_code &__rhs) noexcept
duration< int64_t > seconds
seconds
duration< int64_t, ratio< 3600 > > hours
hours
auto clock_cast(const time_point< _SourceClock, _Duration > &__t)
Convert a time point to a different clock.
duration< int64_t, ratio< 86400 > > days
days
duration< int64_t, ratio< 60 > > minutes
minutes
constexpr time_point< _Clock, typename common_type< duration< _Rep1, _Period1 >, _Dur2 >::type > operator+(const duration< _Rep1, _Period1 > &__lhs, const time_point< _Clock, _Dur2 > &__rhs)
Adjust a time point forwards by the given duration.
constexpr common_type< duration< _Rep1, _Period1 >, duration< _Rep2, _Period2 > >::type operator-(const duration< _Rep1, _Period1 > &__lhs, const duration< _Rep2, _Period2 > &__rhs)
The difference between two durations.
constexpr duration< __common_rep_t< _Rep1, __disable_if_is_duration< _Rep2 > >, _Period > operator/(const duration< _Rep1, _Period > &__d, const _Rep2 &__s)
duration< int64_t, ratio< 2629746 > > months
months
duration< int64_t, ratio< 31556952 > > years
years
constexpr complex< _Tp > operator*(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x times y.
constexpr complex< _Tp > operator-(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x minus y.
constexpr complex< _Tp > operator+(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x plus y.
_Tp abs(const complex< _Tp > &)
Return magnitude of z.
constexpr complex< _Tp > operator/(const complex< _Tp > &__x, const complex< _Tp > &__y)
Return new complex value x divided by y.
typename common_type< _Tp... >::type common_type_t
Alias template for common_type.
constexpr std::remove_reference< _Tp >::type && move(_Tp &&__t) noexcept
Convert a value to an rvalue.
_Tp * end(valarray< _Tp > &__va) noexcept
Return an iterator pointing to one past the last element of the valarray.
_Tp * begin(valarray< _Tp > &__va) noexcept
Return an iterator pointing to the first element of the valarray.
constexpr const _Tp & max(const _Tp &, const _Tp &)
This does what you think it does.
constexpr const _Tp & min(const _Tp &, const _Tp &)
This does what you think it does.
ISO C++ entities toplevel namespace is std.
constexpr auto size(const _Container &__cont) noexcept(noexcept(__cont.size())) -> decltype(__cont.size())
Return the size of a container.
const tzdb & front() const noexcept
Controlling output for std::string.
Provides compile-time rational arithmetic.
A non-owning reference to a string.
chrono::time_point represents a point in time as measured by a clock
Forward iterators support a superset of input iterator operations.