33 #ifndef HAS_STRING_VIEW 34 # if __cplusplus >= 201703 35 # define HAS_STRING_VIEW 1 37 # define HAS_STRING_VIEW 0 39 #endif // HAS_STRING_VIEW 46 #if !(__cplusplus >= 201402) 65 # include <string_view> 68 #include <type_traits> 71 # pragma GCC diagnostic push 72 # pragma GCC diagnostic ignored "-Wpedantic" 75 # pragma GCC diagnostic ignored "-Wmissing-field-initializers" 87 # define ONLY_C_LOCALE 0 90 #if defined(_MSC_VER) && (!defined(__clang__) || (_MSC_VER < 1910)) 94 # define CONSTDATA const 97 # define NOEXCEPT _NOEXCEPT 100 # define CONSTDATA constexpr const 101 # define CONSTCD11 constexpr 102 # define CONSTCD14 constexpr 103 # define NOEXCEPT noexcept 106 #elif defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x5150 108 # define CONSTDATA constexpr const 109 # define CONSTCD11 constexpr 111 # define NOEXCEPT noexcept 113 #elif __cplusplus >= 201402 115 # define CONSTDATA constexpr const 116 # define CONSTCD11 constexpr 117 # define CONSTCD14 constexpr 118 # define NOEXCEPT noexcept 121 # define CONSTDATA constexpr const 122 # define CONSTCD11 constexpr 124 # define NOEXCEPT noexcept 128 # if __cplusplus >= 201703 129 # define HAS_VOID_T 1 131 # define HAS_VOID_T 0 146 using days = std::chrono::duration
147 <int, std::ratio_multiply<std::ratio<24>, std::chrono::hours::period>>;
149 using weeks = std::chrono::duration
150 <int, std::ratio_multiply<std::ratio<7>, days::period>>;
152 using years = std::chrono::duration
153 <int, std::ratio_multiply<std::ratio<146097, 400>, days::period>>;
155 using months = std::chrono::duration
156 <int, std::ratio_divide<years::period, std::ratio<12>>>;
160 template <
class Duration>
161 using sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;
168 template <
class Duration>
169 using local_time = std::chrono::time_point<local_t, Duration>;
305 CONSTCD11 explicit operator
unsigned() const NOEXCEPT;
321 template<class CharT, class Traits>
322 std::basic_ostream<CharT, Traits>&
323 operator<<(
std::basic_ostream<CharT, Traits>& os, const
day& d);
336 CONSTCD14 month operator++(
int) NOEXCEPT;
338 CONSTCD14 month operator--(
int) NOEXCEPT;
343 CONSTCD11 explicit operator
unsigned() const NOEXCEPT;
347 CONSTCD11 bool operator==(const month& x, const month& y) NOEXCEPT;
348 CONSTCD11 bool operator!=(const month& x, const month& y) NOEXCEPT;
349 CONSTCD11 bool operator< (const month& x, const month& y) NOEXCEPT;
350 CONSTCD11 bool operator> (const month& x, const month& y) NOEXCEPT;
351 CONSTCD11 bool operator<=(const month& x, const month& y) NOEXCEPT;
352 CONSTCD11 bool operator>=(const month& x, const month& y) NOEXCEPT;
359 template<class CharT, class Traits>
360 std::basic_ostream<CharT, Traits>&
361 operator<<(
std::basic_ostream<CharT, Traits>& os, const month& m);
381 CONSTCD11 year operator-() const NOEXCEPT;
382 CONSTCD11 year operator+() const NOEXCEPT;
386 CONSTCD11 explicit operator
int() const NOEXCEPT;
393 CONSTCD11 bool operator==(const year& x, const year& y) NOEXCEPT;
394 CONSTCD11 bool operator!=(const year& x, const year& y) NOEXCEPT;
395 CONSTCD11 bool operator< (const year& x, const year& y) NOEXCEPT;
396 CONSTCD11 bool operator> (const year& x, const year& y) NOEXCEPT;
397 CONSTCD11 bool operator<=(const year& x, const year& y) NOEXCEPT;
398 CONSTCD11 bool operator>=(const year& x, const year& y) NOEXCEPT;
405 template<class CharT, class Traits>
406 std::basic_ostream<CharT, Traits>&
407 operator<<(
std::basic_ostream<CharT, Traits>& os, const year& y);
420 CONSTCD14 weekday& operator++() NOEXCEPT;
421 CONSTCD14 weekday operator++(
int) NOEXCEPT;
422 CONSTCD14 weekday& operator--() NOEXCEPT;
423 CONSTCD14 weekday operator--(
int) NOEXCEPT;
428 CONSTCD11 explicit operator
unsigned() const NOEXCEPT;
435 static
CONSTCD11 unsigned char weekday_from_days(
int z) NOEXCEPT;
438 CONSTCD11 bool operator==(const weekday& x, const weekday& y) NOEXCEPT;
439 CONSTCD11 bool operator!=(const weekday& x, const weekday& y) NOEXCEPT;
441 CONSTCD14 weekday operator+(const weekday& x, const
days& y) NOEXCEPT;
442 CONSTCD14 weekday operator+(const
days& x, const weekday& y) NOEXCEPT;
443 CONSTCD14 weekday operator-(const weekday& x, const
days& y) NOEXCEPT;
444 CONSTCD14 days operator-(const weekday& x, const weekday& y) NOEXCEPT;
446 template<class CharT, class Traits>
447 std::basic_ostream<CharT, Traits>&
448 operator<<(
std::basic_ostream<CharT, Traits>& os, const weekday& wd);
454 unsigned char wd_ : 4;
455 unsigned char index_ : 4;
458 weekday_indexed() =
default;
462 CONSTCD11 unsigned index() const NOEXCEPT;
466 CONSTCD11 bool operator==(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT;
467 CONSTCD11 bool operator!=(const weekday_indexed& x, const weekday_indexed& y) NOEXCEPT;
469 template<class CharT, class Traits>
470 std::basic_ostream<CharT, Traits>&
471 operator<<(
std::basic_ostream<CharT, Traits>& os, const weekday_indexed& wdi);
486 CONSTCD11 bool operator==(const weekday_last& x, const weekday_last& y) NOEXCEPT;
487 CONSTCD11 bool operator!=(const weekday_last& x, const weekday_last& y) NOEXCEPT;
489 template<class CharT, class Traits>
490 std::basic_ostream<CharT, Traits>&
491 operator<<(
std::basic_ostream<CharT, Traits>& os, const weekday_last& wdl);
501 year_month() =
default;
515 CONSTCD11 bool operator==(const year_month& x, const year_month& y) NOEXCEPT;
516 CONSTCD11 bool operator!=(const year_month& x, const year_month& y) NOEXCEPT;
517 CONSTCD11 bool operator< (const year_month& x, const year_month& y) NOEXCEPT;
518 CONSTCD11 bool operator> (const year_month& x, const year_month& y) NOEXCEPT;
519 CONSTCD11 bool operator<=(const year_month& x, const year_month& y) NOEXCEPT;
520 CONSTCD11 bool operator>=(const year_month& x, const year_month& y) NOEXCEPT;
522 CONSTCD14 year_month operator+(const year_month& ym, const
months& dm) NOEXCEPT;
523 CONSTCD14 year_month operator+(const
months& dm, const year_month& ym) NOEXCEPT;
524 CONSTCD14 year_month operator-(const year_month& ym, const
months& dm) NOEXCEPT;
526 CONSTCD11 months operator-(const year_month& x, const year_month& y) NOEXCEPT;
527 CONSTCD11 year_month operator+(const year_month& ym, const
years& dy) NOEXCEPT;
528 CONSTCD11 year_month operator+(const
years& dy, const year_month& ym) NOEXCEPT;
529 CONSTCD11 year_month operator-(const year_month& ym, const
years& dy) NOEXCEPT;
531 template<class CharT, class Traits>
532 std::basic_ostream<CharT, Traits>&
533 operator<<(
std::basic_ostream<CharT, Traits>& os, const year_month& ym);
543 month_day() =
default;
552 CONSTCD11 bool operator==(const month_day& x, const month_day& y) NOEXCEPT;
553 CONSTCD11 bool operator!=(const month_day& x, const month_day& y) NOEXCEPT;
554 CONSTCD11 bool operator< (const month_day& x, const month_day& y) NOEXCEPT;
555 CONSTCD11 bool operator> (const month_day& x, const month_day& y) NOEXCEPT;
556 CONSTCD11 bool operator<=(const month_day& x, const month_day& y) NOEXCEPT;
557 CONSTCD11 bool operator>=(const month_day& x, const month_day& y) NOEXCEPT;
559 template<class CharT, class Traits>
560 std::basic_ostream<CharT, Traits>&
561 operator<<(
std::basic_ostream<CharT, Traits>& os, const month_day& md);
576 CONSTCD11 bool operator==(const month_day_last& x, const month_day_last& y) NOEXCEPT;
577 CONSTCD11 bool operator!=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
578 CONSTCD11 bool operator< (const month_day_last& x, const month_day_last& y) NOEXCEPT;
579 CONSTCD11 bool operator> (const month_day_last& x, const month_day_last& y) NOEXCEPT;
580 CONSTCD11 bool operator<=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
581 CONSTCD11 bool operator>=(const month_day_last& x, const month_day_last& y) NOEXCEPT;
583 template<class CharT, class Traits>
584 std::basic_ostream<CharT, Traits>&
585 operator<<(
std::basic_ostream<CharT, Traits>& os, const month_day_last& mdl);
598 CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT;
603 CONSTCD11 bool operator==(const month_weekday& x, const month_weekday& y) NOEXCEPT;
604 CONSTCD11 bool operator!=(const month_weekday& x, const month_weekday& y) NOEXCEPT;
606 template<class CharT, class Traits>
607 std::basic_ostream<CharT, Traits>&
608 operator<<(
std::basic_ostream<CharT, Traits>& os, const month_weekday& mwd);
628 bool operator==(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT;
630 bool operator!=(const month_weekday_last& x, const month_weekday_last& y) NOEXCEPT;
632 template<class CharT, class Traits>
633 std::basic_ostream<CharT, Traits>&
634 operator<<(
std::basic_ostream<CharT, Traits>& os, const month_weekday_last& mwdl);
645 year_month_day() =
default;
671 CONSTCD11 bool operator==(const year_month_day& x, const year_month_day& y) NOEXCEPT;
672 CONSTCD11 bool operator!=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
673 CONSTCD11 bool operator< (const year_month_day& x, const year_month_day& y) NOEXCEPT;
674 CONSTCD11 bool operator> (const year_month_day& x, const year_month_day& y) NOEXCEPT;
675 CONSTCD11 bool operator<=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
676 CONSTCD11 bool operator>=(const year_month_day& x, const year_month_day& y) NOEXCEPT;
678 CONSTCD14 year_month_day operator+(const year_month_day& ymd, const
months& dm) NOEXCEPT;
679 CONSTCD14 year_month_day operator+(const
months& dm, const year_month_day& ymd) NOEXCEPT;
680 CONSTCD14 year_month_day operator-(const year_month_day& ymd, const
months& dm) NOEXCEPT;
681 CONSTCD11 year_month_day operator+(const year_month_day& ymd, const
years& dy) NOEXCEPT;
682 CONSTCD11 year_month_day operator+(const
years& dy, const year_month_day& ymd) NOEXCEPT;
683 CONSTCD11 year_month_day operator-(const year_month_day& ymd, const
years& dy) NOEXCEPT;
685 template<class CharT, class Traits>
686 std::basic_ostream<CharT, Traits>&
687 operator<<(
std::basic_ostream<CharT, Traits>& os, const year_month_day& ymd);
707 CONSTCD11 date::month_day_last month_day_last() const NOEXCEPT;
716 bool operator==(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
718 bool operator!=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
720 bool operator< (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
722 bool operator> (const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
724 bool operator<=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
726 bool operator>=(const year_month_day_last& x, const year_month_day_last& y) NOEXCEPT;
730 operator+(const year_month_day_last& ymdl, const
months& dm) NOEXCEPT;
734 operator+(const
months& dm, const year_month_day_last& ymdl) NOEXCEPT;
738 operator+(const year_month_day_last& ymdl, const
years& dy) NOEXCEPT;
742 operator+(const
years& dy, const year_month_day_last& ymdl) NOEXCEPT;
746 operator-(const year_month_day_last& ymdl, const
months& dm) NOEXCEPT;
750 operator-(const year_month_day_last& ymdl, const
years& dy) NOEXCEPT;
752 template<class CharT, class Traits>
753 std::basic_ostream<CharT, Traits>&
754 operator<<(
std::basic_ostream<CharT, Traits>& os, const year_month_day_last& ymdl);
765 year_month_weekday() =
default;
779 CONSTCD11 unsigned index() const NOEXCEPT;
780 CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT;
787 static
CONSTCD14 year_month_weekday from_days(
days dp) NOEXCEPT;
792 bool operator==(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT;
794 bool operator!=(const year_month_weekday& x, const year_month_weekday& y) NOEXCEPT;
798 operator+(const year_month_weekday& ymwd, const
months& dm) NOEXCEPT;
802 operator+(const
months& dm, const year_month_weekday& ymwd) NOEXCEPT;
806 operator+(const year_month_weekday& ymwd, const
years& dy) NOEXCEPT;
810 operator+(const
years& dy, const year_month_weekday& ymwd) NOEXCEPT;
814 operator-(const year_month_weekday& ymwd, const
months& dm) NOEXCEPT;
818 operator-(const year_month_weekday& ymwd, const
years& dy) NOEXCEPT;
820 template<class CharT, class Traits>
821 std::basic_ostream<CharT, Traits>&
822 operator<<(
std::basic_ostream<CharT, Traits>& os, const year_month_weekday& ymwdi);
856 operator==(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT;
860 operator!=(const year_month_weekday_last& x, const year_month_weekday_last& y) NOEXCEPT;
863 year_month_weekday_last
864 operator+(const year_month_weekday_last& ymwdl, const
months& dm) NOEXCEPT;
867 year_month_weekday_last
868 operator+(const
months& dm, const year_month_weekday_last& ymwdl) NOEXCEPT;
871 year_month_weekday_last
872 operator+(const year_month_weekday_last& ymwdl, const
years& dy) NOEXCEPT;
875 year_month_weekday_last
876 operator+(const
years& dy, const year_month_weekday_last& ymwdl) NOEXCEPT;
879 year_month_weekday_last
880 operator-(const year_month_weekday_last& ymwdl, const
months& dm) NOEXCEPT;
883 year_month_weekday_last
884 operator-(const year_month_weekday_last& ymwdl, const
years& dy) NOEXCEPT;
886 template<class CharT, class Traits>
887 std::basic_ostream<CharT, Traits>&
888 operator<<(
std::basic_ostream<CharT, Traits>& os, const year_month_weekday_last& ymwdl);
890 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 891 inline namespace literals
919 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) 923 template <
class T,
class = std::
void_t<>>
929 struct is_clock<T, std::void_t<decltype(T::now()), typename T::rep, typename T::period,
930 typename T::duration, typename T::time_point,
931 decltype(T::is_steady)>>
944 template<
class CharT,
class Traits = std::
char_traits<CharT>>
947 std::basic_ostream<CharT, Traits>&
os_;
974 static const int digits = std::numeric_limits<T>::digits;
975 using type =
typename std::conditional
979 typename std::conditional
983 #ifdef __SIZEOF_INT128__ 995 typename std::enable_if
997 !std::chrono::treat_as_floating_point<T>::value,
1008 typename std::enable_if
1010 std::chrono::treat_as_floating_point<T>::value,
1015 using namespace std;
1017 CONSTDATA auto digits = numeric_limits<T>::digits;
1018 static_assert(digits < numeric_limits<I>::digits,
"");
1019 CONSTDATA auto max = I{1} << (digits-1);
1021 const auto negative = t < T{0};
1022 if (min <= t && t <= max && t != 0 && t == t)
1024 t =
static_cast<T
>(
static_cast<I
>(t));
1025 if (t == 0 && negative)
1031 template <std::
intmax_t Xp, std::
intmax_t Yp>
1037 template <std::
intmax_t Xp>
1040 static const std::intmax_t value = Xp;
1046 static const std::intmax_t value = 1;
1049 template <
class R1,
class R2>
1055 static const std::intmax_t n1 = R1::num / gcd_n1_n2;
1056 static const std::intmax_t d1 = R1::den / gcd_d1_d2;
1057 static const std::intmax_t n2 = R2::num / gcd_n1_n2;
1058 static const std::intmax_t d2 = R2::den / gcd_d1_d2;
1059 static const std::intmax_t max = -((std::intmax_t(1) <<
1060 (
sizeof(std::intmax_t) * CHAR_BIT - 1)) + 1);
1062 template <std::
intmax_t Xp, std::
intmax_t Yp,
bool overflow>
1065 static const std::intmax_t value = Xp * Yp;
1068 template <std::
intmax_t Xp, std::
intmax_t Yp>
1071 static const std::intmax_t value = 1;
1075 static const bool value = (n1 <= max / d2) && (n2 <= max / d1);
1076 typedef std::ratio<mul<n1, d2, !value>::value,
1083 template <
class To,
class Rep,
class Period>
1086 typename std::enable_if
1091 trunc(
const std::chrono::duration<Rep, Period>& d)
1093 return To{
detail::trunc(std::chrono::duration_cast<To>(d).count())};
1096 template <
class To,
class Rep,
class Period>
1099 typename std::enable_if
1101 !detail::no_overflow<Period, typename To::period>::value,
1104 trunc(
const std::chrono::duration<Rep, Period>& d)
1106 using namespace std::chrono;
1108 return To{
detail::trunc(duration_cast<To>(duration_cast<duration<rep>>(d)).count())};
1111 #ifndef HAS_CHRONO_ROUNDING 1112 # if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918 || (_MSC_FULL_VER >= 190000000 && defined (__clang__))) 1113 # define HAS_CHRONO_ROUNDING 1 1114 # elif defined(__cpp_lib_chrono) && __cplusplus > 201402 && __cpp_lib_chrono >= 201510 1115 # define HAS_CHRONO_ROUNDING 1 1116 # elif defined(_LIBCPP_VERSION) && __cplusplus > 201402 && _LIBCPP_VERSION >= 3800 1117 # define HAS_CHRONO_ROUNDING 1 1119 # define HAS_CHRONO_ROUNDING 0 1121 #endif // HAS_CHRONO_ROUNDING 1123 #if HAS_CHRONO_ROUNDING == 0 1126 template <
class To,
class Rep,
class Period>
1129 typename std::enable_if
1131 detail::no_overflow<Period, typename To::period>::value,
1134 floor(
const std::chrono::duration<Rep, Period>& d)
1136 auto t = trunc<To>(d);
1142 template <
class To,
class Rep,
class Period>
1145 typename std::enable_if
1147 !detail::no_overflow<Period, typename To::period>::value,
1150 floor(
const std::chrono::duration<Rep, Period>& d)
1152 using namespace std::chrono;
1154 return floor<To>(floor<duration<rep>>(d));
1158 template <
class To,
class Rep,
class Period>
1162 round(
const std::chrono::duration<Rep, Period>& d)
1164 auto t0 = floor<To>(d);
1165 auto t1 = t0 + To{1};
1166 if (t1 == To{0} && t0 < To{0})
1168 auto diff0 = d - t0;
1169 auto diff1 = t1 - d;
1172 if (t0 - trunc<To>(t0/2)*2 == To{0})
1182 template <
class To,
class Rep,
class Period>
1186 ceil(
const std::chrono::duration<Rep, Period>& d)
1188 auto t = trunc<To>(d);
1194 template <
class Rep,
class Period,
1195 class =
typename std::enable_if
1197 std::numeric_limits<Rep>::is_signed
1200 std::chrono::duration<Rep, Period>
1201 abs(std::chrono::duration<Rep, Period> d)
1203 return d >= d.zero() ? d : -d;
1207 template <
class To,
class Clock,
class FromDuration>
1210 std::chrono::time_point<Clock, To>
1211 floor(
const std::chrono::time_point<Clock, FromDuration>& tp)
1213 using std::chrono::time_point;
1214 return time_point<Clock, To>{date::floor<To>(tp.time_since_epoch())};
1218 template <
class To,
class Clock,
class FromDuration>
1221 std::chrono::time_point<Clock, To>
1222 round(
const std::chrono::time_point<Clock, FromDuration>& tp)
1224 using std::chrono::time_point;
1225 return time_point<Clock, To>{round<To>(tp.time_since_epoch())};
1229 template <
class To,
class Clock,
class FromDuration>
1232 std::chrono::time_point<Clock, To>
1233 ceil(
const std::chrono::time_point<Clock, FromDuration>& tp)
1235 using std::chrono::time_point;
1236 return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
1239 #else // HAS_CHRONO_ROUNDING == 1 1246 #endif // HAS_CHRONO_ROUNDING 1249 template <
class To,
class Clock,
class FromDuration>
1252 std::chrono::time_point<Clock, To>
1253 trunc(
const std::chrono::time_point<Clock, FromDuration>& tp)
1255 using std::chrono::time_point;
1256 return time_point<Clock, To>{trunc<To>(tp.time_since_epoch())};
1268 CONSTCD11 inline day::operator unsigned() const NOEXCEPT {
return d_;}
1276 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
1292 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
1324 return days{
static_cast<days::rep
>(
static_cast<unsigned>(x)
1325 - static_cast<unsigned>(y))};
1333 return day{
static_cast<unsigned>(x) + static_cast<unsigned>(y.count())};
1352 template<
class CharT,
class Traits>
1354 std::basic_ostream<CharT, Traits>&
1355 operator<<(std::basic_ostream<CharT, Traits>& os,
const day& d)
1361 os << static_cast<unsigned>(d);
1391 CONSTCD11 inline month::operator unsigned() const NOEXCEPT {
return m_;}
1399 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
1415 return static_cast<unsigned>(x) < static_cast<unsigned>(y);
1447 auto const d =
static_cast<unsigned>(x) - static_cast<unsigned>(y);
1448 return months(d <= 11 ? d : d + 12);
1456 auto const mu =
static_cast<long long>(
static_cast<unsigned>(x)) - 1 + y.count();
1457 auto const yr = (mu >= 0 ? mu : mu-11) / 12;
1458 return month{
static_cast<unsigned>(mu - yr * 12 + 1)};
1477 template<
class CharT,
class Traits>
1479 std::basic_ostream<CharT, Traits>&
1480 operator<<(std::basic_ostream<CharT, Traits>& os,
const month& m)
1482 switch (static_cast<unsigned>(m))
1521 os << static_cast<unsigned>(m) <<
" is not a valid month";
1544 return y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0);
1547 CONSTCD11 inline year::operator int() const NOEXCEPT {
return y_;}
1554 return y_ != std::numeric_limits<short>::min();
1562 return year{-32767};
1578 return static_cast<int>(x) == static_cast<int>(y);
1594 return static_cast<int>(x) < static_cast<int>(y);
1626 return years{
static_cast<int>(x) - static_cast<int>(y)};
1634 return year{
static_cast<int>(x) + y.count()};
1650 return year{
static_cast<int>(x) - y.count()};
1653 template<
class CharT,
class Traits>
1655 std::basic_ostream<CharT, Traits>&
1656 operator<<(std::basic_ostream<CharT, Traits>& os,
const year& y)
1661 os.width(4 + (y < year{0}));
1662 os << static_cast<int>(y);
1673 return static_cast<unsigned char>(
static_cast<unsigned>(
1674 z >= -4 ? (z+4) % 7 : (z+5) % 7 + 6));
1680 : wd_(
static_cast<decltype(wd_)
>(wd))
1686 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1692 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1720 weekday::operator unsigned() const NOEXCEPT
1722 return static_cast<unsigned>(wd_);
1732 return static_cast<unsigned>(x) == static_cast<unsigned>(y);
1748 auto const diff =
static_cast<unsigned>(x) - static_cast<unsigned>(y);
1749 return days{diff <= 6 ? diff : diff + 7};
1757 auto const wdu =
static_cast<long long>(
static_cast<unsigned>(x)) + y.count();
1758 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1759 return weekday{
static_cast<unsigned>(wdu - wk * 7)};
1778 template<
class CharT,
class Traits>
1780 std::basic_ostream<CharT, Traits>&
1781 operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday& wd)
1783 switch (static_cast<unsigned>(wd))
1807 os << static_cast<unsigned>(wd) <<
" is not a valid weekday";
1813 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 1814 inline namespace literals
1820 operator "" _d(
unsigned long long d) NOEXCEPT
1822 return date::day{
static_cast<unsigned>(d)};
1828 operator "" _y(
unsigned long long y) NOEXCEPT
1832 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900) 1857 #if !defined(_MSC_VER) || (_MSC_VER >= 1900) 1878 return weekday().ok() && 1 <= index_ && index_ <= 5;
1882 # pragma GCC diagnostic push 1883 # pragma GCC diagnostic ignored "-Wconversion" 1889 : wd_(
static_cast<decltype(wd_)
>(static_cast<unsigned>(wd)))
1890 , index_(
static_cast<decltype(index_)
>(index))
1894 # pragma GCC diagnostic pop 1897 template<
class CharT,
class Traits>
1899 std::basic_ostream<CharT, Traits>&
1900 operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday_indexed& wdi)
1902 return os << wdi.
weekday() <<
'[' << wdi.index() <<
']';
1910 return {*
this, index};
1916 operator==(
const weekday_indexed& x,
const weekday_indexed& y) NOEXCEPT
1918 return x.weekday() == y.weekday() && x.index() == y.index();
1924 operator!=(
const weekday_indexed& x,
const weekday_indexed& y) NOEXCEPT
1938 operator==(
const weekday_last& x,
const weekday_last& y) NOEXCEPT
1940 return x.weekday() == y.weekday();
1946 operator!=(
const weekday_last& x,
const weekday_last& y) NOEXCEPT
1951 template<
class CharT,
class Traits>
1953 std::basic_ostream<CharT, Traits>&
1954 operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday_last& wdl)
1956 return os << wdl.weekday() <<
"[last]";
1964 return weekday_last{*
this};
2021 return x.year() == y.year() && x.month() == y.month();
2035 operator<(
const year_month& x,
const year_month& y) NOEXCEPT
2037 return x.year() < y.year() ?
true 2038 : (x.year() > y.year() ?
false 2039 : (x.month() < y.month()));
2045 operator>(
const year_month& x,
const year_month& y) NOEXCEPT
2071 auto dmi =
static_cast<int>(
static_cast<unsigned>(ym.month())) - 1 + dm.count();
2072 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
2073 dmi = dmi - dy * 12 + 1;
2074 return (ym.year() +
years(dy)) / month(static_cast<unsigned>(dmi));
2096 operator-(
const year_month& x,
const year_month& y) NOEXCEPT
2098 return (x.year() - y.year()) +
2099 months(static_cast<unsigned>(x.month()) - static_cast<unsigned>(y.month()));
2107 return (ym.year() + dy) / ym.month();
2126 template<
class CharT,
class Traits>
2128 std::basic_ostream<CharT, Traits>&
2129 operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month& ym)
2131 return os << ym.year() <<
'/' << ym.month();
2158 return m_.
ok() &&
date::day{1} <= d_ && d_ <= d[static_cast<unsigned>(m_)-1];
2166 return x.month() == y.month() && x.day() == y.day();
2182 return x.month() < y.month() ?
true 2183 : (x.month() > y.month() ?
false 2184 : (x.day() < y.day()));
2211 template<
class CharT,
class Traits>
2213 std::basic_ostream<CharT, Traits>&
2214 operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day& md)
2216 return os << md.month() <<
'/' << md.day();
2228 operator==(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2230 return x.month() == y.month();
2236 operator!=(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2244 operator<(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2246 return x.month() < y.month();
2252 operator>(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2260 operator<=(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2268 operator>=(
const month_day_last& x,
const month_day_last& y) NOEXCEPT
2273 template<
class CharT,
class Traits>
2275 std::basic_ostream<CharT, Traits>&
2276 operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day_last& mdl)
2278 return os << mdl.month() <<
"/last";
2306 return m_.
ok() && wdi_.
ok();
2312 operator==(
const month_weekday& x,
const month_weekday& y) NOEXCEPT
2314 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
2320 operator!=(
const month_weekday& x,
const month_weekday& y) NOEXCEPT
2325 template<
class CharT,
class Traits>
2327 std::basic_ostream<CharT, Traits>&
2328 operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday& mwd)
2330 return os << mwd.month() <<
'/' << mwd.weekday_indexed();
2358 return m_.
ok() && wdl_.
ok();
2364 operator==(
const month_weekday_last& x,
const month_weekday_last& y) NOEXCEPT
2366 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
2372 operator!=(
const month_weekday_last& x,
const month_weekday_last& y) NOEXCEPT
2377 template<
class CharT,
class Traits>
2379 std::basic_ostream<CharT, Traits>&
2380 operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday_last& mwdl)
2382 return os << mwdl.month() <<
'/' << mwdl.weekday_last();
2397 year_month_day_last&
2406 year_month_day_last&
2415 year_month_day_last&
2424 year_month_day_last&
2455 d[
static_cast<unsigned>(month()) - 1] :
date::day{29};
2460 year_month_day_last::operator
sys_days() const NOEXCEPT
2477 return y_.
ok() && mdl_.
ok();
2483 operator==(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2485 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
2491 operator!=(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2499 operator<(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2501 return x.year() < y.year() ?
true 2502 : (x.year() > y.year() ?
false 2503 : (x.month_day_last() < y.month_day_last()));
2509 operator>(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2517 operator<=(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2525 operator>=(
const year_month_day_last& x,
const year_month_day_last& y) NOEXCEPT
2530 template<
class CharT,
class Traits>
2532 std::basic_ostream<CharT, Traits>&
2533 operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day_last& ymdl)
2535 return os << ymdl.year() <<
'/' << ymdl.month_day_last();
2543 return (ymdl.year() / ymdl.month() + dm) /
last;
2559 return ymdl + (-dm);
2567 return {ymdl.year()+dy, ymdl.month_day_last()};
2583 return ymdl + (-dy);
2608 : year_month_day(from_days(dp.time_since_epoch()))
2614 : year_month_day(from_days(dp.time_since_epoch()))
2662 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2663 "This algorithm has not been ported to a 16 bit unsigned integer");
2664 static_assert(std::numeric_limits<int>::digits >= 20,
2665 "This algorithm has not been ported to a 16 bit signed integer");
2666 auto const y =
static_cast<int>(y_) - (m_ <=
feb);
2667 auto const m =
static_cast<unsigned>(m_);
2668 auto const d =
static_cast<unsigned>(d_);
2669 auto const era = (y >= 0 ? y : y-399) / 400;
2670 auto const yoe =
static_cast<unsigned>(y - era * 400);
2671 auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1;
2672 auto const doe = yoe * 365 + yoe/4 - yoe/100 + doy;
2673 return days{era * 146097 +
static_cast<int>(doe) - 719468};
2695 if (!(y_.
ok() && m_.
ok()))
2703 operator==(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2705 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
2711 operator!=(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2719 operator<(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2721 return x.year() < y.year() ?
true 2722 : (x.year() > y.year() ?
false 2723 : (x.month() < y.month() ?
true 2724 : (x.month() > y.month() ?
false 2725 : (x.day() < y.day()))));
2731 operator>(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2739 operator<=(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2747 operator>=(
const year_month_day& x,
const year_month_day& y) NOEXCEPT
2752 template<
class CharT,
class Traits>
2754 std::basic_ostream<CharT, Traits>&
2755 operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day& ymd)
2760 os << ymd.year() <<
'-';
2762 os << static_cast<unsigned>(ymd.month()) <<
'-';
2772 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2773 "This algorithm has not been ported to a 16 bit unsigned integer");
2774 static_assert(std::numeric_limits<int>::digits >= 20,
2775 "This algorithm has not been ported to a 16 bit signed integer");
2776 auto const z = dp.count() + 719468;
2777 auto const era = (z >= 0 ? z : z - 146096) / 146097;
2778 auto const doe =
static_cast<unsigned>(z - era * 146097);
2779 auto const yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365;
2780 auto const y =
static_cast<days::rep
>(yoe) + era * 400;
2781 auto const doy = doe - (365*yoe + yoe/4 - yoe/100);
2782 auto const mp = (5*doy + 2)/153;
2783 auto const d = doy - (153*mp+2)/5 + 1;
2784 auto const m = mp < 10 ? mp+3 : mp-9;
2793 return (ymd.year() / ymd.month() + dm) / ymd.
day();
2817 return (ymd.year() + dy) / ymd.month() / ymd.
day();
2851 : year_month_weekday(from_days(dp.time_since_epoch()))
2857 : year_month_weekday(from_days(dp.time_since_epoch()))
2912 return wdi_.
index();
2944 if (wdi_.
index() <= 4)
2947 return static_cast<unsigned>(d2.count()) <= static_cast<unsigned>((y_/m_/
last).day());
2957 auto const ymd = year_month_day(dp);
2958 return {ymd.year(), ymd.month(), wd[(
static_cast<unsigned>(ymd.day())-1)/7+1]};
2968 ).time_since_epoch();
2974 operator==(
const year_month_weekday& x,
const year_month_weekday& y) NOEXCEPT
2976 return x.year() == y.year() && x.month() == y.month() &&
2977 x.weekday_indexed() == y.weekday_indexed();
2983 operator!=(
const year_month_weekday& x,
const year_month_weekday& y) NOEXCEPT
2988 template<
class CharT,
class Traits>
2990 std::basic_ostream<CharT, Traits>&
2991 operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday& ymwdi)
2993 return os << ymwdi.year() <<
'/' << ymwdi.month()
2994 <<
'/' << ymwdi.weekday_indexed();
3002 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
3018 return ymwd + (-dm);
3026 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
3042 return ymwd + (-dy);
3059 year_month_weekday_last&
3068 year_month_weekday_last&
3077 year_month_weekday_last&
3086 year_month_weekday_last&
3114 year_month_weekday_last::operator
sys_days() const NOEXCEPT
3131 return y_.
ok() && m_.
ok() && wdl_.
ok();
3146 operator==(
const year_month_weekday_last& x,
const year_month_weekday_last& y) NOEXCEPT
3148 return x.year() == y.year() && x.month() == y.month() &&
3149 x.weekday_last() == y.weekday_last();
3155 operator!=(
const year_month_weekday_last& x,
const year_month_weekday_last& y) NOEXCEPT
3160 template<
class CharT,
class Traits>
3162 std::basic_ostream<CharT, Traits>&
3163 operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday_last& ymwdl)
3165 return os << ymwdl.year() <<
'/' << ymwdl.month() <<
'/' << ymwdl.weekday_last();
3170 year_month_weekday_last
3173 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
3178 year_month_weekday_last
3186 year_month_weekday_last
3189 return ymwdl + (-dm);
3194 year_month_weekday_last
3197 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
3202 year_month_weekday_last
3210 year_month_weekday_last
3213 return ymwdl + (-dy);
3231 return y / month(static_cast<unsigned>(m));
3257 return m /
day(static_cast<unsigned>(d));
3265 return month(static_cast<unsigned>(m)) / d;
3277 return month_day_last{m};
3293 return month(static_cast<unsigned>(m))/
last;
3309 operator/(
const month& m,
const weekday_indexed& wdi) NOEXCEPT
3317 operator/(
const weekday_indexed& wdi,
const month& m) NOEXCEPT
3327 return month(static_cast<unsigned>(m)) / wdi;
3361 return month(static_cast<unsigned>(m)) / wdl;
3379 return {ym.
year(), ym.month(), d};
3387 return ym /
day(static_cast<unsigned>(d));
3395 return y / md.
month() / md.day();
3403 return year(y) / md;
3419 return year(y) / md;
3429 return {ym.
year(), month_day_last{ym.
month()}};
3435 operator/(
const year& y,
const month_day_last& mdl) NOEXCEPT
3445 return year(y) / mdl;
3451 operator/(
const month_day_last& mdl,
const year& y) NOEXCEPT
3461 return year(y) / mdl;
3469 operator/(
const year_month& ym,
const weekday_indexed& wdi) NOEXCEPT
3471 return {ym.
year(), ym.month(), wdi};
3479 return {y, mwd.
month(), mwd.weekday_indexed()};
3487 return year(y) / mwd;
3503 return year(y) / mwd;
3510 year_month_weekday_last
3511 operator/(
const year_month& ym,
const weekday_last& wdl) NOEXCEPT
3513 return {ym.
year(), ym.month(), wdl};
3518 year_month_weekday_last
3519 operator/(
const year& y,
const month_weekday_last& mwdl) NOEXCEPT
3521 return {y, mwdl.
month(), mwdl.weekday_last()};
3526 year_month_weekday_last
3529 return year(y) / mwdl;
3534 year_month_weekday_last
3535 operator/(
const month_weekday_last& mwdl,
const year& y) NOEXCEPT
3542 year_month_weekday_last
3545 return year(y) / mwdl;
3548 template <
class Duration>
3551 template <
class CharT,
class Traits,
class Duration>
3552 std::basic_ostream<CharT, Traits>&
3553 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
3555 const std::chrono::seconds* offset_sec =
nullptr);
3557 template <
class CharT,
class Traits,
class Duration,
class Alloc>
3558 std::basic_istream<CharT, Traits>&
3559 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt,
3560 fields<Duration>& fds, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
3561 std::chrono::minutes* offset =
nullptr);
3579 template <std::uint64_t n, std::uint64_t d = 10,
unsigned w = 0,
3580 bool should_continue = !(n < 2) && d != 0 && (w < 19)>
3586 template <std::u
int64_t n, std::u
int64_t d,
unsigned w>
3592 template <
unsigned exp>
3598 static CONSTDATA std::uint64_t value = h * h * (exp % 2 ? 10 : 1);
3607 template <
class Rep,
unsigned w,
bool in_range = (w < 19)>
3608 struct make_precision
3610 using type = std::chrono::duration<Rep,
3611 std::ratio<1, static_pow10<w>::value>>;
3612 static CONSTDATA
unsigned w
idth = w;
3615 template <
class Rep,
unsigned w>
3618 using type = std::chrono::duration<Rep, std::micro>;
3622 template <
class Duration,
3623 unsigned w =
width<std::common_type<
3625 std::chrono::seconds>::type::period::den>::value>
3629 using rep =
typename std::common_type<Duration, std::chrono::seconds>::type::rep;
3644 : s_(std::chrono::duration_cast<std::chrono::seconds>(d))
3645 , sub_s_(std::chrono::duration_cast<precision>(d - s_))
3659 using namespace std::chrono;
3660 return sub_s_ < std::chrono::seconds{1} && s_ < minutes{1};
3663 template <
class CharT,
class Traits>
3665 std::basic_ostream<CharT, Traits>&
3672 os << x.s_.count() <<
3673 std::use_facet<std::numpunct<char>>(os.getloc()).decimal_point();
3675 os << static_cast<std::int64_t>(x.sub_s_.count());
3680 template <
class Duration>
3685 using rep =
typename std::common_type<Duration, std::chrono::seconds>::type::rep;
3704 using namespace std::chrono;
3705 return s_ < minutes{1};
3708 template <
class CharT,
class Traits>
3710 std::basic_ostream<CharT, Traits>&
3731 template <
class Duration>
3735 std::is_convertible<Duration, std::chrono::hours>::value
3737 std::is_convertible<Duration, std::chrono::minutes>::value
3738 ? classify::minute :
3739 std::is_convertible<Duration, std::chrono::seconds>::value
3740 ? classify::second :
3741 std::chrono::treat_as_floating_point<typename Duration::rep>::value
3742 ? classify::not_valid :
3743 classify::subsecond;
3746 template <
class Rep,
class Period>
3749 typename std::enable_if
3751 std::numeric_limits<Rep>::is_signed,
3752 std::chrono::duration<Rep, Period>
3754 abs(std::chrono::duration<Rep, Period> d)
3756 return d >= d.zero() ? d : -d;
3759 template <
class Rep,
class Period>
3762 typename std::enable_if
3764 !std::numeric_limits<Rep>::is_signed,
3765 std::chrono::duration<Rep, Period>
3767 abs(std::chrono::duration<Rep, Period> d)
3783 , mode_(static_cast<decltype(mode_)>(is24hr))
3790 , mode_(
static_cast<decltype(mode_)
>(m))
3797 CONSTCD14 std::chrono::hours to24hr()
const;
3801 return !neg_ && h_ <
days{1};
3808 time_of_day_base::to24hr()
const 3811 if (mode_ ==
am || mode_ ==
pm)
3813 CONSTDATA auto h12 = std::chrono::hours(12);
3820 h = std::chrono::hours(0);
3828 time_of_day_base::make24() NOEXCEPT
3837 time_of_day_base::make12() NOEXCEPT
3839 if (mode_ == is24hr)
3841 CONSTDATA auto h12 = std::chrono::hours(12);
3850 if (h_ == std::chrono::hours(0))
3857 template <class Duration, detail::classify = detail::classify_duration<Duration>::value>
3860 template <
class Rep,
class Period>
3869 #if !defined(_MSC_VER) || _MSC_VER >= 1900 3876 :
base(since_midnight, since_midnight < std::chrono::hours{0}, is24hr)
3880 :
base(h, h < std::chrono::hours{0}, md)
3904 return base::in_conventional_range();
3907 template<
class CharT,
class Traits>
3909 std::basic_ostream<CharT, Traits>&
3912 using namespace std;
3918 if (t.mode_ !=
am && t.mode_ !=
pm)
3923 case time_of_day_storage::is24hr:
3937 template <
class Rep,
class Period>
3954 :
base(std::chrono::duration_cast<std::chrono::hours>(since_midnight),
3955 since_midnight < std::chrono::minutes{0}, is24hr)
3960 unsigned md) NOEXCEPT
3961 :
base(h,
false, md)
3971 auto p = to24hr() + m_;
3987 return base::in_conventional_range() && m_ < std::chrono::hours{1};
3990 template<
class CharT,
class Traits>
3992 std::basic_ostream<CharT, Traits>&
3995 using namespace std;
4001 if (t.mode_ !=
am && t.mode_ !=
pm)
4003 os << t.h_.count() <<
':';
4019 template <
class Rep,
class Period>
4039 :
base(std::chrono::duration_cast<std::chrono::hours>(since_midnight),
4040 since_midnight < std::chrono::seconds{0}, is24hr)
4041 , m_(std::chrono::duration_cast<std::chrono::minutes>(
detail::abs(since_midnight) - h_))
4046 std::chrono::seconds s,
unsigned md) NOEXCEPT
4047 :
base(h,
false, md)
4076 return base::in_conventional_range() && m_ < std::chrono::hours{1} &&
4080 template<
class CharT,
class Traits>
4082 std::basic_ostream<CharT, Traits>&
4085 using namespace std;
4091 if (t.mode_ !=
am && t.mode_ !=
pm)
4093 os << t.h_.count() <<
':';
4095 os << t.m_.count() <<
':' << t.s_;
4108 template <
class CharT,
class Traits,
class Duration>
4110 std::basic_ostream<CharT, Traits>&
4111 date::to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
4113 const std::chrono::seconds* offset_sec);
4115 template <
class CharT,
class Traits,
class Duration,
class Alloc>
4117 std::basic_istream<CharT, Traits>&
4120 std::basic_string<CharT, Traits, Alloc>* abbrev, std::chrono::minutes* offset);
4123 template <
class Rep,
class Period>
4128 using Duration = std::chrono::duration<Rep, Period>;
4147 :
base(date::trunc<std::chrono::hours>(since_midnight),
4148 since_midnight < Duration{0}, is24hr)
4149 , m_(date::trunc<std::chrono::minutes>(
detail::abs(since_midnight) - h_))
4154 std::chrono::seconds s,
precision sub_s,
4155 unsigned md) NOEXCEPT
4156 :
base(h,
false, md)
4186 return base::in_conventional_range() && m_ < std::chrono::hours{1} &&
4190 template<
class CharT,
class Traits>
4192 std::basic_ostream<CharT, Traits>&
4195 using namespace std;
4201 if (t.mode_ !=
am && t.mode_ !=
pm)
4203 os << t.h_.count() <<
':';
4205 os << t.m_.count() <<
':' << t.s_;
4218 template <
class CharT,
class Traits,
class Duration>
4220 std::basic_ostream<CharT, Traits>&
4221 date::to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
4223 const std::chrono::seconds* offset_sec);
4225 template <
class CharT,
class Traits,
class Duration,
class Alloc>
4227 std::basic_istream<CharT, Traits>&
4230 std::basic_string<CharT, Traits, Alloc>* abbrev, std::chrono::minutes* offset);
4235 template <
class Duration>
4241 #if !defined(_MSC_VER) || _MSC_VER >= 1900 4248 :
base(since_midnight)
4251 template <
class Arg0,
class Arg1,
class ...Args>
4253 explicit time_of_day(Arg0&& arg0, Arg1&& arg1, Args&& ...args) NOEXCEPT
4254 :
base(std::forward<Arg0>(arg0), std::forward<Arg1>(arg1), std::forward<Args>(args)...)
4258 template <
class Rep,
class Period,
4259 class =
typename std::enable_if
4260 <!std::chrono::treat_as_floating_point<Rep>::value>::type>
4280 make_time(
const std::chrono::hours& h,
const std::chrono::minutes& m,
4289 make_time(
const std::chrono::hours& h,
const std::chrono::minutes& m,
4290 const std::chrono::seconds& s,
unsigned md)
4295 template <
class Rep,
class Period,
4296 class =
typename std::enable_if<std::ratio_less<Period,
4297 std::ratio<1>>::value>::type>
4301 make_time(
const std::chrono::hours& h,
const std::chrono::minutes& m,
4302 const std::chrono::seconds& s,
const std::chrono::duration<Rep, Period>& sub_s,
4308 template <
class CharT,
class Traits,
class Duration>
4310 typename std::enable_if
4312 !std::chrono::treat_as_floating_point<typename Duration::rep>::value &&
4313 std::ratio_less<typename Duration::period, days::period>::value
4314 , std::basic_ostream<CharT, Traits>&
4318 auto const dp = date::floor<days>(tp);
4319 return os << year_month_day(dp) <<
' ' <<
make_time(tp-dp);
4322 template <
class CharT,
class Traits>
4324 std::basic_ostream<CharT, Traits>&
4325 operator<<(std::basic_ostream<CharT, Traits>& os,
const sys_days& dp)
4327 return os << year_month_day(dp);
4330 template <
class CharT,
class Traits,
class Duration>
4332 std::basic_ostream<CharT, Traits>&
4340 template <
class Duration>
4343 year_month_day ymd{year{0}/0/0};
4353 fields(year_month_day ymd_, weekday wd_) : ymd(ymd_), wd(wd_) {}
4368 template <
class CharT,
class Traits,
class Duration>
4372 if (!fds.
ymd.ok() && !fds.
wd.ok())
4375 os.setstate(std::ios::failbit);
4381 wd =
static_cast<unsigned>(weekday{fds.
ymd});
4382 if (fds.
wd.ok() && wd !=
static_cast<unsigned>(fds.
wd))
4385 os.setstate(std::ios::failbit);
4390 wd =
static_cast<unsigned>(fds.
wd);
4394 template <
class CharT,
class Traits,
class Duration>
4398 if (!fds.
ymd.month().ok())
4401 os.setstate(std::ios::failbit);
4404 return static_cast<unsigned>(fds.
ymd.month());
4415 std::pair<const std::string*, const std::string*>
4418 using namespace std;
4419 static const string nm[] =
4436 return make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4440 std::pair<const std::string*, const std::string*>
4443 using namespace std;
4444 static const string nm[] =
4471 return make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4475 std::pair<const std::string*, const std::string*>
4478 using namespace std;
4479 static const string nm[] =
4484 return make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4487 template <
class CharT,
class Traits,
class FwdIter>
4489 scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
4491 using namespace std;
4492 size_t nkw =
static_cast<size_t>(std::distance(kb, ke));
4493 const unsigned char doesnt_match =
'\0';
4494 const unsigned char might_match =
'\1';
4495 const unsigned char does_match =
'\2';
4496 unsigned char statbuf[100];
4497 unsigned char* status = statbuf;
4498 unique_ptr<unsigned char, void(*)(void*)> stat_hold(0, free);
4499 if (nkw >
sizeof(statbuf))
4501 status = (
unsigned char*)malloc(nkw);
4502 if (status ==
nullptr)
4504 stat_hold.reset(status);
4506 size_t n_might_match = nkw;
4507 size_t n_does_match = 0;
4509 unsigned char* st = status;
4510 for (
auto ky = kb; ky != ke; ++ky, ++st)
4522 for (
size_t indx = 0; is && n_might_match > 0; ++indx)
4525 auto ic = is.peek();
4528 is.setstate(ios::eofbit);
4531 auto c =
static_cast<char>(toupper(ic));
4532 bool consume =
false;
4540 for (
auto ky = kb; ky != ke; ++ky, ++st)
4542 if (*st == might_match)
4544 if (c == static_cast<char>(toupper((*ky)[indx])))
4547 if (ky->size() == indx+1)
4568 if (n_might_match + n_does_match > 1)
4571 for (
auto ky = kb; ky != ke; ++ky, ++st)
4573 if (*st == does_match && ky->size() != indx+1)
4584 for (st = status; kb != ke; ++kb, ++st)
4585 if (*st == does_match)
4588 is.setstate(ios_base::failbit);
4594 #endif // ONLY_C_LOCALE 4596 template <
class CharT,
class Traits,
class Duration>
4597 std::basic_ostream<CharT, Traits>&
4598 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
4600 const std::chrono::seconds* offset_sec)
4602 using namespace std;
4603 using namespace std::chrono;
4604 using namespace detail;
4607 auto& facet = use_facet<time_put<CharT>>(os.getloc());
4609 const CharT* command =
nullptr;
4610 CharT modified = CharT{};
4619 if (modified == CharT{})
4625 const CharT f[] = {
'%', *fmt};
4626 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4627 #else // ONLY_C_LOCALE 4628 os << weekday_names().first[tm.tm_wday+7*(*fmt ==
'a')];
4629 #endif // ONLY_C_LOCALE 4633 os << CharT{
'%'} << modified << *fmt;
4646 if (modified == CharT{})
4650 const CharT f[] = {
'%', *fmt};
4651 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4652 #else // ONLY_C_LOCALE 4653 os << month_names().first[tm.tm_mon+12*(*fmt ==
'b')];
4654 #endif // ONLY_C_LOCALE 4658 os << CharT{
'%'} << modified << *fmt;
4670 if (modified == CharT{
'O'})
4671 os << CharT{
'%'} << modified << *fmt;
4676 auto const& ymd = fds.
ymd;
4678 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
4679 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
4680 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
4681 tm.tm_mday =
static_cast<int>(
static_cast<unsigned>(ymd.day()));
4683 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
4687 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
4689 auto fe = begin(f) + 1;
4690 if (modified == CharT{
'E'})
4693 facet.put(os, os, os.fill(), &tm, begin(f), fe);
4694 #else // ONLY_C_LOCALE 4698 os << weekday_names().first[
static_cast<unsigned>(wd)+7]
4700 os << month_names().first[
extract_month(os, fds)-1+12] <<
' ';
4701 auto d =
static_cast<int>(
static_cast<unsigned>(fds.
ymd.day()));
4705 <<
make_time(duration_cast<seconds>(fds.
tod.to_duration()))
4706 <<
' ' << fds.
ymd.year();
4711 auto const& ymd = fds.
ymd;
4712 save_stream<CharT, Traits> _(os);
4716 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
4718 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
4720 os << static_cast<int>(ymd.year()) % 100;
4722 #endif // ONLY_C_LOCALE 4733 auto y =
static_cast<int>(fds.
ymd.year());
4735 if (modified == CharT{})
4738 save_stream<CharT, Traits> _(os);
4754 else if (modified == CharT{
'E'})
4756 tm.tm_year = y - 1900;
4757 CharT f[3] = {
'%',
'E',
'C'};
4758 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4762 os << CharT{
'%'} << modified << *fmt;
4775 auto d =
static_cast<int>(
static_cast<unsigned>(fds.
ymd.day()));
4777 if (modified == CharT{})
4780 save_stream<CharT, Traits> _(os);
4781 if (*fmt == CharT{
'd'})
4788 else if (modified == CharT{
'O'})
4791 CharT f[3] = {
'%',
'O', *fmt};
4792 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4796 os << CharT{
'%'} << modified << *fmt;
4808 if (modified == CharT{})
4810 auto const& ymd = fds.
ymd;
4811 save_stream<CharT, Traits> _(os);
4815 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
4817 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
4819 os << static_cast<int>(ymd.year()) % 100;
4823 os << CharT{
'%'} << modified << *fmt;
4834 if (modified == CharT{})
4836 auto const& ymd = fds.
ymd;
4837 save_stream<CharT, Traits> _(os);
4841 os << static_cast<int>(ymd.year()) << CharT{
'-'};
4843 os << static_cast<unsigned>(ymd.month()) << CharT{
'-'};
4845 os << static_cast<unsigned>(ymd.day());
4849 os << CharT{
'%'} << modified << *fmt;
4861 if (modified == CharT{})
4864 auto y = year_month_day{ld +
days{3}}.year();
4868 if (*fmt == CharT{
'G'})
4872 save_stream<CharT, Traits> _(os);
4876 os << std::abs(static_cast<int>(y)) % 100;
4881 os << CharT{
'%'} << modified << *fmt;
4895 if (modified == CharT{})
4898 if (*fmt == CharT{
'I'})
4900 if (hms.hours() < hours{10})
4902 os << hms.hours().count();
4905 else if (modified == CharT{
'O'})
4907 const CharT f[] = {
'%', modified, *fmt};
4908 tm.tm_hour =
static_cast<int>(hms.hours().count());
4909 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4913 os << CharT{
'%'} << modified << *fmt;
4925 if (modified == CharT{})
4928 auto y = fds.
ymd.year();
4930 save_stream<CharT, Traits> _(os);
4938 os << CharT{
'%'} << modified << *fmt;
4949 auto m =
static_cast<unsigned>(fds.
ymd.month());
4951 if (modified == CharT{})
4959 else if (modified == CharT{
'O'})
4961 const CharT f[] = {
'%', modified, *fmt};
4962 tm.tm_mon =
static_cast<int>(m-1);
4963 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4967 os << CharT{
'%'} << modified << *fmt;
4980 if (modified == CharT{})
4983 if (fds.
tod.minutes() < minutes{10})
4985 os << fds.
tod.minutes().count();
4988 else if (modified == CharT{
'O'})
4990 const CharT f[] = {
'%', modified, *fmt};
4991 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
4992 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
4996 os << CharT{
'%'} << modified << *fmt;
5008 if (modified == CharT{})
5012 os << CharT{
'%'} << modified << *fmt;
5024 if (modified == CharT{})
5026 const CharT f[] = {
'%', *fmt};
5027 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5028 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5032 os << CharT{
'%'} << modified << *fmt;
5035 if (fds.
tod.hours() < hours{12})
5036 os << ampm_names().first[0];
5038 os << ampm_names().first[1];
5050 if (modified == CharT{})
5052 const CharT f[] = {
'%', *fmt};
5053 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5054 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5055 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
5056 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5060 os << CharT{
'%'} << modified << *fmt;
5065 save_stream<CharT, Traits> _(os);
5068 os << tod.hours().count() << CharT{
':'};
5070 os << tod.minutes().count() << CharT{
':'};
5072 os << tod.seconds().count() << CharT{
' '};
5074 if (tod.hours() < hours{12})
5075 os << ampm_names().first[0];
5077 os << ampm_names().first[1];
5088 if (modified == CharT{})
5090 if (fds.
tod.hours() < hours{10})
5092 os << fds.
tod.hours().count() << CharT{
':'};
5093 if (fds.
tod.minutes() < minutes{10})
5095 os << fds.
tod.minutes().count();
5099 os << CharT{
'%'} << modified << *fmt;
5111 if (modified == CharT{})
5117 else if (modified == CharT{
'O'})
5119 const CharT f[] = {
'%', modified, *fmt};
5120 tm.tm_sec =
static_cast<int>(fds.
tod.s_.seconds().count());
5121 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5125 os << CharT{
'%'} << modified << *fmt;
5137 if (modified == CharT{})
5141 os << CharT{
'%'} << modified << *fmt;
5152 if (modified == CharT{})
5158 os << CharT{
'%'} << modified << *fmt;
5173 if (modified == CharT{})
5176 os << (wd != 0 ? wd : 7u);
5179 else if (modified == CharT{
'O'})
5181 const CharT f[] = {
'%', modified, *fmt};
5182 tm.tm_wday =
static_cast<int>(wd);
5183 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5187 os << CharT{
'%'} << modified << *fmt;
5199 auto const& ymd = fds.
ymd;
5202 if (modified == CharT{})
5207 os << CharT{
'0'} << CharT{
'0'};
5210 auto wn = duration_cast<
weeks>(ld - st).count() + 1;
5217 else if (modified == CharT{
'O'})
5219 const CharT f[] = {
'%', modified, *fmt};
5220 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5224 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5225 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5229 os << CharT{
'%'} << modified << *fmt;
5243 if (modified == CharT{})
5246 auto y = year_month_day{ld +
days{3}}.year();
5253 auto wn = duration_cast<
weeks>(ld - st).count() + 1;
5259 else if (modified == CharT{
'O'})
5261 const CharT f[] = {
'%', modified, *fmt};
5262 auto const& ymd = fds.
ymd;
5263 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5267 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5268 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5272 os << CharT{
'%'} << modified << *fmt;
5288 if (modified == CharT{})
5294 else if (modified == CharT{
'O'})
5296 const CharT f[] = {
'%', modified, *fmt};
5297 tm.tm_wday =
static_cast<int>(wd);
5298 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5302 os << CharT{
'%'} << modified << *fmt;
5314 auto const& ymd = fds.
ymd;
5317 if (modified == CharT{})
5322 os << CharT{
'0'} << CharT{
'0'};
5325 auto wn = duration_cast<
weeks>(ld - st).count() + 1;
5332 else if (modified == CharT{
'O'})
5334 const CharT f[] = {
'%', modified, *fmt};
5335 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5339 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5340 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5344 os << CharT{
'%'} << modified << *fmt;
5357 if (modified == CharT{
'O'})
5358 os << CharT{
'%'} << modified << *fmt;
5362 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
5363 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5364 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5366 auto fe = begin(f) + 1;
5367 if (modified == CharT{
'E'})
5370 facet.put(os, os, os.fill(), &tm, begin(f), fe);
5384 auto y =
static_cast<int>(fds.
ymd.year());
5386 if (modified == CharT{})
5397 const CharT f[] = {
'%', modified, *fmt};
5398 tm.tm_year = y - 1900;
5399 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5411 auto y = fds.
ymd.year();
5413 if (modified == CharT{})
5419 else if (modified == CharT{
'E'})
5421 const CharT f[] = {
'%', modified, *fmt};
5422 tm.tm_year =
static_cast<int>(y) - 1900;
5423 facet.put(os, os, os.fill(), &tm, begin(f), end(f));
5427 os << CharT{
'%'} << modified << *fmt;
5439 if (offset_sec ==
nullptr)
5442 os.setstate(ios::failbit);
5445 auto m = duration_cast<minutes>(*offset_sec);
5446 auto neg = m < minutes{0};
5448 auto h = duration_cast<hours>(m);
5457 if (modified != CharT{})
5459 if (m < minutes{10})
5471 if (modified == CharT{})
5473 if (abbrev ==
nullptr)
5476 os.setstate(ios::failbit);
5479 for (
auto c : *abbrev)
5484 os << CharT{
'%'} << modified << *fmt;
5496 if (modified == CharT{})
5502 os << CharT{
'%'} << modified << *fmt;
5513 if (modified == CharT{})
5520 os << CharT{
'%'} << modified << CharT{
'%'};
5534 if (modified != CharT{})
5545 if (modified != CharT{})
5550 template <
class CharT,
class Traits>
5552 std::basic_ostream<CharT, Traits>&
5553 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const year& y)
5555 using CT = std::chrono::seconds;
5560 template <
class CharT,
class Traits>
5562 std::basic_ostream<CharT, Traits>&
5563 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const month& m)
5565 using CT = std::chrono::seconds;
5570 template <
class CharT,
class Traits>
5572 std::basic_ostream<CharT, Traits>&
5573 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const day& d)
5575 using CT = std::chrono::seconds;
5580 template <
class CharT,
class Traits>
5582 std::basic_ostream<CharT, Traits>&
5583 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const weekday& wd)
5585 using CT = std::chrono::seconds;
5590 template <
class CharT,
class Traits>
5592 std::basic_ostream<CharT, Traits>&
5593 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const year_month& ym)
5595 using CT = std::chrono::seconds;
5600 template <
class CharT,
class Traits>
5602 std::basic_ostream<CharT, Traits>&
5603 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const month_day& md)
5605 using CT = std::chrono::seconds;
5610 template <
class CharT,
class Traits>
5612 std::basic_ostream<CharT, Traits>&
5613 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5614 const year_month_day& ymd)
5616 using CT = std::chrono::seconds;
5621 template <
class CharT,
class Traits,
class Rep,
class Period>
5623 std::basic_ostream<CharT, Traits>&
5624 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5625 const std::chrono::duration<Rep, Period>& d)
5627 using Duration = std::chrono::duration<Rep, Period>;
5633 template <
class CharT,
class Traits,
class Duration>
5634 std::basic_ostream<CharT, Traits>&
5635 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5637 const std::chrono::seconds* offset_sec =
nullptr)
5640 auto ld = floor<days>(tp);
5642 return to_stream(os, fmt, fds, abbrev, offset_sec);
5645 template <
class CharT,
class Traits,
class Duration>
5646 std::basic_ostream<CharT, Traits>&
5647 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5650 using namespace std::chrono;
5652 const std::string abbrev(
"UTC");
5654 auto sd = floor<days>(tp);
5656 return to_stream(os, fmt, fds, &abbrev, &offset);
5661 template <
class CharT,
class Streamable>
5663 format(
const std::locale& loc,
const CharT* fmt,
const Streamable& tp)
5664 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
5665 std::basic_string<CharT>{})
5667 std::basic_ostringstream<CharT> os;
5668 os.exceptions(std::ios::failbit | std::ios::badbit);
5674 template <
class CharT,
class Streamable>
5676 format(
const CharT* fmt,
const Streamable& tp)
5677 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
5678 std::basic_string<CharT>{})
5680 std::basic_ostringstream<CharT> os;
5681 os.exceptions(std::ios::failbit | std::ios::badbit);
5686 template <
class CharT,
class Traits,
class Alloc,
class Streamable>
5688 format(
const std::locale& loc,
const std::basic_string<CharT, Traits, Alloc>& fmt,
5689 const Streamable& tp)
5690 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
5691 std::basic_string<CharT, Traits, Alloc>{})
5693 std::basic_ostringstream<CharT, Traits, Alloc> os;
5694 os.exceptions(std::ios::failbit | std::ios::badbit);
5700 template <
class CharT,
class Traits,
class Alloc,
class Streamable>
5702 format(
const std::basic_string<CharT, Traits, Alloc>& fmt,
const Streamable& tp)
5703 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
5704 std::basic_string<CharT, Traits, Alloc>{})
5706 std::basic_ostringstream<CharT, Traits, Alloc> os;
5707 os.exceptions(std::ios::failbit | std::ios::badbit);
5717 template <
class CharT,
class Traits>
5719 read_char(std::basic_istream<CharT, Traits>& is, CharT fmt, std::ios::iostate& err)
5722 if (Traits::eq_int_type(ic, Traits::eof()) ||
5723 !Traits::eq(Traits::to_char_type(ic), fmt))
5725 err |= std::ios::failbit;
5726 is.setstate(std::ios::failbit);
5732 template <
class CharT,
class Traits>
5734 read_unsigned(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
5740 auto ic = is.peek();
5741 if (Traits::eq_int_type(ic, Traits::eof()))
5743 auto c =
static_cast<char>(Traits::to_char_type(ic));
5744 if (!(
'0' <= c && c <=
'9'))
5748 x = 10*x +
static_cast<unsigned>(c -
'0');
5753 is.setstate(std::ios::failbit);
5757 template <
class CharT,
class Traits>
5759 read_signed(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
5761 auto ic = is.peek();
5762 if (!Traits::eq_int_type(ic, Traits::eof()))
5764 auto c =
static_cast<char>(Traits::to_char_type(ic));
5765 if ((
'0' <= c && c <=
'9') || c ==
'-' || c ==
'+')
5767 if (c ==
'-' || c ==
'+')
5769 auto x =
static_cast<int>(
read_unsigned(is, std::max(m, 1u), M));
5779 is.setstate(std::ios::failbit);
5783 template <
class CharT,
class Traits>
5787 using namespace std;
5789 auto decimal_point = Traits::to_int_type(
5790 use_facet<numpunct<CharT>>(is.getloc()).decimal_point());
5794 auto ic = is.peek();
5795 if (Traits::eq_int_type(ic, Traits::eof()))
5797 if (Traits::eq_int_type(ic, decimal_point))
5800 decimal_point = Traits::eof();
5805 auto c =
static_cast<char>(Traits::to_char_type(ic));
5806 if (!(
'0' <= c && c <=
'9'))
5816 is.setstate(std::ios::failbit);
5819 return std::stold(buf);
5843 template <
class CharT,
class Traits>
5845 read(std::basic_istream<CharT, Traits>&)
5849 template <
class CharT,
class Traits,
class ...Args>
5851 read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args);
5853 template <
class CharT,
class Traits,
class ...Args>
5855 read(std::basic_istream<CharT, Traits>& is,
rs a0, Args&& ...args);
5857 template <
class CharT,
class Traits,
class ...Args>
5859 read(std::basic_istream<CharT, Traits>& is,
ru a0, Args&& ...args);
5861 template <
class CharT,
class Traits,
class ...Args>
5863 read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args);
5865 template <
class CharT,
class Traits,
class ...Args>
5867 read(std::basic_istream<CharT, Traits>& is,
rld a0, Args&& ...args);
5869 template <
class CharT,
class Traits,
class ...Args>
5871 read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args)
5876 auto ic = is.peek();
5877 if (Traits::eq_int_type(ic, Traits::eof()))
5879 is.setstate(std::ios::failbit | std::ios::eofbit);
5882 if (!Traits::eq(Traits::to_char_type(ic), a0))
5884 is.setstate(std::ios::failbit);
5889 read(is, std::forward<Args>(args)...);
5892 template <
class CharT,
class Traits,
class ...Args>
5894 read(std::basic_istream<CharT, Traits>& is,
rs a0, Args&& ...args)
5900 read(is, std::forward<Args>(args)...);
5903 template <
class CharT,
class Traits,
class ...Args>
5905 read(std::basic_istream<CharT, Traits>& is,
ru a0, Args&& ...args)
5910 a0.
i =
static_cast<int>(x);
5911 read(is, std::forward<Args>(args)...);
5914 template <
class CharT,
class Traits,
class ...Args>
5916 read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args)
5920 auto u =
static_cast<unsigned>(a0);
5921 CharT buf[std::numeric_limits<unsigned>::digits10+2] = {};
5925 *e++ = CharT(u % 10) + CharT{
'0'};
5928 std::reverse(buf, e);
5929 for (
auto p = buf; p != e && is.rdstate() == std::ios::goodbit; ++p)
5932 if (is.rdstate() == std::ios::goodbit)
5933 read(is, std::forward<Args>(args)...);
5936 template <
class CharT,
class Traits,
class ...Args>
5938 read(std::basic_istream<CharT, Traits>& is,
rld a0, Args&& ...args)
5944 read(is, std::forward<Args>(args)...);
5949 template <
class CharT,
class Traits,
class Duration,
class Alloc = std::allocator<CharT>>
5950 std::basic_istream<CharT, Traits>&
5953 std::chrono::minutes* offset)
5955 using namespace std;
5956 using namespace std::chrono;
5957 typename basic_istream<CharT, Traits>::sentry ok{is,
true};
5961 auto& f = use_facet<time_get<CharT>>(is.getloc());
5964 std::basic_string<CharT, Traits, Alloc> temp_abbrev;
5965 minutes temp_offset{};
5966 const CharT* command =
nullptr;
5967 auto modified = CharT{};
5969 CONSTDATA int not_a_year = numeric_limits<short>::min();
5971 CONSTDATA int not_a_century = not_a_year / 100;
5972 int C = not_a_century;
5974 int y = not_a_2digit_year;
5979 int wd = not_a_weekday;
5981 int I = not_a_hour_12_value;
5985 int g = not_a_2digit_year;
5988 int V = not_a_week_num;
5989 int U = not_a_week_num;
5990 int W = not_a_week_num;
5995 for (; *fmt && is.rdstate() == std::ios::goodbit; ++fmt)
6004 ios_base::iostate err = ios_base::goodbit;
6005 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6006 if ((err & ios::failbit) == 0)
6010 auto nm = detail::weekday_names();
6011 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6028 ios_base::iostate err = ios_base::goodbit;
6029 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6030 if ((err & ios::failbit) == 0)
6034 auto nm = detail::month_names();
6035 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6050 ios_base::iostate err = ios_base::goodbit;
6051 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6052 if ((err & ios::failbit) == 0)
6054 Y = tm.tm_year + 1900;
6057 h = hours{tm.tm_hour};
6058 min = minutes{tm.tm_min};
6059 s = duration_cast<Duration>(seconds{tm.tm_sec});
6063 auto nm = detail::weekday_names();
6064 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6069 nm = detail::month_names();
6070 i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6075 read(is, rs{d, 1, 2});
6080 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6084 read(is, ru{H, 1, 2}, CharT{
':'}, ru{M, 1, 2},
6085 CharT{
':'}, rld{S, 1, w});
6090 s = round<Duration>(duration<long double>{S});
6092 read(is, rs{Y, 1, 4u});
6105 ios_base::iostate err = ios_base::goodbit;
6106 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6107 if ((err & ios::failbit) == 0)
6109 Y = tm.tm_year + 1900;
6115 read(is, ru{m, 1, 2}, CharT{
'/'}, ru{d, 1, 2}, CharT{
'/'},
6129 ios_base::iostate err = ios_base::goodbit;
6130 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6131 if ((err & ios::failbit) == 0)
6133 h = hours{tm.tm_hour};
6134 min = minutes{tm.tm_min};
6135 s = duration_cast<Duration>(seconds{tm.tm_sec});
6140 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6144 read(is, ru{H, 1, 2}, CharT{
':'}, ru{M, 1, 2},
6145 CharT{
':'}, rld{S, 1, w});
6150 s = round<Duration>(duration<long double>{S});
6164 if (modified == CharT{})
6167 read(is, rs{C, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6172 ios_base::iostate err = ios_base::goodbit;
6173 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6174 if ((err & ios::failbit) == 0)
6176 auto tY = tm.tm_year + 1900;
6177 C = (tY >= 0 ? tY : tY-99) / 100;
6192 if (modified == CharT{})
6193 read(is, ru{m, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6194 ru{d, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6197 read(is, CharT{
'%'}, width, modified, *fmt);
6208 if (modified == CharT{})
6209 read(is, rs{Y, 1, width == -1 ? 4u :
static_cast<unsigned>(width)},
6210 CharT{
'-'}, ru{m, 1, 2}, CharT{
'-'}, ru{d, 1, 2});
6212 read(is, CharT{
'%'}, width, modified, *fmt);
6225 if (modified == CharT{})
6227 read(is, rs{d, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6229 else if (modified == CharT{
'O'})
6231 ios_base::iostate err = ios_base::goodbit;
6232 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6236 if ((err & ios::failbit) == 0)
6241 read(is, CharT{
'%'}, width, modified, *fmt);
6254 if (modified == CharT{})
6258 read(is, ru{H, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6263 else if (modified == CharT{
'O'})
6265 ios_base::iostate err = ios_base::goodbit;
6266 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6267 if ((err & ios::failbit) == 0)
6268 h = hours{tm.tm_hour};
6272 read(is, CharT{
'%'}, width, modified, *fmt);
6284 if (modified == CharT{})
6287 read(is, rs{I, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6288 if (I != not_a_hour_12_value)
6290 if (!(1 <= I && I <= 12))
6292 I = not_a_hour_12_value;
6298 read(is, CharT{
'%'}, width, modified, *fmt);
6309 if (modified == CharT{})
6310 read(is, ru{j, 1, width == -1 ? 3u :
static_cast<unsigned>(width)});
6312 read(is, CharT{
'%'}, width, modified, *fmt);
6324 if (modified == CharT{})
6328 read(is, ru{M, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6333 else if (modified == CharT{
'O'})
6335 ios_base::iostate err = ios_base::goodbit;
6336 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6337 if ((err & ios::failbit) == 0)
6338 min = minutes{tm.tm_min};
6342 read(is, CharT{
'%'}, width, modified, *fmt);
6355 if (modified == CharT{})
6357 read(is, rs{m, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6359 else if (modified == CharT{
'O'})
6361 ios_base::iostate err = ios_base::goodbit;
6362 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6363 if ((err & ios::failbit) == 0)
6368 read(is, CharT{
'%'}, width, modified, *fmt);
6383 auto ic = is.peek();
6384 if (Traits::eq_int_type(ic, Traits::eof()))
6386 ios_base::iostate err = ios_base::eofbit;
6388 err |= ios_base::failbit;
6396 else if (*fmt ==
'n')
6397 is.setstate(ios_base::failbit);
6410 if (modified == CharT{})
6412 if (I == not_a_hour_12_value)
6416 ios_base::iostate err = ios_base::goodbit;
6417 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6418 if (err & ios::failbit)
6420 h = hours{tm.tm_hour};
6421 I = not_a_hour_12_value;
6424 read(is, CharT{
'%'}, width, modified, *fmt);
6426 if (I == not_a_hour_12_value)
6428 auto nm = detail::ampm_names();
6429 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6438 else if (h == hours{12})
6440 I = not_a_hour_12_value;
6454 ios_base::iostate err = ios_base::goodbit;
6455 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6456 if ((err & ios::failbit) == 0)
6458 h = hours{tm.tm_hour};
6459 min = minutes{tm.tm_min};
6460 s = duration_cast<Duration>(seconds{tm.tm_sec});
6465 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6469 read(is, ru{H, 1, 2}, CharT{
':'}, ru{M, 1, 2},
6470 CharT{
':'}, rld{S, 1, w});
6471 if (is.fail() || !(1 <= H && H <= 12))
6474 auto nm = detail::ampm_names();
6475 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6484 else if (h == hours{12})
6487 s = round<Duration>(duration<long double>{S});
6499 if (modified == CharT{})
6502 read(is, ru{H, 1, 2}, CharT{
'\0'}, CharT{
':'}, CharT{
'\0'},
6503 ru{M, 1, 2}, CharT{
'\0'});
6511 read(is, CharT{
'%'}, width, modified, *fmt);
6523 if (modified == CharT{})
6527 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6529 read(is, rld{S, 1, width == -1 ? w :
static_cast<unsigned>(width)});
6531 s = round<Duration>(duration<long double>{S});
6534 else if (modified == CharT{
'O'})
6536 ios_base::iostate err = ios_base::goodbit;
6537 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6538 if ((err & ios::failbit) == 0)
6539 s = duration_cast<Duration>(seconds{tm.tm_sec});
6543 read(is, CharT{
'%'}, width, modified, *fmt);
6555 if (modified == CharT{})
6558 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6562 read(is, ru{H, 1, 2}, CharT{
':'}, ru{M, 1, 2},
6563 CharT{
':'}, rld{S, 1, w});
6568 s = round<Duration>(duration<long double>{S});
6572 read(is, CharT{
'%'}, width, modified, *fmt);
6584 if (modified == CharT{})
6586 read(is, rs{Y, 1, width == -1 ? 4u :
static_cast<unsigned>(width)});
6588 else if (modified == CharT{
'E'})
6590 ios_base::iostate err = ios_base::goodbit;
6591 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6592 if ((err & ios::failbit) == 0)
6593 Y = tm.tm_year + 1900;
6597 read(is, CharT{
'%'}, width, modified, *fmt);
6610 if (modified == CharT{})
6612 read(is, ru{y, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6616 ios_base::iostate err = ios_base::goodbit;
6617 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6618 if ((err & ios::failbit) == 0)
6619 Y = tm.tm_year + 1900;
6633 if (modified == CharT{})
6634 read(is, ru{g, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6636 read(is, CharT{
'%'}, width, modified, *fmt);
6647 if (modified == CharT{})
6648 read(is, rs{G, 1, width == -1 ? 4u :
static_cast<unsigned>(width)});
6650 read(is, CharT{
'%'}, width, modified, *fmt);
6661 if (modified == CharT{})
6662 read(is, ru{U, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6664 read(is, CharT{
'%'}, width, modified, *fmt);
6675 if (modified == CharT{})
6676 read(is, ru{V, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6678 read(is, CharT{
'%'}, width, modified, *fmt);
6689 if (modified == CharT{})
6690 read(is, ru{W, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6692 read(is, CharT{
'%'}, width, modified, *fmt);
6705 if (modified == CharT{})
6708 read(is, ru{wd, 1, width == -1 ? 1u :
static_cast<unsigned>(width)});
6709 if (!is.fail() && *fmt ==
'u')
6718 else if (modified == CharT{
'O'})
6720 ios_base::iostate err = ios_base::goodbit;
6721 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6722 if ((err & ios::failbit) == 0)
6727 read(is, CharT{
'%'}, width, modified, *fmt);
6740 if (modified == CharT{})
6746 read(is, CharT{
'%'}, width, modified, *fmt);
6758 if (modified == CharT{})
6761 read(is, CharT{
'%'}, width, modified, *fmt);
6773 if (modified == CharT{})
6774 read(is, rs{H, 2, 2}, ru{M, 2, 2});
6776 read(is, rs{H, 1, 2}, CharT{
':'}, ru{M, 2, 2});
6778 temp_offset = hours{ H } + minutes{ H < 0 ? -M : M };
6789 if (modified == CharT{})
6791 if (!temp_abbrev.empty())
6792 is.setstate(ios::failbit);
6795 while (is.rdstate() == std::ios::goodbit)
6797 auto i = is.rdbuf()->sgetc();
6798 if (Traits::eq_int_type(i, Traits::eof()))
6800 is.setstate(ios::eofbit);
6803 auto wc = Traits::to_char_type(i);
6804 auto c =
static_cast<char>(wc);
6806 if (!(CharT{1} < wc && wc < CharT{127}) || !(isalnum(c) ||
6807 c ==
'_' || c ==
'/' || c ==
'-' || c ==
'+'))
6809 temp_abbrev.push_back(c);
6810 is.rdbuf()->sbumpc();
6812 if (temp_abbrev.empty())
6813 is.setstate(ios::failbit);
6817 read(is, CharT{
'%'}, width, modified, *fmt);
6828 if (width == -1 && modified == CharT{} &&
'0' <= *fmt && *fmt <=
'9')
6830 width =
static_cast<char>(*fmt) -
'0';
6831 while (
'0' <= fmt[1] && fmt[1] <=
'9')
6832 width = 10*width +
static_cast<char>(*++fmt) -
'0';
6836 if (modified == CharT{})
6837 read(is, CharT{
'%'}, width, *fmt);
6839 read(is, CharT{
'%'}, width, modified, *fmt);
6856 if (is.rdstate() == ios::goodbit && command)
6858 if (modified == CharT{})
6859 read(is, CharT{
'%'}, width);
6861 read(is, CharT{
'%'}, width, modified);
6863 if (is.rdstate() != ios::goodbit && *fmt != CharT{} && !is.fail())
6864 is.setstate(ios::failbit);
6867 if (y != not_a_2digit_year)
6870 if (!(0 <= y && y <= 99))
6872 if (C == not_a_century)
6874 if (Y == not_a_year)
6883 C = (Y >= 0 ? Y : Y-100) / 100;
6890 tY = 100*(C+1) - (y == 0 ? 100 : y);
6891 if (Y != not_a_year && Y != tY)
6895 if (g != not_a_2digit_year)
6898 if (!(0 <= g && g <= 99))
6900 if (C == not_a_century)
6902 if (G == not_a_year)
6911 C = (G >= 0 ? G : G-100) / 100;
6918 tG = 100*(C+1) - (g == 0 ? 100 : g);
6919 if (G != not_a_year && G != tG)
6923 if (G != not_a_year)
6926 if (V == not_a_week_num || wd == not_a_weekday)
6930 (weekday{
static_cast<unsigned>(wd)}-
mon)};
6931 if (Y == not_a_year)
6932 Y =
static_cast<int>(ymd.year());
6933 else if (year{Y} != ymd.year())
6936 m =
static_cast<int>(
static_cast<unsigned>(ymd.month()));
6937 else if (month(static_cast<unsigned>(m)) != ymd.month())
6940 d =
static_cast<int>(
static_cast<unsigned>(ymd.day()));
6941 else if (
day(static_cast<unsigned>(d)) != ymd.
day())
6944 if (j != 0 && Y != not_a_year)
6948 m =
static_cast<int>(
static_cast<unsigned>(ymd.month()));
6949 else if (month(static_cast<unsigned>(m)) != ymd.month())
6952 d =
static_cast<int>(
static_cast<unsigned>(ymd.day()));
6953 else if (
day(static_cast<unsigned>(d)) != ymd.
day())
6956 if (U != not_a_week_num && Y != not_a_year)
6958 if (wd == not_a_weekday)
6962 sd = year{Y-1}/
dec/weekday{
static_cast<unsigned>(wd)}[
last];
6965 (weekday{
static_cast<unsigned>(wd)} -
sun);
6966 year_month_day ymd = sd;
6967 if (year{Y} != ymd.
year())
6970 m =
static_cast<int>(
static_cast<unsigned>(ymd.
month()));
6971 else if (month(static_cast<unsigned>(m)) != ymd.
month())
6974 d =
static_cast<int>(
static_cast<unsigned>(ymd.
day()));
6975 else if (
day(static_cast<unsigned>(d)) != ymd.
day())
6978 if (W != not_a_week_num && Y != not_a_year)
6980 if (wd == not_a_weekday)
6984 sd = year{Y-1}/
dec/weekday{
static_cast<unsigned>(wd)}[
last];
6987 (weekday{
static_cast<unsigned>(wd)} -
mon);
6988 year_month_day ymd = sd;
6989 if (year{Y} != ymd.
year())
6992 m =
static_cast<int>(
static_cast<unsigned>(ymd.
month()));
6993 else if (month(static_cast<unsigned>(m)) != ymd.
month())
6996 d =
static_cast<int>(
static_cast<unsigned>(ymd.
day()));
6997 else if (
day(static_cast<unsigned>(d)) != ymd.
day())
7002 auto ymd = year{Y}/m/d;
7003 if (wd != not_a_weekday && ymd.ok())
7005 if (weekday{
static_cast<unsigned>(wd)} != weekday(ymd))
7011 if (wd != not_a_weekday)
7012 fds.
wd = weekday{
static_cast<unsigned>(wd)};
7013 if (abbrev !=
nullptr)
7014 *abbrev = std::move(temp_abbrev);
7015 if (offset !=
nullptr)
7016 *offset = temp_offset;
7021 is.setstate(ios_base::failbit);
7025 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7026 std::basic_istream<CharT, Traits>&
7027 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt, year& y,
7028 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7029 std::chrono::minutes* offset =
nullptr)
7031 using namespace std;
7032 using namespace std::chrono;
7036 if (!fds.ymd.year().ok())
7037 is.setstate(ios::failbit);
7043 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7044 std::basic_istream<CharT, Traits>&
7045 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt, month& m,
7046 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7047 std::chrono::minutes* offset =
nullptr)
7049 using namespace std;
7050 using namespace std::chrono;
7054 if (!fds.ymd.month().ok())
7055 is.setstate(ios::failbit);
7057 m = fds.ymd.
month();
7061 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7062 std::basic_istream<CharT, Traits>&
7064 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7065 std::chrono::minutes* offset =
nullptr)
7067 using namespace std;
7068 using namespace std::chrono;
7072 if (!fds.ymd.day().ok())
7073 is.setstate(ios::failbit);
7079 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7080 std::basic_istream<CharT, Traits>&
7081 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt, weekday& wd,
7082 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7083 std::chrono::minutes* offset =
nullptr)
7085 using namespace std;
7086 using namespace std::chrono;
7091 is.setstate(ios::failbit);
7097 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7098 std::basic_istream<CharT, Traits>&
7099 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt, year_month& ym,
7100 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7101 std::chrono::minutes* offset =
nullptr)
7103 using namespace std;
7104 using namespace std::chrono;
7108 if (!fds.ymd.month().ok())
7109 is.setstate(ios::failbit);
7111 ym = fds.ymd.
year()/fds.ymd.month();
7115 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7116 std::basic_istream<CharT, Traits>&
7117 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt, month_day& md,
7118 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7119 std::chrono::minutes* offset =
nullptr)
7121 using namespace std;
7122 using namespace std::chrono;
7126 if (!fds.ymd.month().ok() || !fds.ymd.day().ok())
7127 is.setstate(ios::failbit);
7129 md = fds.ymd.
month()/fds.ymd.day();
7133 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7134 std::basic_istream<CharT, Traits>&
7136 year_month_day& ymd, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7137 std::chrono::minutes* offset =
nullptr)
7139 using namespace std;
7140 using namespace std::chrono;
7145 is.setstate(ios::failbit);
7151 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7152 std::basic_istream<CharT, Traits>&
7155 std::chrono::minutes* offset =
nullptr)
7157 using namespace std;
7158 using namespace std::chrono;
7160 minutes offset_local{};
7161 auto offptr = offset ? offset : &offset_local;
7164 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
7165 is.setstate(ios::failbit);
7167 tp = round<Duration>(
sys_days(fds.ymd) - *offptr + fds.tod.to_duration());
7171 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7172 std::basic_istream<CharT, Traits>&
7175 std::chrono::minutes* offset =
nullptr)
7177 using namespace std;
7178 using namespace std::chrono;
7182 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
7183 is.setstate(ios::failbit);
7189 template <
class Rep,
class Period,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7190 std::basic_istream<CharT, Traits>&
7192 std::chrono::duration<Rep, Period>& d,
7193 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7194 std::chrono::minutes* offset =
nullptr)
7196 using namespace std;
7197 using namespace std::chrono;
7198 using Duration = std::chrono::duration<Rep, Period>;
7203 d = duration_cast<Duration>(fds.tod.to_duration());
7207 template <
class Parsable,
class CharT,
class Traits = std::
char_traits<CharT>,
7208 class Alloc = std::allocator<CharT>>
7211 const std::basic_string<CharT, Traits, Alloc>
format_;
7218 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7219 std::chrono::minutes* offset =
nullptr)
7220 : format_(std::move(format))
7228 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7229 std::basic_istream<CharT, Traits>&
7236 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7239 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp)
7240 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7247 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7250 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7251 std::basic_string<CharT, Traits, Alloc>& abbrev)
7252 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7253 format.c_str(), tp, &abbrev),
7256 return {
format, tp, &abbrev};
7259 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7262 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7263 std::chrono::minutes& offset)
7264 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7265 format.c_str(), tp,
nullptr, &offset),
7268 return {
format, tp,
nullptr, &offset};
7271 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7274 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7275 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
7276 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7277 format.c_str(), tp, &abbrev, &offset),
7280 return {
format, tp, &abbrev, &offset};
7285 template <
class Parsable,
class CharT>
7289 -> decltype(
from_stream(std::declval<std::basic_istream<CharT>&>(),
format, tp),
7295 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7298 parse(
const CharT*
format, Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev)
7299 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
format,
7303 return {
format, tp, &abbrev};
7306 template <
class Parsable,
class CharT>
7309 parse(
const CharT*
format, Parsable& tp, std::chrono::minutes& offset)
7311 tp,
nullptr, &offset),
7314 return {
format, tp,
nullptr, &offset};
7317 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7321 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
7322 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
format,
7323 tp, &abbrev, &offset),
7326 return {
format, tp, &abbrev, &offset};
7334 #if __cplusplus >= 201402 && (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 411) \ 7335 && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5150) 7337 template <
class CharT, std::
size_t N>
7338 class string_literal
7343 using const_iterator =
const CharT*;
7345 string_literal(string_literal
const&) =
default;
7346 string_literal& operator=(string_literal
const&) =
delete;
7348 template <std::size_t N1 = 2,
7349 class = std::enable_if_t<N1 == N>>
7350 CONSTCD14 string_literal(CharT c) NOEXCEPT
7355 CONSTCD14 string_literal(
const CharT(&a)[N]) NOEXCEPT
7358 for (std::size_t i = 0; i < N; ++i)
7362 template <
class U = CharT,
class = std::enable_if_t<1 < sizeof(U)>>
7363 CONSTCD14
string_literal(const
char(&a)[N]) NOEXCEPT
7366 for (std::
size_t i = 0; i < N; ++i)
7370 template <
class CharT2,
class = std::enable_if_t<!std::is_same<CharT2, CharT>{}>>
7371 CONSTCD14 string_literal(string_literal<CharT2, N>
const& a) NOEXCEPT
7374 for (std::size_t i = 0; i < N; ++i)
7378 template <std::size_t N1, std::size_t N2,
7380 CONSTCD14 string_literal(
const string_literal<CharT, N1>& x,
7381 const string_literal<CharT, N2>& y) NOEXCEPT
7385 for (; i < N1-1; ++i)
7387 for (std::size_t j = 0; j < N2; ++j, ++i)
7391 CONSTCD14 const CharT* data()
const NOEXCEPT {
return p_;}
7392 CONSTCD14 std::size_t size()
const NOEXCEPT {
return N-1;}
7394 CONSTCD14 const_iterator begin()
const NOEXCEPT {
return p_;}
7395 CONSTCD14 const_iterator end()
const NOEXCEPT {
return p_ + N-1;}
7397 CONSTCD14 CharT
const& operator[](std::size_t n)
const NOEXCEPT
7402 template <
class Traits>
7404 std::basic_ostream<CharT, Traits>&
7405 operator<<(std::basic_ostream<CharT, Traits>& os,
const string_literal& s)
7411 template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
7414 string_literal<std::conditional_t<sizeof(CharT2) <= sizeof(CharT1), CharT1, CharT2>,
7416 operator+(
const string_literal<CharT1, N1>& x,
const string_literal<CharT2, N2>& y) NOEXCEPT
7418 using CharT = std::conditional_t<sizeof(CharT2) <= sizeof(CharT1), CharT1, CharT2>;
7419 return string_literal<CharT, N1 + N2 - 1>{string_literal<CharT, N1>{x},
7420 string_literal<CharT, N2>{y}};
7423 template <
class CharT,
class Traits,
class Alloc, std::
size_t N>
7425 std::basic_string<CharT, Traits, Alloc>
7426 operator+(std::basic_string<CharT, Traits, Alloc> x,
7427 const string_literal<CharT, N>& y) NOEXCEPT
7429 x.append(y.data(), y.size());
7433 template <
class CharT, std::
size_t N>
7436 string_literal<CharT, N>
7437 msl(
const CharT(&a)[N]) NOEXCEPT
7439 return string_literal<CharT, N>{a};
7442 template <
class CharT,
7443 class = std::enable_if_t<std::is_same<CharT, char>{} ||
7444 std::is_same<CharT, wchar_t>{} ||
7445 std::is_same<CharT, char16_t>{} ||
7446 std::is_same<CharT, char32_t>{}>>
7449 string_literal<CharT, 2>
7450 msl(CharT c) NOEXCEPT
7452 return string_literal<CharT, 2>{c};
7458 to_string_len(std::intmax_t i)
7469 template <std::
intmax_t N>
7475 string_literal<char, to_string_len(N)+1>
7479 return msl(
char(N % 10 +
'0'));
7482 template <std::
intmax_t N>
7488 string_literal<char, to_string_len(N)+1>
7492 return msl<N/10>() +
msl(
char(N % 10 +
'0'));
7495 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
7500 std::ratio<N, D>::type::den != 1,
7501 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) +
7502 to_string_len(std::ratio<N, D>::type::den) + 4>
7504 msl(std::ratio<N, D>) NOEXCEPT
7507 return msl(CharT{
'['}) + msl<R::num>() +
msl(CharT{
'/'}) +
7508 msl<R::den>() +
msl(CharT{
']'});
7511 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
7516 std::ratio<N, D>::type::den == 1,
7517 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) + 3>
7519 msl(std::ratio<N, D>) NOEXCEPT
7522 return msl(CharT{
'['}) + msl<R::num>() +
msl(CharT{
']'});
7525 template <
class CharT>
7529 msl(std::atto) NOEXCEPT
7531 return msl(CharT{
'a'});
7534 template <
class CharT>
7538 msl(std::femto) NOEXCEPT
7540 return msl(CharT{
'f'});
7543 template <
class CharT>
7547 msl(std::pico) NOEXCEPT
7549 return msl(CharT{
'p'});
7552 template <
class CharT>
7556 msl(std::nano) NOEXCEPT
7558 return msl(CharT{
'n'});
7561 template <
class CharT>
7566 std::is_same<CharT, char>{},
7567 string_literal<char, 3>
7569 msl(std::micro) NOEXCEPT
7571 return string_literal<char, 3>{
"\xC2\xB5"};
7574 template <
class CharT>
7579 !std::is_same<CharT, char>{},
7580 string_literal<CharT, 2>
7582 msl(std::micro) NOEXCEPT
7584 return string_literal<CharT, 2>{CharT{
static_cast<unsigned char>(
'\xB5')}};
7587 template <
class CharT>
7591 msl(std::milli) NOEXCEPT
7593 return msl(CharT{
'm'});
7596 template <
class CharT>
7600 msl(std::centi) NOEXCEPT
7602 return msl(CharT{
'c'});
7605 template <
class CharT>
7609 msl(std::deci) NOEXCEPT
7611 return msl(CharT{
'd'});
7614 template <
class CharT>
7618 msl(std::deca) NOEXCEPT
7620 return string_literal<CharT, 3>{
"da"};
7623 template <
class CharT>
7627 msl(std::hecto) NOEXCEPT
7629 return msl(CharT{
'h'});
7632 template <
class CharT>
7636 msl(std::kilo) NOEXCEPT
7638 return msl(CharT{
'k'});
7641 template <
class CharT>
7645 msl(std::mega) NOEXCEPT
7647 return msl(CharT{
'M'});
7650 template <
class CharT>
7654 msl(std::giga) NOEXCEPT
7656 return msl(CharT{
'G'});
7659 template <
class CharT>
7663 msl(std::tera) NOEXCEPT
7665 return msl(CharT{
'T'});
7668 template <
class CharT>
7672 msl(std::peta) NOEXCEPT
7674 return msl(CharT{
'P'});
7677 template <
class CharT>
7681 msl(std::exa) NOEXCEPT
7683 return msl(CharT{
'E'});
7686 template <
class CharT,
class Period>
7691 return msl<CharT>(p) + string_literal<CharT, 2>{
"s"};
7694 template <
class CharT>
7699 return string_literal<CharT, 2>{
"s"};
7702 template <
class CharT>
7707 return string_literal<CharT, 4>{
"min"};
7710 template <
class CharT>
7715 return string_literal<CharT, 2>{
"h"};
7718 #else // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411) 7727 template <
class CharT>
7728 std::basic_string<CharT>
7732 return std::basic_string<CharT>(y.begin(), y.end());
7735 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
7737 typename std::enable_if
7739 std::ratio<N, D>::type::den != 1,
7740 std::basic_string<CharT>
7745 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
'/'} +
7746 to_string<CharT>(R::den) + CharT{
']'};
7749 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
7751 typename std::enable_if
7753 std::ratio<N, D>::type::den == 1,
7754 std::basic_string<CharT>
7759 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
']'};
7762 template <
class CharT>
7764 std::basic_string<CharT>
7770 template <
class CharT>
7772 std::basic_string<CharT>
7778 template <
class CharT>
7780 std::basic_string<CharT>
7786 template <
class CharT>
7788 std::basic_string<CharT>
7794 template <
class CharT>
7796 typename std::enable_if
7798 std::is_same<CharT, char>::value,
7806 template <
class CharT>
7808 typename std::enable_if
7810 !std::is_same<CharT, char>::value,
7811 std::basic_string<CharT>
7815 return {CharT(static_cast<unsigned char>(
'\xB5'))};
7818 template <
class CharT>
7820 std::basic_string<CharT>
7826 template <
class CharT>
7828 std::basic_string<CharT>
7834 template <
class CharT>
7836 std::basic_string<CharT>
7842 template <
class CharT>
7844 std::basic_string<CharT>
7850 template <
class CharT>
7852 std::basic_string<CharT>
7858 template <
class CharT>
7860 std::basic_string<CharT>
7866 template <
class CharT>
7868 std::basic_string<CharT>
7874 template <
class CharT>
7876 std::basic_string<CharT>
7882 template <
class CharT>
7884 std::basic_string<CharT>
7890 template <
class CharT>
7892 std::basic_string<CharT>
7898 template <
class CharT>
7900 std::basic_string<CharT>
7906 template <
class CharT,
class Period>
7907 std::basic_string<CharT>
7910 return msl<CharT>(p) + CharT{
's'};
7913 template <
class CharT>
7914 std::basic_string<CharT>
7920 template <
class CharT>
7921 std::basic_string<CharT>
7924 return {
'm',
'i',
'n'};
7927 template <
class CharT>
7928 std::basic_string<CharT>
7934 #endif // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411) 7936 template <
class CharT,
class Traits = std::
char_traits<CharT>>
7942 template <
class Rep>
7951 template <
class Traits>
7954 template <
class Rep>
7956 std::basic_string<char, Traits>
7960 return std::basic_string<char, Traits>(s.begin(), s.end());
7967 template <
class Rep>
7972 return std::to_wstring(n);
7976 template <
class Traits>
7979 template <
class Rep>
7981 std::basic_string<wchar_t, Traits>
7984 auto s = std::to_wstring(n);
7985 return std::basic_string<wchar_t, Traits>(s.begin(), s.end());
7991 template <
class CharT,
class Traits,
class Rep,
class Period>
7993 std::basic_ostream<CharT, Traits>&
7994 operator<<(std::basic_ostream<CharT, Traits>& os,
7995 const std::chrono::duration<Rep, Period>& d)
7997 using namespace detail;
7998 return os << make_string<CharT, Traits>::from(d.count()) +
8006 # pragma GCC diagnostic pop
constexpr time_of_day_storage(std::chrono::hours since_midnight) noexcept
unsigned read_unsigned(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
constexpr time_of_day_storage() noexcept
sys_time< days > sys_days
std::chrono::time_point< std::chrono::system_clock, Duration > sys_time
constexpr std::enable_if< std::numeric_limits< Rep >::is_signed, std::chrono::duration< Rep, Period > >::type abs(std::chrono::duration< Rep, Period > d)
constexpr date::month month() const noexcept
date::weekday_indexed wdi_
constexpr std::chrono::seconds seconds() const noexcept
constexpr time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, unsigned md) noexcept
constexpr const date::month dec
month & operator+=(const months &m) noexcept
constexpr date::month month() const noexcept
constexpr time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s, precision sub_s, unsigned md) noexcept
constexpr bool operator!=(const day &x, const day &y) noexcept
constexpr const date::last_spec last
constexpr time_of_day(Arg0 &&arg0, Arg1 &&arg1, Args &&...args) noexcept
constexpr bool operator>=(const day &x, const day &y) noexcept
constexpr bool operator==(const day &x, const day &y) noexcept
constexpr unsigned index() const noexcept
constexpr std::chrono::minutes minutes() const noexcept
constexpr time_of_day< std::chrono::duration< Rep, Period > > make_time(const std::chrono::duration< Rep, Period > &d)
std::chrono::seconds & seconds() noexcept
year_month_weekday_last & operator+=(const months &m) noexcept
static constexpr year min() noexcept
constexpr day operator-(const day &x, const days &y) noexcept
weekday & operator++() noexcept
std::ios::fmtflags flags_
constexpr weekday_indexed operator[](unsigned index) const noexcept
constexpr date::month month() const noexcept
constexpr const date::month may
constexpr std::chrono::time_point< Clock, To > floor(const std::chrono::time_point< Clock, FromDuration > &tp)
days to_days() const noexcept
constexpr date::day day() const noexcept
year_month_day & operator+=(const months &m) noexcept
year_month_weekday & operator+=(const months &m) noexcept
std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, const parse_manip< Parsable, CharT, Traits, Alloc > &x)
constexpr bool ok() const noexcept
std::ratio< mul< n1, d2,!value >::value, mul< n2, d1,!value >::value > type
std::chrono::duration< Rep, std::micro > type
constexpr bool in_conventional_range() const noexcept
constexpr date::year year() const noexcept
days to_days() const noexcept
time_of_day_storage & make24() noexcept
void read(std::basic_istream< CharT, Traits > &)
constexpr bool ok() const noexcept
auto parse(const std::basic_string< CharT, Traits, Alloc > &format, Parsable &tp) -> decltype(from_stream(std::declval< std::basic_istream< CharT, Traits > & >(), format.c_str(), tp), parse_manip< Parsable, CharT, Traits, Alloc >
constexpr const date::weekday mon
std::chrono::duration< int, std::ratio_divide< years::period, std::ratio< 12 >>> months
year_month & operator-=(const months &dm) noexcept
std::basic_istream< CharT, Traits > & from_stream(std::basic_istream< CharT, Traits > &is, const CharT *fmt, fields< Duration > &fds, std::basic_string< CharT, Traits, Alloc > *abbrev=nullptr, std::chrono::minutes *offset=nullptr)
constexpr std::chrono::hours hours() const noexcept
constexpr const date::weekday fri
constexpr date::weekday weekday() const noexcept
constexpr bool is_leap() const noexcept
day & operator++() noexcept
constexpr std::chrono::hours hours() const noexcept
constexpr bool ok() const noexcept
constexpr date::month month() const noexcept
static std::basic_string< wchar_t, Traits > from(Rep n)
year & operator-=(const years &y) noexcept
time_of_day_storage & make24() noexcept
constexpr time_of_day_storage(std::chrono::minutes since_midnight) noexcept
precision to_duration() const noexcept
time_of_day_storage & make24() noexcept
std::chrono::minutes * offset_
std::basic_string< CharT > get_units(std::ratio< 3600 >)
constexpr date::weekday weekday() const noexcept
fields(year_month_day ymd_)
constexpr year operator-() const noexcept
static year_month_weekday from_days(days dp) noexcept
std::enable_if< detail::no_overflow< Period, typename To::period >::value, To >::type floor(const std::chrono::duration< Rep, Period > &d)
constexpr const date::weekday tue
constexpr date::year year() const noexcept
std::string type(const x_type &a_param)
constexpr unsigned mode() const noexcept
constexpr const date::month jul
constexpr time_of_day_storage(std::chrono::hours h, std::chrono::minutes m, std::chrono::seconds s, unsigned md) noexcept
constexpr precision subseconds() const noexcept
std::basic_string< CharT, Traits, Alloc > * abbrev_
constexpr bool ok() const noexcept
To ceil(const std::chrono::duration< Rep, Period > &d)
constexpr date::month month() const noexcept
constexpr date::weekday_indexed weekday_indexed() const noexcept
constexpr date::weekday weekday() const noexcept
std::basic_string< CharT > msl(std::exa)
constexpr bool ok() const noexcept
time_of_day_storage & make12() noexcept
month & operator--() noexcept
constexpr year_month_day_last(const date::year &y, const date::month_day_last &mdl) noexcept
constexpr const date::month apr
constexpr bool operator>(const day &x, const day &y) noexcept
typename std::enable_if< B, T >::type enable_if_t
constexpr const date::weekday thu
weekday & operator-=(const days &d) noexcept
year_month_day & operator-=(const months &m) noexcept
constexpr std::chrono::minutes minutes() const noexcept
typename std::conditional< digits< 32, std::int32_t, typename std::conditional< digits< 64, std::int64_t, std::int64_t >::type >::type type
int read_signed(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
constexpr date::year year() const noexcept
constexpr time_of_day_storage(std::chrono::seconds since_midnight) noexcept
constexpr date::month month() const noexcept
year & operator++() noexcept
std::chrono::hours precision
const std::basic_string< CharT, Traits, Alloc > format_
fields(year_month_day ymd_, time_of_day< Duration > tod_)
constexpr month_weekday_last(const date::month &m, const date::weekday_last &wd) noexcept
weekday_indexed()=default
std::chrono::duration< int, std::ratio_multiply< std::ratio< 7 >, days::period >> weeks
constexpr std::chrono::hours hours() const noexcept
date::weekday_indexed wdi_
constexpr std::chrono::minutes minutes() const noexcept
constexpr const date::month jun
constexpr std::chrono::time_point< Clock, To > ceil(const std::chrono::time_point< Clock, FromDuration > &tp)
auto format(const std::locale &loc, const CharT *fmt, const Streamable &tp) -> decltype(to_stream(std::declval< std::basic_ostream< CharT > & >(), fmt, tp), std::basic_string< CharT >
void read(std::basic_istream< CharT, Traits > &is, rld a0, Args &&...args)
constexpr bool in_conventional_range() const noexcept
constexpr date::month month() const noexcept
constexpr bool ok() const noexcept
constexpr unsigned mode() const noexcept
constexpr year operator+() const noexcept
constexpr time_of_day(Duration since_midnight) noexcept
constexpr bool in_conventional_range() const noexcept
constexpr unsigned index() const noexcept
constexpr date::weekday_indexed weekday_indexed() const noexcept
constexpr const date::weekday sun
std::chrono::duration< int, std::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period >> days
time_of_day_storage & make24() noexcept
constexpr time_of_day_storage() noexcept
weekday & operator+=(const days &d) noexcept
time_of_day_storage & make12() noexcept
constexpr date::month_day_last month_day_last() const noexcept
constexpr std::enable_if< detail::no_overflow< Period, typename To::period >::value, To >::type trunc(const std::chrono::duration< Rep, Period > &d)
constexpr date::weekday_last weekday_last() const noexcept
constexpr const date::month feb
constexpr bool ok() const noexcept
fields(year_month_day ymd_, weekday wd_)
time_of_day_storage & make12() noexcept
std::chrono::duration< int, std::ratio_multiply< std::ratio< 146097, 400 >, days::period >> years
constexpr unsigned mode() const noexcept
constexpr std::chrono::seconds seconds() const noexcept
static constexpr unsigned char weekday_from_days(int z) noexcept
year_month_day_last & operator-=(const months &m) noexcept
sys_time< std::chrono::seconds > sys_seconds
constexpr year_month operator/(const year &y, const month &m) noexcept
year & operator+=(const years &y) noexcept
static std::wstring from(Rep n)
constexpr time_of_day_base(std::chrono::hours h, bool neg, unsigned m) noexcept
std::basic_ostream< CharT, Traits > & os_
constexpr const date::weekday sat
fields(weekday wd_, time_of_day< Duration > tod_)
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
constexpr time_of_day_storage() noexcept
constexpr const date::month oct
constexpr date::year year() const noexcept
static constexpr year max() noexcept
long double read_long_double(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
constexpr date::month month() const noexcept
constexpr const date::weekday wed
constexpr time_of_day_storage(std::chrono::hours h, unsigned md) noexcept
precision to_duration() const noexcept
constexpr std::enable_if< !std::numeric_limits< Rep >::is_signed, std::chrono::duration< Rep, Period > >::type abs(std::chrono::duration< Rep, Period > d)
constexpr bool in_conventional_range() const noexcept
year_month_day_last & operator+=(const months &m) noexcept
constexpr const date::month mar
precision to_duration() const noexcept
save_stream(std::basic_ostream< CharT, Traits > &os)
constexpr bool ok() const noexcept
time_of_day_storage & make12() noexcept
constexpr day operator+(const day &x, const days &y) noexcept
days to_days() const noexcept
constexpr time_of_day_storage(Duration since_midnight) noexcept
constexpr std::chrono::time_point< Clock, To > round(const std::chrono::time_point< Clock, FromDuration > &tp)
constexpr date::weekday_last weekday_last() const noexcept
month & operator-=(const months &m) noexcept
year_month_weekday_last & operator-=(const months &m) noexcept
fields(year_month_day ymd_, weekday wd_, time_of_day< Duration > tod_)
constexpr month_weekday(const date::month &m, const date::weekday_indexed &wdi) noexcept
std::chrono::minutes precision
constexpr date::weekday weekday() const noexcept
unsigned extract_month(std::basic_ostream< CharT, Traits > &os, const fields< Duration > &fds)
std::string to_string(std::uint64_t x)
day & operator+=(const days &d) noexcept
std::basic_ostream< CharT, Traits > & to_stream(std::basic_ostream< CharT, Traits > &os, const CharT *fmt, const fields< Duration > &fds, const std::string *abbrev=nullptr, const std::chrono::seconds *offset_sec=nullptr)
constexpr date::year year() const noexcept
constexpr year_month_weekday_last(const date::year &y, const date::month &m, const date::weekday_last &wdl) noexcept
constexpr unsigned mode() const noexcept
constexpr bool ok() const noexcept
month & operator++() noexcept
static year_month_day from_days(days dp) noexcept
constexpr bool ok() const noexcept
parse_manip(std::basic_string< CharT, Traits, Alloc > format, Parsable &tp, std::basic_string< CharT, Traits, Alloc > *abbrev=nullptr, std::chrono::minutes *offset=nullptr)
bool read_char(std::basic_istream< CharT, Traits > &is, CharT fmt, std::ios::iostate &err)
time_of_day< Duration > tod
unsigned extract_weekday(std::basic_ostream< CharT, Traits > &os, const fields< Duration > &fds)
typename dfs::precision precision
local_time< days > local_days
year_month_weekday & operator-=(const months &m) noexcept
constexpr bool operator<(const day &x, const day &y) noexcept
constexpr const date::month jan
constexpr bool operator<=(const day &x, const day &y) noexcept
constexpr const date::month nov
static std::string from(Rep n)
date::month_day_last mdl_
precision to_duration() const noexcept
constexpr date::month month() const noexcept
constexpr std::enable_if< !std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) noexcept
date::day day() const noexcept
static std::basic_string< char, Traits > from(Rep n)
constexpr bool ok() const noexcept
constexpr date::day day() const noexcept
year_month & operator+=(const months &dm) noexcept
std::chrono::time_point< local_t, Duration > local_time
constexpr month_day_last(const date::month &m) noexcept
weekday & operator--() noexcept
year & operator--() noexcept
std::chrono::seconds precision
std::chrono::seconds & seconds() noexcept
To round(const std::chrono::duration< Rep, Period > &d)
local_time< std::chrono::seconds > local_seconds
fields(time_of_day< Duration > tod_)
constexpr weekday_last(const date::weekday &wd) noexcept
constexpr const date::month sep
day & operator--() noexcept
constexpr time_of_day_base() noexcept
constexpr bool ok() const noexcept
year_month_weekday()=default
constexpr bool in_conventional_range() const noexcept
constexpr std::chrono::hours hours() const noexcept
constexpr const date::month aug
day & operator-=(const days &d) noexcept