35#ifndef HAS_STRING_VIEW
36# if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
37# define HAS_STRING_VIEW 1
39# define HAS_STRING_VIEW 0
65# include <string_view>
71# pragma GCC diagnostic push
72# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)
73# pragma GCC diagnostic ignored "-Wpedantic"
77# pragma GCC diagnostic ignored "-Wmissing-field-initializers"
84# pragma warning(disable : 4127)
95# define ONLY_C_LOCALE 0
98#if defined(_MSC_VER) && (!defined(__clang__) || (_MSC_VER < 1910))
100# ifndef _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING
101# define _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING
105# define CONSTDATA const
108# define NOEXCEPT _NOEXCEPT
111# define CONSTDATA constexpr const
112# define CONSTCD11 constexpr
113# define CONSTCD14 constexpr
114# define NOEXCEPT noexcept
117#elif defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x5150
119# define CONSTDATA constexpr const
120# define CONSTCD11 constexpr
122# define NOEXCEPT noexcept
124#elif __cplusplus >= 201402
126# define CONSTDATA constexpr const
127# define CONSTCD11 constexpr
128# define CONSTCD14 constexpr
129# define NOEXCEPT noexcept
132# define CONSTDATA constexpr const
133# define CONSTCD11 constexpr
135# define NOEXCEPT noexcept
138#ifndef HAS_UNCAUGHT_EXCEPTIONS
139# if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
140# define HAS_UNCAUGHT_EXCEPTIONS 1
142# define HAS_UNCAUGHT_EXCEPTIONS 0
147# if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
163template <
typename R1,
typename R2>
166template <
typename R1,
typename R2>
176using days = std::chrono::duration
190template <
class Duration>
191 using sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;
198template <
class Duration>
199 using local_time = std::chrono::time_point<local_t, Duration>;
351template<class CharT, class Traits>
352std::basic_ostream<CharT, Traits>&
353operator<<(std::basic_ostream<CharT, Traits>& os, const
day& d);
389template<class CharT, class Traits>
390std::basic_ostream<CharT, Traits>&
391operator<<(std::basic_ostream<CharT, Traits>& os, const
month& m);
435template<
class CharT,
class Traits>
436std::basic_ostream<CharT, Traits>&
437operator<<(std::basic_ostream<CharT, Traits>& os,
const year& y);
472 template<class CharT, class Traits>
473 friend std::basic_ostream<CharT, Traits>&
474 operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday& wd);
486template<class CharT, class Traits>
487std::basic_ostream<CharT, Traits>&
488operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday& wd);
509template<class CharT, class Traits>
510std::basic_ostream<CharT, Traits>&
511operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday_indexed& wdi);
529template<class CharT, class Traits>
530std::basic_ostream<CharT, Traits>&
531operator<<(std::basic_ostream<CharT, Traits>& os, const
weekday_last& wdl);
583template<class CharT, class Traits>
584std::basic_ostream<CharT, Traits>&
585operator<<(std::basic_ostream<CharT, Traits>& os, const
year_month& ym);
611template<class CharT, class Traits>
612std::basic_ostream<CharT, Traits>&
613operator<<(std::basic_ostream<CharT, Traits>& os, const
month_day& md);
635template<class CharT, class Traits>
636std::basic_ostream<CharT, Traits>&
637operator<<(std::basic_ostream<CharT, Traits>& os, const
month_day_last& mdl);
658template<class CharT, class Traits>
659std::basic_ostream<CharT, Traits>&
660operator<<(std::basic_ostream<CharT, Traits>& os, const
month_weekday& mwd);
684template<class CharT, class Traits>
685std::basic_ostream<CharT, Traits>&
705 template<
class = detail::unspecified_month_disambiguator>
707 template<
class = detail::unspecified_month_disambiguator>
742template<class CharT, class Traits>
743std::basic_ostream<CharT, Traits>&
744operator<<(std::basic_ostream<CharT, Traits>& os, const
year_month_day& ymd);
757 template<
class = detail::unspecified_month_disambiguator>
759 template<
class = detail::unspecified_month_disambiguator>
814template<class CharT, class Traits>
815std::basic_ostream<CharT, Traits>&
833 template<
class = detail::unspecified_month_disambiguator>
835 template<
class = detail::unspecified_month_disambiguator>
887template<class CharT, class Traits>
888std::basic_ostream<CharT, Traits>&
903 template<
class = detail::unspecified_month_disambiguator>
905 template<
class = detail::unspecified_month_disambiguator>
958template<class CharT, class Traits>
959std::basic_ostream<CharT, Traits>&
962#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
963inline namespace literals
995template <
class T,
class = std::
void_t<>>
1001struct is_clock<T, std::void_t<decltype(T::now()), typename T::rep, typename T::period,
1002 typename T::duration, typename T::time_point,
1003 decltype(T::is_steady)>>
1007template<
class T>
inline constexpr bool is_clock_v = is_clock<T>::value;
1018template<
class CharT,
class Traits = std::
char_traits<CharT>>
1022 std::basic_ios<CharT, Traits>&
is_;
1027 std::basic_ostream<CharT, Traits>*
tie_;
1035 is_.precision(precision_);
1047 , flags_(is.flags())
1048 , precision_(is.precision())
1049 , width_(is.
width(0))
1050 , tie_(is.tie(nullptr))
1053 if (tie_ !=
nullptr)
1058template<
class CharT,
class Traits = std::
char_traits<CharT>>
1065 if ((this->flags_ & std::ios::unitbuf) &&
1067 std::uncaught_exceptions() == 0 &&
1069 !std::uncaught_exception() &&
1072 this->is_.rdbuf()->pubsync();
1087 static const int digits = std::numeric_limits<T>::digits;
1088 using type =
typename std::conditional
1092 typename std::conditional
1096#ifdef __SIZEOF_INT128__
1108typename std::enable_if
1110 !std::chrono::treat_as_floating_point<T>::value,
1121typename std::enable_if
1123 std::chrono::treat_as_floating_point<T>::value,
1128 using std::numeric_limits;
1130 CONSTDATA auto digits = numeric_limits<T>::digits;
1131 static_assert(digits < numeric_limits<I>::digits,
"");
1134 const auto negative = t < T{0};
1135 if (
min <= t && t <=
max && t != 0 && t == t)
1137 t =
static_cast<T
>(
static_cast<I
>(t));
1138 if (t == 0 && negative)
1144template <std::
intmax_t Xp, std::
intmax_t Yp>
1150template <std::
intmax_t Xp>
1153 static const std::intmax_t value = Xp;
1159 static const std::intmax_t value = 1;
1162template <
class R1,
class R2>
1168 static const std::intmax_t n1 = R1::num / gcd_n1_n2;
1169 static const std::intmax_t d1 = R1::den / gcd_d1_d2;
1170 static const std::intmax_t n2 = R2::num / gcd_n1_n2;
1171 static const std::intmax_t d2 = R2::den / gcd_d1_d2;
1172#ifdef __cpp_constexpr
1175 static const std::intmax_t
max = LLONG_MAX;
1178 template <std::
intmax_t Xp, std::
intmax_t Yp,
bool overflow>
1181 static const std::intmax_t value = Xp * Yp;
1184 template <std::
intmax_t Xp, std::
intmax_t Yp>
1187 static const std::intmax_t value = 1;
1191 static const bool value = (n1 <=
max / d2) && (n2 <=
max / d1);
1192 typedef std::ratio<mul<n1, d2, !value>::value,
1199template <
class To,
class Rep,
class Period>
1202typename std::enable_if
1207trunc(
const std::chrono::duration<Rep, Period>& d)
1209 return To{
detail::trunc(std::chrono::duration_cast<To>(d).count())};
1212template <
class To,
class Rep,
class Period>
1215typename std::enable_if
1220trunc(
const std::chrono::duration<Rep, Period>& d)
1222 using std::chrono::duration_cast;
1223 using std::chrono::duration;
1224 using rep =
typename std::common_type<Rep, typename To::rep>::type;
1225 return To{
detail::trunc(duration_cast<To>(duration_cast<duration<rep>>(d)).count())};
1228#ifndef HAS_CHRONO_ROUNDING
1229# if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918 || (_MSC_FULL_VER >= 190000000 && defined (__clang__)))
1230# define HAS_CHRONO_ROUNDING 1
1231# elif defined(__cpp_lib_chrono) && __cplusplus > 201402 && __cpp_lib_chrono >= 201510
1232# define HAS_CHRONO_ROUNDING 1
1233# elif defined(_LIBCPP_VERSION) && __cplusplus > 201402 && _LIBCPP_VERSION >= 3800
1234# define HAS_CHRONO_ROUNDING 1
1236# define HAS_CHRONO_ROUNDING 0
1240#if HAS_CHRONO_ROUNDING == 0
1243template <
class To,
class Rep,
class Period>
1246typename std::enable_if
1251floor(
const std::chrono::duration<Rep, Period>& d)
1253 auto t = trunc<To>(d);
1259template <
class To,
class Rep,
class Period>
1262typename std::enable_if
1267floor(
const std::chrono::duration<Rep, Period>& d)
1269 using rep =
typename std::common_type<Rep, typename To::rep>::type;
1270 return floor<To>(
floor<std::chrono::duration<rep>>(d));
1274template <
class To,
class Rep,
class Period>
1278round(
const std::chrono::duration<Rep, Period>& d)
1280 auto t0 = floor<To>(d);
1281 auto t1 = t0 + To{1};
1282 if (t1 == To{0} && t0 < To{0})
1284 auto diff0 = d - t0;
1285 auto diff1 = t1 - d;
1288 if (t0 - trunc<To>(t0/2)*2 == To{0})
1298template <
class To,
class Rep,
class Period>
1302ceil(
const std::chrono::duration<Rep, Period>& d)
1304 auto t = trunc<To>(d);
1310template <
class Rep,
class Period,
1311 class =
typename std::enable_if
1313 std::numeric_limits<Rep>::is_signed
1316std::chrono::duration<Rep, Period>
1317abs(std::chrono::duration<Rep, Period> d)
1319 return d >= d.zero() ? d : -d;
1323template <
class To,
class Clock,
class FromDuration>
1326std::chrono::time_point<Clock, To>
1327floor(
const std::chrono::time_point<Clock, FromDuration>& tp)
1330 return time_point<Clock, To>{date::floor<To>(tp.time_since_epoch())};
1334template <
class To,
class Clock,
class FromDuration>
1337std::chrono::time_point<Clock, To>
1338round(
const std::chrono::time_point<Clock, FromDuration>& tp)
1341 return time_point<Clock, To>{round<To>(tp.time_since_epoch())};
1345template <
class To,
class Clock,
class FromDuration>
1348std::chrono::time_point<Clock, To>
1349ceil(
const std::chrono::time_point<Clock, FromDuration>& tp)
1352 return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
1367template <
class To,
class Rep,
class Period>
1370typename std::enable_if
1372 !std::chrono::treat_as_floating_point<typename To::rep>::value,
1375round_i(
const std::chrono::duration<Rep, Period>& d)
1377 return round<To>(d);
1380template <
class To,
class Rep,
class Period>
1383typename std::enable_if
1385 std::chrono::treat_as_floating_point<typename To::rep>::value,
1388round_i(
const std::chrono::duration<Rep, Period>& d)
1393template <
class To,
class Clock,
class FromDuration>
1396std::chrono::time_point<Clock, To>
1397round_i(
const std::chrono::time_point<Clock, FromDuration>& tp)
1400 return time_point<Clock, To>{round_i<To>(tp.time_since_epoch())};
1406template <
class To,
class Clock,
class FromDuration>
1409std::chrono::time_point<Clock, To>
1410trunc(
const std::chrono::time_point<Clock, FromDuration>& tp)
1413 return time_point<Clock, To>{trunc<To>(tp.time_since_epoch())};
1433 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
1449 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
1481 return days{
static_cast<days::rep
>(
static_cast<unsigned>(x)
1482 -
static_cast<unsigned>(y))};
1490 return day{
static_cast<unsigned>(x) +
static_cast<unsigned>(y.count())};
1512template<
class CharT,
class Traits>
1513std::basic_ostream<CharT, Traits>&
1520 os << static_cast<unsigned>(d);
1526template<
class CharT,
class Traits>
1528std::basic_ostream<CharT, Traits>&
1529operator<<(std::basic_ostream<CharT, Traits>& os,
const day& d)
1533 os <<
" is not a valid day";
1571 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
1587 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
1619 auto const d =
static_cast<unsigned>(x) -
static_cast<unsigned>(y);
1620 return months(d <= 11 ? d : d + 12);
1628 auto const mu =
static_cast<long long>(
static_cast<unsigned>(x)) + y.count() - 1;
1629 auto const yr = (
mu >= 0 ?
mu :
mu-11) / 12;
1630 return month{
static_cast<unsigned>(
mu - yr * 12 + 1)};
1652template<
class CharT,
class Traits>
1653std::basic_ostream<CharT, Traits>&
1658 CharT fmt[] = {
'%',
'b', 0};
1659 os <<
format(os.getloc(), fmt, m);
1662 os << static_cast<unsigned>(m);
1668template<
class CharT,
class Traits>
1670std::basic_ostream<CharT, Traits>&
1671operator<<(std::basic_ostream<CharT, Traits>& os,
const month& m)
1675 os <<
" is not a valid month";
1696 return y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0);
1714 return static_cast<int>(x) ==
static_cast<int>(y);
1730 return static_cast<int>(x) <
static_cast<int>(y);
1762 return years{
static_cast<int>(x) -
static_cast<int>(y)};
1770 return year{
static_cast<int>(x) + y.count()};
1786 return year{
static_cast<int>(x) - y.count()};
1792template<
class CharT,
class Traits>
1793std::basic_ostream<CharT, Traits>&
1799 os.width(4 + (y <
year{0}));
1800 os.imbue(std::locale::classic());
1801 os << static_cast<int>(y);
1807template<
class CharT,
class Traits>
1809std::basic_ostream<CharT, Traits>&
1810operator<<(std::basic_ostream<CharT, Traits>& os,
const year& y)
1814 os <<
" is not a valid year";
1825 auto u =
static_cast<unsigned>(z);
1826 return static_cast<unsigned char>(z >= -4 ? (u+4) % 7 : u % 7);
1832 : wd_(
static_cast<decltype(wd_)
>(wd != 7 ? wd : 0))
1838 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1844 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1876 return unsigned{wd_};
1883 return unsigned{((wd_ == 0u) ? 7u : wd_)};
1891 return x.wd_ == y.wd_;
1907 auto const wdu = x.wd_ - y.wd_;
1908 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1909 return days{wdu - wk * 7};
1917 auto const wdu =
static_cast<long long>(
static_cast<unsigned>(x.wd_)) + y.count();
1918 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1919 return weekday{
static_cast<unsigned>(wdu - wk * 7)};
1941template<
class CharT,
class Traits>
1942std::basic_ostream<CharT, Traits>&
1947 CharT fmt[] = {
'%',
'a', 0};
1957template<
class CharT,
class Traits>
1959std::basic_ostream<CharT, Traits>&
1960operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday& wd)
1964 os <<
" is not a valid weekday";
1968#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1969inline namespace literals
1977 return date::day{
static_cast<unsigned>(d)};
2012#if !defined(_MSC_VER) || (_MSC_VER >= 1900)
2054 return weekday().
ok() && 1 <= index_ && index_ <= 5;
2058# pragma GCC diagnostic push
2059# pragma GCC diagnostic ignored "-Wconversion"
2065 : wd_(
static_cast<decltype(wd_)
>(
static_cast<unsigned>(wd.wd_)))
2066 , index_(
static_cast<decltype(index_)
>(index))
2070# pragma GCC diagnostic pop
2076template<
class CharT,
class Traits>
2077std::basic_ostream<CharT, Traits>&
2085template<
class CharT,
class Traits>
2087std::basic_ostream<CharT, Traits>&
2088operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday_indexed& wdi)
2092 os <<
" is not a valid weekday_indexed";
2101 return {*
this, index};
2109 return x.weekday() == y.weekday() && x.index() == y.index();
2131 return x.weekday() == y.weekday();
2145template<
class CharT,
class Traits>
2146std::basic_ostream<CharT, Traits>&
2154template<
class CharT,
class Traits>
2156std::basic_ostream<CharT, Traits>&
2157operator<<(std::basic_ostream<CharT, Traits>& os,
const weekday_last& wdl)
2161 os <<
" is not a valid weekday_last";
2229 return x.year() == y.year() && x.month() == y.month();
2245 return x.year() < y.year() ? true
2246 : (x.year() > y.year() ? false
2247 : (x.month() < y.month()));
2280 auto dmi =
static_cast<int>(
static_cast<unsigned>(ym.month())) - 1 + dm.count();
2281 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
2282 dmi = dmi - dy * 12 + 1;
2283 return (ym.year() +
years(dy)) /
month(
static_cast<unsigned>(dmi));
2309 return (x.year() - y.year()) +
2310 months(
static_cast<unsigned>(x.month()) -
static_cast<unsigned>(y.month()));
2318 return (ym.year() + dy) / ym.month();
2340template<
class CharT,
class Traits>
2341std::basic_ostream<CharT, Traits>&
2350template<
class CharT,
class Traits>
2352std::basic_ostream<CharT, Traits>&
2353operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month& ym)
2357 os <<
" is not a valid year_month";
2385 return m_.
ok() &&
date::day{1} <=
d_ && d_ <= d[static_cast<unsigned>(m_)-1];
2393 return x.month() == y.month() && x.day() == y.day();
2409 return x.month() < y.month() ? true
2410 : (x.month() > y.month() ? false
2411 : (x.day() < y.day()));
2441template<
class CharT,
class Traits>
2442std::basic_ostream<CharT, Traits>&
2451template<
class CharT,
class Traits>
2453std::basic_ostream<CharT, Traits>&
2454operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day& md)
2458 os <<
" is not a valid month_day";
2473 return x.month() == y.month();
2489 return x.month() < y.month();
2519template<
class CharT,
class Traits>
2520std::basic_ostream<CharT, Traits>&
2528template<
class CharT,
class Traits>
2530std::basic_ostream<CharT, Traits>&
2531operator<<(std::basic_ostream<CharT, Traits>& os,
const month_day_last& mdl)
2535 os <<
" is not a valid month_day_last";
2564 return m_.
ok() && wdi_.
ok();
2572 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
2586template<
class CharT,
class Traits>
2587std::basic_ostream<CharT, Traits>&
2596template<
class CharT,
class Traits>
2598std::basic_ostream<CharT, Traits>&
2599operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday& mwd)
2603 os <<
" is not a valid month_weekday";
2632 return m_.
ok() && wdl_.
ok();
2640 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
2654template<
class CharT,
class Traits>
2655std::basic_ostream<CharT, Traits>&
2664template<
class CharT,
class Traits>
2666std::basic_ostream<CharT, Traits>&
2667operator<<(std::basic_ostream<CharT, Traits>& os,
const month_weekday_last& mwdl)
2671 os <<
" is not a valid month_weekday_last";
2769 return y_.
ok() && mdl_.
ok();
2777 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
2793 return x.year() < y.year() ? true
2794 : (x.year() > y.year() ? false
2795 : (x.month_day_last() < y.month_day_last()));
2825template<
class CharT,
class Traits>
2826std::basic_ostream<CharT, Traits>&
2835template<
class CharT,
class Traits>
2837std::basic_ostream<CharT, Traits>&
2838operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day_last& ymdl)
2842 os <<
" is not a valid year_month_day_last";
2852 return (ymdl.year() / ymdl.month() + dm) /
last;
2870 return ymdl + (-dm);
2878 return {ymdl.year()+dy, ymdl.month_day_last()};
2894 return ymdl + (-dy);
2975 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2976 "This algorithm has not been ported to a 16 bit unsigned integer");
2977 static_assert(std::numeric_limits<int>::digits >= 20,
2978 "This algorithm has not been ported to a 16 bit signed integer");
2979 auto const y =
static_cast<int>(y_) - (m_ <=
February);
2980 auto const m =
static_cast<unsigned>(m_);
2981 auto const d =
static_cast<unsigned>(
d_);
2982 auto const era = (y >= 0 ? y : y-399) / 400;
2983 auto const yoe =
static_cast<unsigned>(y - era * 400);
2984 auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1;
2985 auto const doe = yoe * 365 + yoe/4 - yoe/100 + doy;
2986 return days{era * 146097 +
static_cast<int>(doe) - 719468};
3008 if (!(y_.
ok() && m_.
ok()))
3018 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
3034 return x.year() < y.year() ? true
3035 : (x.year() > y.year() ? false
3036 : (x.month() < y.month() ? true
3037 : (x.month() > y.month() ? false
3038 : (x.day() < y.day()))));
3065template<
class CharT,
class Traits>
3067std::basic_ostream<CharT, Traits>&
3068operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_day& ymd)
3070 detail::save_ostream<CharT, Traits> _(os);
3073 os.imbue(std::locale::classic());
3074 os << static_cast<int>(ymd.year()) <<
'-';
3076 os << static_cast<unsigned>(ymd.month()) <<
'-';
3078 os << static_cast<unsigned>(ymd.day());
3080 os <<
" is not a valid year_month_day";
3089 static_assert(std::numeric_limits<unsigned>::digits >= 18,
3090 "This algorithm has not been ported to a 16 bit unsigned integer");
3091 static_assert(std::numeric_limits<int>::digits >= 20,
3092 "This algorithm has not been ported to a 16 bit signed integer");
3093 auto const z = dp.count() + 719468;
3094 auto const era = (z >= 0 ? z : z - 146096) / 146097;
3095 auto const doe =
static_cast<unsigned>(z - era * 146097);
3096 auto const yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365;
3097 auto const y =
static_cast<days::rep
>(yoe) + era * 400;
3098 auto const doy = doe - (365*yoe + yoe/4 - yoe/100);
3099 auto const mp = (5*doy + 2)/153;
3100 auto const d = doy - (153*mp+2)/5 + 1;
3101 auto const m = mp < 10 ? mp+3 : mp-9;
3111 return (ymd.year() / ymd.month() + dm) / ymd.day();
3137 return (ymd.year() + dy) / ymd.month() / ymd.day();
3234 return wdi_.
index();
3266 if (wdi_.
index() <= 4)
3270 return static_cast<unsigned>(d2.count()) <=
static_cast<unsigned>((y_/m_/
last).day());
3281 return {ymd.year(), ymd.month(), wd[(
static_cast<unsigned>(ymd.day())-1)/7+1]};
3291 ).time_since_epoch();
3299 return x.year() == y.year() && x.month() == y.month() &&
3300 x.weekday_indexed() == y.weekday_indexed();
3311template<
class CharT,
class Traits>
3313std::basic_ostream<CharT, Traits>&
3314operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday& ymwdi)
3320 os <<
" is not a valid year_month_weekday";
3330 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
3348 return ymwd + (-dm);
3356 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
3372 return ymwd + (-dy);
3463 return y_.
ok() && m_.
ok() && wdl_.
ok();
3480 return x.year() == y.year() && x.month() == y.month() &&
3481 x.weekday_last() == y.weekday_last();
3492template<
class CharT,
class Traits>
3494std::basic_ostream<CharT, Traits>&
3495operator<<(std::basic_ostream<CharT, Traits>& os,
const year_month_weekday_last& ymwdl)
3501 os <<
" is not a valid year_month_weekday_last";
3508year_month_weekday_last
3511 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
3517year_month_weekday_last
3526year_month_weekday_last
3529 return ymwdl + (-dm);
3534year_month_weekday_last
3537 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
3542year_month_weekday_last
3550year_month_weekday_last
3553 return ymwdl + (-dy);
3571 return y /
month(
static_cast<unsigned>(m));
3597 return m /
day(
static_cast<unsigned>(d));
3605 return month(
static_cast<unsigned>(m)) / d;
3633 return month(
static_cast<unsigned>(m))/
last;
3667 return month(
static_cast<unsigned>(m)) / wdi;
3701 return month(
static_cast<unsigned>(m)) / wdl;
3719 return {ym.year(), ym.month(), d};
3727 return ym /
day(
static_cast<unsigned>(d));
3735 return y / md.month() / md.day();
3743 return year(y) / md;
3759 return year(y) / md;
3785 return year(y) / mdl;
3801 return year(y) / mdl;
3811 return {ym.year(), ym.month(), wdi};
3819 return {y, mwd.month(), mwd.weekday_indexed()};
3827 return year(y) / mwd;
3843 return year(y) / mwd;
3850year_month_weekday_last
3853 return {ym.year(), ym.month(), wdl};
3858year_month_weekday_last
3861 return {y, mwdl.month(), mwdl.weekday_last()};
3866year_month_weekday_last
3869 return year(y) / mwdl;
3874year_month_weekday_last
3882year_month_weekday_last
3885 return year(y) / mwdl;
3888template <
class Duration>
3891template <
class CharT,
class Traits,
class Duration>
3892std::basic_ostream<CharT, Traits>&
3893to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
3894 const fields<Duration>& fds,
const std::string* abbrev =
nullptr,
3895 const std::chrono::seconds* offset_sec =
nullptr);
3897template <
class CharT,
class Traits,
class Duration,
class Alloc>
3898std::basic_istream<CharT, Traits>&
3899from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt,
3900 fields<Duration>& fds, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
3901 std::chrono::minutes* offset =
nullptr);
3919template <std::uint64_t n, std::uint64_t d,
unsigned w = 0,
3920 bool should_continue = n%d != 0 && (w < 19)>
3923 static_assert(d > 0,
"width called with zero denominator");
3927template <std::u
int64_t n, std::u
int64_t d,
unsigned w>
3933template <
unsigned exp>
3939 static CONSTDATA std::uint64_t value = h * h * (exp % 2 ? 10 : 1);
3948template <
class Duration>
3951 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
3958 std::ratio<1, static_pow10<width>::value>>;
3971 : s_(std::chrono::duration_cast<std::chrono::seconds>(d))
3972 , sub_s_(std::chrono::duration_cast<precision>(d - s_))
3986 return sub_s_ < std::chrono::seconds{1} && s_ < std::chrono::minutes{1};
3989 template <
class CharT,
class Traits>
3991 std::basic_ostream<CharT, Traits>&
3994 return x.
print(os, std::chrono::treat_as_floating_point<rep>{});
3997 template <
class CharT,
class Traits>
3998 std::basic_ostream<CharT, Traits>&
3999 print(std::basic_ostream<CharT, Traits>& os, std::true_type)
const
4002 std::chrono::duration<rep> d = s_ + sub_s_;
4003 if (d < std::chrono::seconds{10})
4005 os.precision(
width+6);
4010 template <
class CharT,
class Traits>
4011 std::basic_ostream<CharT, Traits>&
4012 print(std::basic_ostream<CharT, Traits>& os, std::false_type)
const
4022 os << std::use_facet<std::numpunct<CharT>>(os.getloc()).decimal_point();
4027 os.imbue(std::locale::classic());
4029 os << sub_s_.count();
4035template <
class Rep,
class Period>
4038typename std::enable_if
4040 std::numeric_limits<Rep>::is_signed,
4041 std::chrono::duration<Rep, Period>
4043abs(std::chrono::duration<Rep, Period> d)
4045 return d >= d.zero() ? +d : -d;
4048template <
class Rep,
class Period>
4051typename std::enable_if
4053 !std::numeric_limits<Rep>::is_signed,
4054 std::chrono::duration<Rep, Period>
4056abs(std::chrono::duration<Rep, Period> d)
4063template <
class Duration>
4067 std::chrono::seconds>::type>;
4083 : h_(std::chrono::duration_cast<std::chrono::hours>(
detail::abs(d)))
4084 , m_(std::chrono::duration_cast<std::chrono::minutes>(
detail::abs(d)) - h_)
4086 , neg_(d < Duration::zero())
4099 {
return (s_.
to_duration() + m_ + h_) * (1-2*neg_);}
4103 return !neg_ && h_ <
days{1} && m_ < std::chrono::hours{1} &&
4109 template <
class charT,
class traits>
4111 std::basic_ostream<charT, traits>&
4116 if (tod.
h_ < std::chrono::hours{10})
4118 os << tod.
h_.count() <<
':';
4119 if (tod.
m_ < std::chrono::minutes{10})
4121 os << tod.
m_.count() <<
':' << tod.
s_;
4125 template <
class CharT,
class Traits,
class Duration2>
4127 std::basic_ostream<CharT, Traits>&
4130 const std::chrono::seconds* offset_sec);
4132 template <
class CharT,
class Traits,
class Duration2,
class Alloc>
4134 std::basic_istream<CharT, Traits>&
4137 std::basic_string<CharT, Traits, Alloc>* abbrev, std::chrono::minutes* offset);
4145 using std::chrono::hours;
4146 return hours{0} <= h && h < hours{12};
4154 using std::chrono::hours;
4155 return hours{12} <= h && h < hours{24};
4163 using std::chrono::hours;
4182 using std::chrono::hours;
4188 else if (h == hours{12})
4193template <
class Duration>
4196template <
class Rep,
class Period>
4205template <
class CharT,
class Traits,
class Duration>
4207typename std::enable_if
4209 std::ratio_less<typename Duration::period, days::period>::value
4210 , std::basic_ostream<CharT, Traits>&
4214 auto const dp = date::floor<days>(tp);
4218template <
class CharT,
class Traits>
4220std::basic_ostream<CharT, Traits>&
4223 return os << year_month_day(dp);
4226template <
class CharT,
class Traits,
class Duration>
4228std::basic_ostream<CharT, Traits>&
4229operator<<(std::basic_ostream<CharT, Traits>& os,
const local_time<Duration>& ut)
4231 return (os << sys_time<Duration>{ut.time_since_epoch()});
4237template <
class CharT, std::
size_t N>
4240template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4243string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4247template <
class CharT, std::
size_t N>
4257 using const_iterator =
const CharT*;
4262 template <std::size_t N1 = 2,
4263 class =
typename std::enable_if<N1 == N>::type>
4269 template <std::size_t N1 = 3,
4270 class =
typename std::enable_if<N1 == N>::type>
4276 template <std::size_t N1 = 4,
4277 class =
typename std::enable_if<N1 == N>::type>
4286 for (std::size_t i = 0; i < N; ++i)
4290 template <
class U = CharT,
4291 class =
typename std::enable_if<(1 <
sizeof(U))>::type>
4295 for (std::size_t i = 0; i < N; ++i)
4299 template <
class CharT2,
4300 class =
typename std::enable_if<!std::is_same<CharT2, CharT>::value>::type>
4304 for (std::size_t i = 0; i < N; ++i)
4319 template <
class Traits>
4321 std::basic_ostream<CharT, Traits>&
4322 operator<<(std::basic_ostream<CharT, Traits>& os,
const string_literal& s)
4327 template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4330 string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4332 operator+(
const string_literal<CharT1, N1>& x,
const string_literal<CharT2, N2>& y)
NOEXCEPT;
4335template <
class CharT>
4338string_literal<CharT, 3>
4339operator+(
const string_literal<CharT, 2>& x,
const string_literal<CharT, 2>& y)
NOEXCEPT
4341 return string_literal<CharT, 3>(x[0], y[0]);
4344template <
class CharT>
4347string_literal<CharT, 4>
4348operator+(
const string_literal<CharT, 3>& x,
const string_literal<CharT, 2>& y)
NOEXCEPT
4350 return string_literal<CharT, 4>(x[0], x[1], y[0]);
4353template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4356string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4358operator+(
const string_literal<CharT1, N1>& x,
const string_literal<CharT2, N2>& y)
NOEXCEPT
4360 using CT =
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type;
4362 string_literal<CT, N1 + N2 - 1> r;
4364 for (; i < N1-1; ++i)
4365 r.p_[i] = CT(x.p_[i]);
4366 for (std::size_t j = 0; j < N2; ++j, ++i)
4367 r.p_[i] = CT(y.p_[j]);
4373template <
class CharT,
class Traits,
class Alloc, std::
size_t N>
4375std::basic_string<CharT, Traits, Alloc>
4376operator+(std::basic_string<CharT, Traits, Alloc> x,
const string_literal<CharT, N>& y)
4378 x.append(y.data(), y.size());
4382#if __cplusplus >= 201402 && (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 411) \
4383 && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5150)
4385template <
class CharT,
4386 class = std::enable_if_t<std::is_same<CharT, char>::value ||
4387 std::is_same<CharT, wchar_t>::value ||
4388 std::is_same<CharT, char16_t>::value ||
4389 std::is_same<CharT, char32_t>::value>>
4392string_literal<CharT, 2>
4395 return string_literal<CharT, 2>{c};
4401to_string_len(std::intmax_t i)
4412template <std::
intmax_t N>
4418 string_literal<char, to_string_len(N)+1>
4422 return msl(
char(N % 10 +
'0'));
4425template <std::
intmax_t N>
4431 string_literal<char, to_string_len(N)+1>
4435 return msl<N/10>() + msl(
char(N % 10 +
'0'));
4438template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4443 std::ratio<N, D>::type::den != 1,
4444 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) +
4445 to_string_len(std::ratio<N, D>::type::den) + 4>
4449 using R =
typename std::ratio<N, D>::type;
4450 return msl(CharT{
'['}) + msl<R::num>() + msl(CharT{
'/'}) +
4451 msl<R::den>() + msl(CharT{
']'});
4454template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4459 std::ratio<N, D>::type::den == 1,
4460 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) + 3>
4464 using R =
typename std::ratio<N, D>::type;
4465 return msl(CharT{
'['}) + msl<R::num>() + msl(CharT{
']'});
4473to_string(std::uint64_t x)
4475 return std::to_string(x);
4478template <
class CharT>
4480std::basic_string<CharT>
4481to_string(std::uint64_t x)
4483 auto y = std::to_string(x);
4484 return std::basic_string<CharT>(y.begin(), y.end());
4487template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4489typename std::enable_if
4491 std::ratio<N, D>::type::den != 1,
4492 std::basic_string<CharT>
4494msl(std::ratio<N, D>)
4496 using R =
typename std::ratio<N, D>::type;
4497 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
'/'} +
4498 to_string<CharT>(R::den) + CharT{
']'};
4501template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4503typename std::enable_if
4505 std::ratio<N, D>::type::den == 1,
4506 std::basic_string<CharT>
4508msl(std::ratio<N, D>)
4510 using R =
typename std::ratio<N, D>::type;
4511 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
']'};
4516template <
class CharT>
4519string_literal<CharT, 2>
4522 return string_literal<CharT, 2>{
'a'};
4525template <
class CharT>
4528string_literal<CharT, 2>
4531 return string_literal<CharT, 2>{
'f'};
4534template <
class CharT>
4537string_literal<CharT, 2>
4540 return string_literal<CharT, 2>{
'p'};
4543template <
class CharT>
4546string_literal<CharT, 2>
4549 return string_literal<CharT, 2>{
'n'};
4552template <
class CharT>
4555typename std::enable_if
4557 std::is_same<CharT, char>::value,
4558 string_literal<char, 3>
4562 return string_literal<char, 3>{
'\xC2',
'\xB5'};
4565template <
class CharT>
4568typename std::enable_if
4570 !std::is_same<CharT, char>::value,
4571 string_literal<CharT, 2>
4575 return string_literal<CharT, 2>{CharT{
static_cast<unsigned char>(
'\xB5')}};
4578template <
class CharT>
4581string_literal<CharT, 2>
4584 return string_literal<CharT, 2>{
'm'};
4587template <
class CharT>
4590string_literal<CharT, 2>
4593 return string_literal<CharT, 2>{
'c'};
4596template <
class CharT>
4599string_literal<CharT, 3>
4602 return string_literal<CharT, 3>{
'd',
'a'};
4605template <
class CharT>
4608string_literal<CharT, 2>
4611 return string_literal<CharT, 2>{
'd'};
4614template <
class CharT>
4617string_literal<CharT, 2>
4620 return string_literal<CharT, 2>{
'h'};
4623template <
class CharT>
4626string_literal<CharT, 2>
4629 return string_literal<CharT, 2>{
'k'};
4632template <
class CharT>
4635string_literal<CharT, 2>
4638 return string_literal<CharT, 2>{
'M'};
4641template <
class CharT>
4644string_literal<CharT, 2>
4647 return string_literal<CharT, 2>{
'G'};
4650template <
class CharT>
4653string_literal<CharT, 2>
4656 return string_literal<CharT, 2>{
'T'};
4659template <
class CharT>
4662string_literal<CharT, 2>
4665 return string_literal<CharT, 2>{
'P'};
4668template <
class CharT>
4671string_literal<CharT, 2>
4674 return string_literal<CharT, 2>{
'E'};
4677template <
class CharT,
class Period>
4682 ->
decltype(msl<CharT>(p) + string_literal<CharT, 2>{
's'})
4684 return msl<CharT>(p) + string_literal<CharT, 2>{
's'};
4687template <
class CharT>
4690string_literal<CharT, 2>
4691get_units(std::ratio<1>)
4693 return string_literal<CharT, 2>{
's'};
4696template <
class CharT>
4699string_literal<CharT, 2>
4700get_units(std::ratio<3600>)
4702 return string_literal<CharT, 2>{
'h'};
4705template <
class CharT>
4708string_literal<CharT, 4>
4709get_units(std::ratio<60>)
4711 return string_literal<CharT, 4>{
'm',
'i',
'n'};
4714template <
class CharT>
4717string_literal<CharT, 2>
4718get_units(std::ratio<86400>)
4720 return string_literal<CharT, 2>{
'd'};
4723template <
class CharT,
class Traits = std::
char_traits<CharT>>
4727struct make_string<char>
4729 template <
class Rep>
4734 return std::to_string(n);
4738template <
class Traits>
4739struct make_string<char, Traits>
4741 template <
class Rep>
4743 std::basic_string<char, Traits>
4746 auto s = std::to_string(n);
4747 return std::basic_string<char, Traits>(s.begin(), s.end());
4752struct make_string<wchar_t>
4754 template <
class Rep>
4759 return std::to_string(n);
4763template <
class Traits>
4764struct make_string<wchar_t, Traits>
4766 template <
class Rep>
4768 std::basic_string<wchar_t, Traits>
4771 auto s = std::to_string(n);
4772 return std::basic_string<wchar_t, Traits>(s.begin(), s.end());
4782template <
class Duration>
4788 bool has_tod =
false;
4790#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__ <= 409)
4791 fields() : ymd{
nanyear/0/0}, wd{8u}, tod{}, has_tod{false} {}
4817template <
class CharT,
class Traits,
class Duration>
4824 os.setstate(std::ios::failbit);
4831 if (fds.
wd.
ok() && wd != fds.
wd)
4834 os.setstate(std::ios::failbit);
4840 return static_cast<unsigned>((wd -
Sunday).count());
4843template <
class CharT,
class Traits,
class Duration>
4850 os.setstate(std::ios::failbit);
4853 return static_cast<unsigned>(fds.
ymd.
month());
4864std::pair<const std::string*, const std::string*>
4867 static const std::string nm[] =
4884 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4888std::pair<const std::string*, const std::string*>
4891 static const std::string nm[] =
4918 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4922std::pair<const std::string*, const std::string*>
4925 static const std::string nm[] =
4930 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4933template <
class CharT,
class Traits,
class FwdIter>
4935scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
4937 size_t nkw =
static_cast<size_t>(std::distance(kb, ke));
4938 const unsigned char doesnt_match =
'\0';
4939 const unsigned char might_match =
'\1';
4940 const unsigned char does_match =
'\2';
4941 unsigned char statbuf[100];
4942 unsigned char* status = statbuf;
4943 std::unique_ptr<
unsigned char, void(*)(
void*)> stat_hold(0, free);
4944 if (nkw >
sizeof(statbuf))
4946 status = (
unsigned char*)std::malloc(nkw);
4947 if (status ==
nullptr)
4948 throw std::bad_alloc();
4949 stat_hold.reset(status);
4951 size_t n_might_match = nkw;
4952 size_t n_does_match = 0;
4954 unsigned char* st = status;
4955 for (
auto ky = kb; ky != ke; ++ky, ++st)
4967 for (
size_t indx = 0; is && n_might_match > 0; ++indx)
4970 auto ic = is.peek();
4973 is.setstate(std::ios::eofbit);
4976 auto c =
static_cast<char>(toupper(
static_cast<unsigned char>(ic)));
4977 bool consume =
false;
4985 for (
auto ky = kb; ky != ke; ++ky, ++st)
4987 if (*st == might_match)
4989 if (c ==
static_cast<char>(toupper(
static_cast<unsigned char>((*ky)[indx]))))
4992 if (ky->size() == indx+1)
5013 if (n_might_match + n_does_match > 1)
5016 for (
auto ky = kb; ky != ke; ++ky, ++st)
5018 if (*st == does_match && ky->size() != indx+1)
5029 for (st = status; kb != ke; ++kb, ++st)
5030 if (*st == does_match)
5033 is.setstate(std::ios::failbit);
5041template <
class CharT,
class Traits,
class Duration>
5042std::basic_ostream<CharT, Traits>&
5043to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5045 const std::chrono::seconds* offset_sec)
5048 using detail::weekday_names;
5049 using detail::month_names;
5050 using detail::ampm_names;
5053 using detail::get_units;
5057 using std::chrono::duration_cast;
5058 using std::chrono::seconds;
5059 using std::chrono::minutes;
5060 using std::chrono::hours;
5066 bool insert_negative = fds.
has_tod && fds.
tod.to_duration() < Duration::zero();
5068 auto& facet = std::use_facet<std::time_put<CharT>>(os.getloc());
5070 const CharT* command =
nullptr;
5071 CharT modified = CharT{};
5080 if (modified == CharT{})
5086 const CharT f[] = {
'%', *fmt};
5087 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5089 os << weekday_names().first[tm.tm_wday+7*(*fmt ==
'a')];
5094 os << CharT{
'%'} << modified << *fmt;
5107 if (modified == CharT{})
5111 const CharT f[] = {
'%', *fmt};
5112 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5114 os << month_names().first[tm.tm_mon+12*(*fmt !=
'B')];
5119 os << CharT{
'%'} << modified << *fmt;
5131 if (modified == CharT{
'O'})
5132 os << CharT{
'%'} << modified << *fmt;
5136 os.setstate(std::ios::failbit);
5137 if (*fmt ==
'c' && !fds.
has_tod)
5138 os.setstate(std::ios::failbit);
5141 auto const& ymd = fds.
ymd;
5145 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
5146 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5147 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5149 tm.tm_mday =
static_cast<int>(
static_cast<unsigned>(ymd.day()));
5151 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5155 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5157 auto fe = std::begin(f) + 1;
5158 if (modified == CharT{
'E'})
5161 facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
5166 os << weekday_names().first[
static_cast<unsigned>(wd)+7]
5168 os << month_names().first[
extract_month(os, fds)-1+12] <<
' ';
5169 auto d =
static_cast<int>(
static_cast<unsigned>(fds.
ymd.
day()));
5173 <<
make_time(duration_cast<seconds>(fds.
tod.to_duration()))
5179 auto const& ymd = fds.
ymd;
5184 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
5186 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
5188 os << static_cast<int>(ymd.year()) % 100;
5201 if (modified == CharT{
'O'})
5202 os << CharT{
'%'} << modified << *fmt;
5206 os.setstate(std::ios::failbit);
5207 auto y =
static_cast<int>(fds.
ymd.
year());
5209 if (modified == CharT{})
5228 else if (modified == CharT{
'E'})
5230 tm.tm_year = y - 1900;
5231 CharT f[3] = {
'%',
'E',
'C'};
5232 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5246 if (modified == CharT{
'E'})
5247 os << CharT{
'%'} << modified << *fmt;
5251 os.setstate(std::ios::failbit);
5252 auto d =
static_cast<int>(
static_cast<unsigned>(fds.
ymd.
day()));
5254 if (modified == CharT{})
5258 if (*fmt == CharT{
'd'})
5267 else if (modified == CharT{
'O'})
5270 CharT f[3] = {
'%',
'O', *fmt};
5271 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5284 if (modified == CharT{})
5287 os.setstate(std::ios::failbit);
5288 auto const& ymd = fds.
ymd;
5293 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
5295 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
5297 os << static_cast<int>(ymd.year()) % 100;
5301 os << CharT{
'%'} << modified << *fmt;
5312 if (modified == CharT{})
5315 os.setstate(std::ios::failbit);
5316 auto const& ymd = fds.
ymd;
5318 os.imbue(std::locale::classic());
5322 os << static_cast<int>(ymd.year()) << CharT{
'-'};
5324 os << static_cast<unsigned>(ymd.month()) << CharT{
'-'};
5326 os << static_cast<unsigned>(ymd.day());
5330 os << CharT{
'%'} << modified << *fmt;
5342 if (modified == CharT{})
5345 os.setstate(std::ios::failbit);
5352 if (*fmt == CharT{
'G'})
5360 os << std::abs(static_cast<int>(y)) % 100;
5365 os << CharT{
'%'} << modified << *fmt;
5377 if (modified == CharT{
'E'})
5378 os << CharT{
'%'} << modified << *fmt;
5382 os.setstate(std::ios::failbit);
5383 if (insert_negative)
5386 insert_negative =
false;
5390 if (modified == CharT{})
5393 auto h = *fmt == CharT{
'I'} ?
date::make12(hms.hours()) : hms.hours();
5399 else if (modified == CharT{
'O'})
5401 const CharT f[] = {
'%', modified, *fmt};
5402 tm.tm_hour =
static_cast<int>(hms.hours().count());
5403 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5416 if (modified == CharT{})
5429 doy = duration_cast<days>(fds.
tod.to_duration());
5439 os.setstate(std::ios::failbit);
5444 os << CharT{
'%'} << modified << *fmt;
5455 if (modified == CharT{
'E'})
5456 os << CharT{
'%'} << modified << *fmt;
5460 os.setstate(std::ios::failbit);
5461 auto m =
static_cast<unsigned>(fds.
ymd.
month());
5463 if (modified == CharT{})
5471 else if (modified == CharT{
'O'})
5473 const CharT f[] = {
'%', modified, *fmt};
5474 tm.tm_mon =
static_cast<int>(m-1);
5475 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5488 if (modified == CharT{
'E'})
5489 os << CharT{
'%'} << modified << *fmt;
5493 os.setstate(std::ios::failbit);
5494 if (insert_negative)
5497 insert_negative =
false;
5500 if (modified == CharT{})
5503 if (fds.
tod.minutes() < minutes{10})
5505 os << fds.
tod.minutes().count();
5508 else if (modified == CharT{
'O'})
5510 const CharT f[] = {
'%', modified, *fmt};
5511 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5512 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5525 if (modified == CharT{})
5529 os << CharT{
'%'} << modified << *fmt;
5540 if (modified == CharT{})
5543 os.setstate(std::ios::failbit);
5545 const CharT f[] = {
'%', *fmt};
5546 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5547 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5550 os << ampm_names().first[0];
5552 os << ampm_names().first[1];
5557 os << CharT{
'%'} << modified << *fmt;
5569 if (modified == CharT{})
5572 os.setstate(std::ios::failbit);
5573 auto d = fds.
tod.to_duration();
5575 os << get_units<CharT>(
typename decltype(d)::period::type{});
5581 os << CharT{
'%'} << modified << *fmt;
5592 if (modified == CharT{})
5595 os.setstate(std::ios::failbit);
5597 const CharT f[] = {
'%', *fmt};
5598 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5599 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5600 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
5601 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5609 os << tod.
minutes().count() << CharT{
':'};
5611 os << tod.
seconds().count() << CharT{
' '};
5613 os << ampm_names().first[0];
5615 os << ampm_names().first[1];
5620 os << CharT{
'%'} << modified << *fmt;
5631 if (modified == CharT{})
5634 os.setstate(std::ios::failbit);
5635 if (fds.
tod.hours() < hours{10})
5637 os << fds.
tod.hours().count() << CharT{
':'};
5638 if (fds.
tod.minutes() < minutes{10})
5640 os << fds.
tod.minutes().count();
5644 os << CharT{
'%'} << modified << *fmt;
5655 if (modified == CharT{
'E'})
5656 os << CharT{
'%'} << modified << *fmt;
5660 os.setstate(std::ios::failbit);
5661 if (insert_negative)
5664 insert_negative =
false;
5667 if (modified == CharT{})
5673 else if (modified == CharT{
'O'})
5675 const CharT f[] = {
'%', modified, *fmt};
5676 tm.tm_sec =
static_cast<int>(fds.
tod.s_.seconds().count());
5677 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5690 if (modified == CharT{})
5694 os << CharT{
'%'} << modified << *fmt;
5705 if (modified == CharT{})
5708 os.setstate(std::ios::failbit);
5713 os << CharT{
'%'} << modified << *fmt;
5724 if (modified == CharT{
'E'})
5725 os << CharT{
'%'} << modified << *fmt;
5730 if (modified == CharT{})
5733 os << (wd != 0 ? wd : 7u);
5736 else if (modified == CharT{
'O'})
5738 const CharT f[] = {
'%', modified, *fmt};
5739 tm.tm_wday =
static_cast<int>(wd);
5740 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5753 if (modified == CharT{
'E'})
5754 os << CharT{
'%'} << modified << *fmt;
5757 auto const& ymd = fds.
ymd;
5759 os.setstate(std::ios::failbit);
5762 if (modified == CharT{})
5767 os << CharT{
'0'} << CharT{
'0'};
5770 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5777 else if (modified == CharT{
'O'})
5779 const CharT f[] = {
'%', modified, *fmt};
5780 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5784 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5785 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5798 if (modified == CharT{
'E'})
5799 os << CharT{
'%'} << modified << *fmt;
5803 os.setstate(std::ios::failbit);
5806 if (modified == CharT{})
5818 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5824 else if (modified == CharT{
'O'})
5826 const CharT f[] = {
'%', modified, *fmt};
5827 auto const& ymd = fds.
ymd;
5828 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5832 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5833 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5850 if (modified == CharT{})
5852 if (modified != CharT{
'E'})
5858 else if (modified == CharT{
'O'})
5860 const CharT f[] = {
'%', modified, *fmt};
5861 tm.tm_wday =
static_cast<int>(wd);
5862 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5867 os << CharT{
'%'} << modified << *fmt;
5878 if (modified == CharT{
'E'})
5879 os << CharT{
'%'} << modified << *fmt;
5882 auto const& ymd = fds.
ymd;
5884 os.setstate(std::ios::failbit);
5887 if (modified == CharT{})
5892 os << CharT{
'0'} << CharT{
'0'};
5895 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5902 else if (modified == CharT{
'O'})
5904 const CharT f[] = {
'%', modified, *fmt};
5905 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5909 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5910 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5923 if (modified == CharT{
'O'})
5924 os << CharT{
'%'} << modified << *fmt;
5928 os.setstate(std::ios::failbit);
5931 tm.tm_sec =
static_cast<int>(fds.
tod.seconds().count());
5932 tm.tm_min =
static_cast<int>(fds.
tod.minutes().count());
5933 tm.tm_hour =
static_cast<int>(fds.
tod.hours().count());
5935 auto fe = std::begin(f) + 1;
5936 if (modified == CharT{
'E'})
5939 facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
5954 os.setstate(std::ios::failbit);
5955 auto y =
static_cast<int>(fds.
ymd.
year());
5957 if (modified == CharT{})
5968 const CharT f[] = {
'%', modified, *fmt};
5969 tm.tm_year = y - 1900;
5970 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5982 if (modified == CharT{
'O'})
5983 os << CharT{
'%'} << modified << *fmt;
5987 os.setstate(std::ios::failbit);
5990 if (modified == CharT{})
5994 os.imbue(std::locale::classic());
5998 else if (modified == CharT{
'E'})
6000 const CharT f[] = {
'%', modified, *fmt};
6001 tm.tm_year =
static_cast<int>(y) - 1900;
6002 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
6015 if (offset_sec ==
nullptr)
6018 os.setstate(ios::failbit);
6021 auto m = duration_cast<minutes>(*offset_sec);
6022 auto neg = m < minutes{0};
6024 auto h = duration_cast<hours>(m);
6033 if (modified != CharT{})
6035 if (m < minutes{10})
6047 if (modified == CharT{})
6049 if (abbrev ==
nullptr)
6052 os.setstate(ios::failbit);
6055 for (
auto c : *abbrev)
6060 os << CharT{
'%'} << modified << *fmt;
6072 if (modified == CharT{})
6078 os << CharT{
'%'} << modified << *fmt;
6089 if (modified == CharT{})
6096 os << CharT{
'%'} << modified << CharT{
'%'};
6110 if (modified != CharT{})
6121 if (modified != CharT{})
6126template <
class CharT,
class Traits>
6128std::basic_ostream<CharT, Traits>&
6129to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const year& y)
6131 using CT = std::chrono::seconds;
6136template <
class CharT,
class Traits>
6138std::basic_ostream<CharT, Traits>&
6141 using CT = std::chrono::seconds;
6146template <
class CharT,
class Traits>
6148std::basic_ostream<CharT, Traits>&
6149to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const day& d)
6151 using CT = std::chrono::seconds;
6156template <
class CharT,
class Traits>
6158std::basic_ostream<CharT, Traits>&
6161 using CT = std::chrono::seconds;
6166template <
class CharT,
class Traits>
6168std::basic_ostream<CharT, Traits>&
6171 using CT = std::chrono::seconds;
6176template <
class CharT,
class Traits>
6178std::basic_ostream<CharT, Traits>&
6181 using CT = std::chrono::seconds;
6186template <
class CharT,
class Traits>
6188std::basic_ostream<CharT, Traits>&
6189to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
6192 using CT = std::chrono::seconds;
6197template <
class CharT,
class Traits,
class Rep,
class Period>
6199std::basic_ostream<CharT, Traits>&
6200to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
6201 const std::chrono::duration<Rep, Period>& d)
6203 using Duration = std::chrono::duration<Rep, Period>;
6204 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
6209template <
class CharT,
class Traits,
class Duration>
6210std::basic_ostream<CharT, Traits>&
6211to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
6213 const std::chrono::seconds* offset_sec =
nullptr)
6215 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
6216 auto ld = std::chrono::time_point_cast<days>(tp);
6223 return to_stream(os, fmt, fds, abbrev, offset_sec);
6226template <
class CharT,
class Traits,
class Duration>
6227std::basic_ostream<CharT, Traits>&
6228to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
6231 using std::chrono::seconds;
6232 using CT =
typename std::common_type<Duration, seconds>::type;
6233 const std::string abbrev(
"UTC");
6235 auto sd = std::chrono::time_point_cast<days>(tp);
6242 return to_stream(os, fmt, fds, &abbrev, &offset);
6247template <
class CharT,
class Streamable>
6249format(
const std::locale& loc,
const CharT* fmt,
const Streamable& tp)
6250 ->
decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
6251 std::basic_string<CharT>{})
6253 std::basic_ostringstream<CharT> os;
6254 os.exceptions(std::ios::failbit | std::ios::badbit);
6260template <
class CharT,
class Streamable>
6262format(
const CharT* fmt,
const Streamable& tp)
6263 ->
decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
6264 std::basic_string<CharT>{})
6266 std::basic_ostringstream<CharT> os;
6267 os.exceptions(std::ios::failbit | std::ios::badbit);
6272template <
class CharT,
class Traits,
class Alloc,
class Streamable>
6274format(
const std::locale& loc,
const std::basic_string<CharT, Traits, Alloc>& fmt,
6275 const Streamable& tp)
6276 ->
decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
6277 std::basic_string<CharT, Traits, Alloc>{})
6279 std::basic_ostringstream<CharT, Traits, Alloc> os;
6280 os.exceptions(std::ios::failbit | std::ios::badbit);
6286template <
class CharT,
class Traits,
class Alloc,
class Streamable>
6288format(
const std::basic_string<CharT, Traits, Alloc>& fmt,
const Streamable& tp)
6289 ->
decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
6290 std::basic_string<CharT, Traits, Alloc>{})
6292 std::basic_ostringstream<CharT, Traits, Alloc> os;
6293 os.exceptions(std::ios::failbit | std::ios::badbit);
6303template <
class CharT,
class Traits>
6305read_char(std::basic_istream<CharT, Traits>& is, CharT fmt, std::ios::iostate& err)
6308 if (Traits::eq_int_type(ic, Traits::eof()) ||
6309 !Traits::eq(Traits::to_char_type(ic), fmt))
6311 err |= std::ios::failbit;
6312 is.setstate(std::ios::failbit);
6318template <
class CharT,
class Traits>
6320read_unsigned(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
6326 auto ic = is.peek();
6327 if (Traits::eq_int_type(ic, Traits::eof()))
6329 auto c =
static_cast<char>(Traits::to_char_type(ic));
6330 if (!(
'0' <= c && c <=
'9'))
6334 x = 10*x +
static_cast<unsigned>(c -
'0');
6339 is.setstate(std::ios::failbit);
6343template <
class CharT,
class Traits>
6345read_signed(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
6347 auto ic = is.peek();
6348 if (!Traits::eq_int_type(ic, Traits::eof()))
6350 auto c =
static_cast<char>(Traits::to_char_type(ic));
6351 if ((
'0' <= c && c <=
'9') || c ==
'-' || c ==
'+')
6353 if (c ==
'-' || c ==
'+')
6365 is.setstate(std::ios::failbit);
6369template <
class CharT,
class Traits>
6374 unsigned fcount = 0;
6375 unsigned long long i = 0;
6376 unsigned long long f = 0;
6377 bool parsing_fraction =
false;
6379 typename Traits::int_type decimal_point =
'.';
6381 auto decimal_point = Traits::to_int_type(
6382 std::use_facet<std::numpunct<CharT>>(is.getloc()).decimal_point());
6386 auto ic = is.peek();
6387 if (Traits::eq_int_type(ic, Traits::eof()))
6389 if (Traits::eq_int_type(ic, decimal_point))
6391 decimal_point = Traits::eof();
6392 parsing_fraction =
true;
6396 auto c =
static_cast<char>(Traits::to_char_type(ic));
6397 if (!(
'0' <= c && c <=
'9'))
6399 if (!parsing_fraction)
6401 i = 10*i +
static_cast<unsigned>(c -
'0');
6405 f = 10*f +
static_cast<unsigned>(c -
'0');
6415 is.setstate(std::ios::failbit);
6418 return static_cast<long double>(i) +
static_cast<long double>(f)/std::pow(10.L, fcount);
6442template <
class CharT,
class Traits>
6444read(std::basic_istream<CharT, Traits>&)
6448template <
class CharT,
class Traits,
class ...Args>
6450read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args);
6452template <
class CharT,
class Traits,
class ...Args>
6454read(std::basic_istream<CharT, Traits>& is,
rs a0, Args&& ...args);
6456template <
class CharT,
class Traits,
class ...Args>
6458read(std::basic_istream<CharT, Traits>& is,
ru a0, Args&& ...args);
6460template <
class CharT,
class Traits,
class ...Args>
6462read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args);
6464template <
class CharT,
class Traits,
class ...Args>
6466read(std::basic_istream<CharT, Traits>& is,
rld a0, Args&& ...args);
6468template <
class CharT,
class Traits,
class ...Args>
6470read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args)
6475 auto ic = is.peek();
6476 if (Traits::eq_int_type(ic, Traits::eof()))
6478 is.setstate(std::ios::failbit | std::ios::eofbit);
6481 if (!Traits::eq(Traits::to_char_type(ic), a0))
6483 is.setstate(std::ios::failbit);
6488 read(is, std::forward<Args>(args)...);
6491template <
class CharT,
class Traits,
class ...Args>
6493read(std::basic_istream<CharT, Traits>& is,
rs a0, Args&& ...args)
6499 read(is, std::forward<Args>(args)...);
6502template <
class CharT,
class Traits,
class ...Args>
6504read(std::basic_istream<CharT, Traits>& is,
ru a0, Args&& ...args)
6509 a0.
i =
static_cast<int>(x);
6510 read(is, std::forward<Args>(args)...);
6513template <
class CharT,
class Traits,
class ...Args>
6515read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args)
6519 auto u =
static_cast<unsigned>(a0);
6520 CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
6524 *e++ =
static_cast<CharT
>(CharT(u % 10) + CharT{
'0'});
6527 std::reverse(buf, e);
6528 for (
auto p = buf; p != e && is.rdstate() == std::ios::goodbit; ++p)
6531 if (is.rdstate() == std::ios::goodbit)
6532 read(is, std::forward<Args>(args)...);
6535template <
class CharT,
class Traits,
class ...Args>
6537read(std::basic_istream<CharT, Traits>& is,
rld a0, Args&& ...args)
6543 read(is, std::forward<Args>(args)...);
6546template <
class T,
class CharT,
class Traits>
6549checked_set(T& value, T from, T not_a_value, std::basic_ios<CharT, Traits>& is)
6553 if (value == not_a_value)
6554 value = std::move(from);
6555 else if (value != from)
6556 is.setstate(std::ios::failbit);
6562template <
class CharT,
class Traits,
class Duration,
class Alloc = std::allocator<CharT>>
6563std::basic_istream<CharT, Traits>&
6566 std::chrono::minutes* offset)
6568 using std::numeric_limits;
6570 using std::chrono::duration;
6571 using std::chrono::duration_cast;
6572 using std::chrono::seconds;
6573 using std::chrono::minutes;
6574 using std::chrono::hours;
6576 typename std::basic_istream<CharT, Traits>::sentry
ok{is,
true};
6584 auto& f = std::use_facet<std::time_get<CharT>>(is.getloc());
6587 const CharT* command =
nullptr;
6588 auto modified = CharT{};
6593 CONSTDATA int not_a_century = not_a_year / 100;
6598 CONSTDATA int not_a_minute = not_a_hour;
6607 int y = not_a_2digit_year;
6608 int g = not_a_2digit_year;
6610 int C = not_a_century;
6611 int m = not_a_month;
6614 int wd = not_a_weekday;
6616 int I = not_a_hour_12_value;
6618 int M = not_a_minute;
6619 Duration s = not_a_second;
6620 int U = not_a_week_num;
6621 int V = not_a_week_num;
6622 int W = not_a_week_num;
6623 std::basic_string<CharT, Traits, Alloc> temp_abbrev;
6624 minutes temp_offset = not_a_offset;
6631 for (; *fmt != CharT{} && !is.fail(); ++fmt)
6641 int trial_wd = not_a_weekday;
6642 if (*fmt ==
'a' || *fmt ==
'A')
6644 if (modified == CharT{})
6647 ios::iostate err = ios::goodbit;
6648 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6651 trial_wd = tm.tm_wday;
6653 auto nm = detail::weekday_names();
6654 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6660 read(is, CharT{
'%'},
width, modified, *fmt);
6665 if (modified == CharT{})
6667 if (modified != CharT{
'E'})
6671 1u :
static_cast<unsigned>(
width)});
6676 if (!(1 <= trial_wd && trial_wd <= 7))
6678 trial_wd = not_a_weekday;
6679 is.setstate(ios::failbit);
6681 else if (trial_wd == 7)
6686 if (!(0 <= trial_wd && trial_wd <= 6))
6688 trial_wd = not_a_weekday;
6689 is.setstate(ios::failbit);
6695 else if (modified == CharT{
'O'})
6697 ios::iostate err = ios::goodbit;
6698 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6701 trial_wd = tm.tm_wday;
6705 read(is, CharT{
'%'},
width, modified, *fmt);
6707 if (trial_wd != not_a_weekday)
6721 if (modified == CharT{})
6723 int ttm = not_a_month;
6725 ios::iostate err = ios::goodbit;
6726 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6727 if ((err & ios::failbit) == 0)
6728 ttm = tm.tm_mon + 1;
6731 auto nm = detail::month_names();
6732 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6739 read(is, CharT{
'%'},
width, modified, *fmt);
6750 if (modified != CharT{
'O'})
6753 ios::iostate err = ios::goodbit;
6754 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6755 if ((err & ios::failbit) == 0)
6757 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
6762 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
6768 auto nm = detail::weekday_names();
6769 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6770 checked_set(wd,
static_cast<int>(i % 7), not_a_weekday, is);
6772 nm = detail::month_names();
6773 i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6774 checked_set(m,
static_cast<int>(i % 12 + 1), not_a_month, is);
6781 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6785 read(is,
ru{tH, 1, 2}, CharT{
':'},
ru{tM, 1, 2},
6786 CharT{
':'},
rld{S, 1, w});
6789 checked_set(s, round_i<Duration>(duration<long double>{S}),
6792 int tY = not_a_year;
6798 read(is, CharT{
'%'},
width, modified, *fmt);
6809 if (modified != CharT{
'O'})
6812 ios::iostate err = ios::goodbit;
6813 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6814 if ((err & ios::failbit) == 0)
6816 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
6823 int ty = not_a_2digit_year;
6824 int tm = not_a_month;
6826 read(is,
ru{tm, 1, 2}, CharT{
'/'},
ru{td, 1, 2}, CharT{
'/'},
6834 read(is, CharT{
'%'},
width, modified, *fmt);
6845 if (modified != CharT{
'O'})
6848 ios::iostate err = ios::goodbit;
6849 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6850 if ((err & ios::failbit) == 0)
6854 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
6861 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6862 int tH = not_a_hour;
6863 int tM = not_a_minute;
6865 read(is,
ru{tH, 1, 2}, CharT{
':'},
ru{tM, 1, 2},
6866 CharT{
':'},
rld{S, 1, w});
6869 checked_set(s, round_i<Duration>(duration<long double>{S}),
6874 read(is, CharT{
'%'},
width, modified, *fmt);
6885 int tC = not_a_century;
6887 if (modified == CharT{})
6895 ios::iostate err = ios::goodbit;
6896 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6897 if ((err & ios::failbit) == 0)
6899 auto tY = tm.tm_year + 1900;
6900 tC = (tY >= 0 ? tY : tY-99) / 100;
6916 if (modified == CharT{})
6918 int tn = not_a_month;
6920 int ty = not_a_2digit_year;
6921 read(is,
ru{tn, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6922 ru{td, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6929 read(is, CharT{
'%'},
width, modified, *fmt);
6940 if (modified == CharT{})
6942 int tY = not_a_year;
6943 int tn = not_a_month;
6946 CharT{
'-'},
ru{tn, 1, 2}, CharT{
'-'},
ru{td, 1, 2});
6952 read(is, CharT{
'%'},
width, modified, *fmt);
6965 if (modified == CharT{})
6967 if (modified != CharT{
'E'})
6975 else if (modified == CharT{
'O'})
6977 ios::iostate err = ios::goodbit;
6978 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6982 if ((err & ios::failbit) == 0)
6988 read(is, CharT{
'%'},
width, modified, *fmt);
7000 if (modified == CharT{})
7002 if (modified != CharT{
'E'})
7005 int tH = not_a_hour;
7010 else if (modified == CharT{
'O'})
7012 ios::iostate err = ios::goodbit;
7013 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7014 if ((err & ios::failbit) == 0)
7020 read(is, CharT{
'%'},
width, modified, *fmt);
7031 if (modified == CharT{})
7033 int tI = not_a_hour_12_value;
7036 if (!(1 <= tI && tI <= 12))
7037 is.setstate(ios::failbit);
7041 read(is, CharT{
'%'},
width, modified, *fmt);
7052 if (modified == CharT{})
7059 read(is, CharT{
'%'},
width, modified, *fmt);
7071 if (modified == CharT{})
7073 if (modified != CharT{
'E'})
7076 int tM = not_a_minute;
7081 else if (modified == CharT{
'O'})
7083 ios::iostate err = ios::goodbit;
7084 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7085 if ((err & ios::failbit) == 0)
7091 read(is, CharT{
'%'},
width, modified, *fmt);
7103 if (modified == CharT{})
7105 if (modified != CharT{
'E'})
7108 int tn = not_a_month;
7113 else if (modified == CharT{
'O'})
7115 ios::iostate err = ios::goodbit;
7116 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7117 if ((err & ios::failbit) == 0)
7123 read(is, CharT{
'%'},
width, modified, *fmt);
7135 if (modified == CharT{})
7139 auto ic = is.peek();
7140 if (Traits::eq_int_type(ic, Traits::eof()))
7142 ios::iostate err = ios::eofbit;
7144 err |= ios::failbit;
7152 else if (*fmt ==
'n')
7153 is.setstate(ios::failbit);
7156 read(is, CharT{
'%'},
width, modified, *fmt);
7167 if (modified == CharT{})
7169 int tp = not_a_ampm;
7173 ios::iostate err = ios::goodbit;
7174 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7176 if (tm.tm_hour == 1)
7178 else if (tm.tm_hour == 13)
7183 auto nm = detail::ampm_names();
7184 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
7185 tp =
static_cast<decltype(tp)
>(i);
7190 read(is, CharT{
'%'},
width, modified, *fmt);
7202 if (modified == CharT{})
7205 ios::iostate err = ios::goodbit;
7206 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7207 if ((err & ios::failbit) == 0)
7211 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
7218 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
7220 int tI = not_a_hour_12_value;
7221 int tM = not_a_minute;
7222 read(is,
ru{tI, 1, 2}, CharT{
':'},
ru{tM, 1, 2},
7223 CharT{
':'},
rld{S, 1, w});
7226 checked_set(s, round_i<Duration>(duration<long double>{S}),
7229 auto nm = detail::ampm_names();
7230 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
7231 checked_set(p,
static_cast<int>(i), not_a_ampm, is);
7235 read(is, CharT{
'%'},
width, modified, *fmt);
7246 if (modified == CharT{})
7248 int tH = not_a_hour;
7249 int tM = not_a_minute;
7250 read(is,
ru{tH, 1, 2}, CharT{
'\0'}, CharT{
':'}, CharT{
'\0'},
7251 ru{tM, 1, 2}, CharT{
'\0'});
7256 read(is, CharT{
'%'},
width, modified, *fmt);
7268 if (modified == CharT{})
7270 if (modified != CharT{
'E'})
7274 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
7277 checked_set(s, round_i<Duration>(duration<long double>{S}),
7281 else if (modified == CharT{
'O'})
7283 ios::iostate err = ios::goodbit;
7284 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7285 if ((err & ios::failbit) == 0)
7286 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
7292 read(is, CharT{
'%'},
width, modified, *fmt);
7303 if (modified == CharT{})
7306 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
7307 int tH = not_a_hour;
7308 int tM = not_a_minute;
7310 read(is,
ru{tH, 1, 2}, CharT{
':'},
ru{tM, 1, 2},
7311 CharT{
':'},
rld{S, 1, w});
7314 checked_set(s, round_i<Duration>(duration<long double>{S}),
7318 read(is, CharT{
'%'},
width, modified, *fmt);
7330 if (modified == CharT{})
7332 if (modified != CharT{
'O'})
7335 int tY = not_a_year;
7340 else if (modified == CharT{
'E'})
7342 ios::iostate err = ios::goodbit;
7343 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7344 if ((err & ios::failbit) == 0)
7345 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
7350 read(is, CharT{
'%'},
width, modified, *fmt);
7362 if (modified == CharT{})
7365 int ty = not_a_2digit_year;
7372 ios::iostate err = ios::goodbit;
7373 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7374 if ((err & ios::failbit) == 0)
7375 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
7389 if (modified == CharT{})
7391 int tg = not_a_2digit_year;
7396 read(is, CharT{
'%'},
width, modified, *fmt);
7407 if (modified == CharT{})
7409 int tG = not_a_year;
7414 read(is, CharT{
'%'},
width, modified, *fmt);
7425 if (modified == CharT{})
7427 int tU = not_a_week_num;
7432 read(is, CharT{
'%'},
width, modified, *fmt);
7443 if (modified == CharT{})
7445 int tV = not_a_week_num;
7450 read(is, CharT{
'%'},
width, modified, *fmt);
7461 if (modified == CharT{})
7463 int tW = not_a_week_num;
7468 read(is, CharT{
'%'},
width, modified, *fmt);
7480 if (modified == CharT{})
7486 read(is, CharT{
'%'},
width, modified, *fmt);
7498 if (modified == CharT{})
7501 read(is, CharT{
'%'},
width, modified, *fmt);
7513 minutes toff = not_a_offset;
7515 auto ic = is.peek();
7516 if (!Traits::eq_int_type(ic, Traits::eof()))
7518 auto c =
static_cast<char>(Traits::to_char_type(ic));
7522 if (modified == CharT{})
7530 if (!Traits::eq_int_type(ic, Traits::eof()))
7532 auto c =
static_cast<char>(Traits::to_char_type(ic));
7533 if (
'0' <= c && c <=
'9')
7537 toff += minutes{tM};
7550 if (!Traits::eq_int_type(ic, Traits::eof()))
7552 auto c =
static_cast<char>(Traits::to_char_type(ic));
7558 toff += minutes{tM};
7576 if (modified == CharT{})
7578 std::basic_string<CharT, Traits, Alloc> buf;
7579 while (is.rdstate() == std::ios::goodbit)
7581 auto i = is.rdbuf()->sgetc();
7582 if (Traits::eq_int_type(i, Traits::eof()))
7584 is.setstate(ios::eofbit);
7587 auto wc = Traits::to_char_type(i);
7588 auto c =
static_cast<char>(wc);
7590 if (!(CharT{1} < wc && wc < CharT{127}) || !(isalnum(c) ||
7591 c ==
'_' || c ==
'/' || c ==
'-' || c ==
'+'))
7594 is.rdbuf()->sbumpc();
7597 is.setstate(ios::failbit);
7601 read(is, CharT{
'%'},
width, modified, *fmt);
7612 if (
width == -1 && modified == CharT{} &&
'0' <= *fmt && *fmt <=
'9')
7614 width =
static_cast<char>(*fmt) -
'0';
7615 while (
'0' <= fmt[1] && fmt[1] <=
'9')
7616 width = 10*
width +
static_cast<char>(*++fmt) -
'0';
7620 if (modified == CharT{})
7623 read(is, CharT{
'%'},
width, modified, *fmt);
7631 if (isspace(
static_cast<unsigned char>(*fmt)))
7644 if (is.rdstate() == ios::goodbit && command)
7646 if (modified == CharT{})
7653 if (y != not_a_2digit_year)
7656 if (!(0 <= y && y <= 99))
7658 if (C == not_a_century)
7660 if (Y == not_a_year)
7669 C = (Y >= 0 ? Y : Y-100) / 100;
7676 tY = 100*(C+1) - (y == 0 ? 100 : y);
7677 if (Y != not_a_year && Y != tY)
7681 if (g != not_a_2digit_year)
7684 if (!(0 <= g && g <= 99))
7686 if (C == not_a_century)
7688 if (G == not_a_year)
7697 C = (G >= 0 ? G : G-100) / 100;
7704 tG = 100*(C+1) - (g == 0 ? 100 : g);
7705 if (G != not_a_year && G != tG)
7711 bool computed =
false;
7712 if (G != not_a_year && V != not_a_week_num && wd != not_a_weekday)
7717 if (Y == not_a_year)
7718 Y =
static_cast<int>(ymd_trial.
year());
7719 else if (
year{Y} != ymd_trial.
year())
7721 if (m == not_a_month)
7722 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7723 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7726 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7727 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7731 if (Y != not_a_year && U != not_a_week_num && wd != not_a_weekday)
7736 if (Y == not_a_year)
7737 Y =
static_cast<int>(ymd_trial.
year());
7738 else if (
year{Y} != ymd_trial.
year())
7740 if (m == not_a_month)
7741 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7742 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7745 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7746 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7750 if (Y != not_a_year && W != not_a_week_num && wd != not_a_weekday)
7755 if (Y == not_a_year)
7756 Y =
static_cast<int>(ymd_trial.
year());
7757 else if (
year{Y} != ymd_trial.
year())
7759 if (m == not_a_month)
7760 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7761 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7764 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7765 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7769 if (j != not_a_doy && Y != not_a_year)
7772 if (m == not_a_month)
7773 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.month()));
7774 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7777 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.day()));
7778 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.day())
7782 auto ymd =
year{Y}/m/d;
7785 if (wd == not_a_weekday)
7791 if (G != not_a_year || V != not_a_week_num)
7800 if (V != not_a_week_num)
7804 if (G != not_a_year && G !=
static_cast<int>(G_trial))
7806 if (V != not_a_week_num)
7808 auto V_trial = duration_cast<weeks>(sd - start).count() + 1;
7813 if (U != not_a_week_num)
7816 auto U_trial = floor<weeks>(
sys_days(ymd) - start).count() + 1;
7820 if (W != not_a_week_num)
7823 auto W_trial = floor<weeks>(
sys_days(ymd) - start).count() + 1;
7830 if (I != not_a_hour_12_value)
7832 if (!(1 <= I && I <= 12))
7834 if (p != not_a_ampm)
7842 if (H == not_a_hour)
7850 if (H != not_a_hour)
7854 if (H != 0 && H != 12)
7857 else if (!(I == H || I == H+12))
7866 if (H != not_a_hour)
7871 if (M != not_a_minute)
7874 fds.
tod.m_ = minutes{M};
7876 if (s != not_a_second)
7886 if (wd != not_a_weekday)
7887 fds.
wd =
weekday{
static_cast<unsigned>(wd)};
7888 if (abbrev !=
nullptr)
7889 *abbrev = std::move(temp_abbrev);
7890 if (offset !=
nullptr && temp_offset != not_a_offset)
7891 *offset = temp_offset;
7896 is.setstate(ios::failbit);
7900template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7901std::basic_istream<CharT, Traits>&
7903 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7904 std::chrono::minutes* offset =
nullptr)
7906 using CT = std::chrono::seconds;
7909 if (!fds.ymd.year().ok())
7910 is.setstate(std::ios::failbit);
7916template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7917std::basic_istream<CharT, Traits>&
7919 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7920 std::chrono::minutes* offset =
nullptr)
7922 using CT = std::chrono::seconds;
7925 if (!fds.ymd.month().ok())
7926 is.setstate(std::ios::failbit);
7928 m = fds.ymd.
month();
7932template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7933std::basic_istream<CharT, Traits>&
7935 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7936 std::chrono::minutes* offset =
nullptr)
7938 using CT = std::chrono::seconds;
7941 if (!fds.ymd.day().ok())
7942 is.setstate(std::ios::failbit);
7948template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7949std::basic_istream<CharT, Traits>&
7951 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7952 std::chrono::minutes* offset =
nullptr)
7954 using CT = std::chrono::seconds;
7958 is.setstate(std::ios::failbit);
7964template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7965std::basic_istream<CharT, Traits>&
7967 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7968 std::chrono::minutes* offset =
nullptr)
7970 using CT = std::chrono::seconds;
7973 if (!fds.ymd.month().ok())
7974 is.setstate(std::ios::failbit);
7976 ym = fds.ymd.
year()/fds.ymd.month();
7980template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7981std::basic_istream<CharT, Traits>&
7983 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7984 std::chrono::minutes* offset =
nullptr)
7986 using CT = std::chrono::seconds;
7989 if (!fds.ymd.month().ok() || !fds.ymd.day().ok())
7990 is.setstate(std::ios::failbit);
7992 md = fds.ymd.
month()/fds.ymd.day();
7996template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7997std::basic_istream<CharT, Traits>&
7999 year_month_day& ymd, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
8000 std::chrono::minutes* offset =
nullptr)
8002 using CT = std::chrono::seconds;
8006 is.setstate(std::ios::failbit);
8012template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
8013std::basic_istream<CharT, Traits>&
8016 std::chrono::minutes* offset =
nullptr)
8018 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
8020 std::chrono::minutes offset_local{};
8021 auto offptr = offset ? offset : &offset_local;
8025 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
8026 is.setstate(std::ios::failbit);
8028 tp = round_i<Duration>(
sys_days(fds.ymd) - *offptr + fds.tod.to_duration());
8032template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
8033std::basic_istream<CharT, Traits>&
8036 std::chrono::minutes* offset =
nullptr)
8038 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
8043 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
8044 is.setstate(std::ios::failbit);
8050template <
class Rep,
class Period,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
8051std::basic_istream<CharT, Traits>&
8053 std::chrono::duration<Rep, Period>& d,
8054 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
8055 std::chrono::minutes* offset =
nullptr)
8057 using Duration = std::chrono::duration<Rep, Period>;
8058 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
8063 is.setstate(std::ios::failbit);
8065 d = round_i<Duration>(fds.tod.to_duration());
8069template <
class Parsable,
class CharT,
class Traits = std::
char_traits<CharT>,
8070 class Alloc = std::allocator<CharT>>
8073 const std::basic_string<CharT, Traits, Alloc>
format_;
8080 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
8081 std::chrono::minutes* offset =
nullptr)
8082 : format_(std::move(
format))
8090 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
8091 std::chrono::minutes* offset =
nullptr)
8098 parse_manip(std::basic_string_view<CharT, Traits>
format, Parsable& tp,
8099 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
8100 std::chrono::minutes* offset =
nullptr)
8109template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8110std::basic_istream<CharT, Traits>&
8117template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8120parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp)
8121 ->
decltype(
date::from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
8128template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8131parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
8132 std::basic_string<CharT, Traits, Alloc>& abbrev)
8133 ->
decltype(
date::from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
8134 format.c_str(), tp, &abbrev),
8137 return {
format, tp, &abbrev};
8140template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8143parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
8144 std::chrono::minutes& offset)
8145 ->
decltype(
date::from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
8147 std::declval<std::basic_string<CharT, Traits, Alloc>*>(),
8151 return {
format, tp,
nullptr, &offset};
8154template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8157parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
8158 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
8159 ->
decltype(
date::from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
8160 format.c_str(), tp, &abbrev, &offset),
8163 return {
format, tp, &abbrev, &offset};
8168template <
class Parsable,
class CharT>
8178template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8181parse(
const CharT*
format, Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev)
8186 return {
format, tp, &abbrev};
8189template <
class Parsable,
class CharT>
8194 tp, std::declval<std::basic_string<CharT>*>(), &offset),
8197 return {
format, tp,
nullptr, &offset};
8200template <
class Parsable,
class CharT,
class Traits,
class Alloc>
8204 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
8206 tp, &abbrev, &offset),
8209 return {
format, tp, &abbrev, &offset};
8214template <
class CharT,
class Traits,
class Rep,
class Period>
8216std::basic_ostream<CharT, Traits>&
8217operator<<(std::basic_ostream<CharT, Traits>& os,
8218 const std::chrono::duration<Rep, Period>& d)
8220 return os << detail::make_string<CharT, Traits>::from(d.count()) +
8221 detail::get_units<CharT>(
typename Period::type{});
8227# pragma warning(pop)
8231# pragma GCC diagnostic pop
CONSTCD14 day & operator-=(const days &d) NOEXCEPT
CONSTCD14 day & operator--() NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 day & operator++() NOEXCEPT
CONSTCD14 day & operator+=(const days &d) NOEXCEPT
save_istream(std::basic_ios< CharT, Traits > &is)
std::streamsize precision_
save_istream(const save_istream &)=delete
std::basic_ostream< CharT, Traits > * tie_
save_istream & operator=(const save_istream &)=delete
std::basic_ios< CharT, Traits > & is_
std::ios::fmtflags flags_
save_ostream(const save_ostream &)=delete
save_ostream(std::basic_ios< CharT, Traits > &os)
save_ostream & operator=(const save_ostream &)=delete
CONSTCD14 std::chrono::seconds & seconds(detail::undocumented) NOEXCEPT
CONSTCD11 hh_mm_ss() NOEXCEPT
CONSTCD11 bool is_negative() const NOEXCEPT
CONSTCD11 std::chrono::minutes minutes() const NOEXCEPT
CONSTCD11 precision subseconds() const NOEXCEPT
CONSTCD11 std::chrono::hours hours() const NOEXCEPT
CONSTCD11 bool in_conventional_range() const NOEXCEPT
CONSTCD11 std::chrono::seconds seconds() const NOEXCEPT
CONSTCD11 precision to_duration() const NOEXCEPT
CONSTCD11 hh_mm_ss(Duration d) NOEXCEPT
typename dfs::precision precision
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 month_day_last(const date::month &m) NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD11 date::day day() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 month_weekday_last(const date::month &m, const date::weekday_last &wd) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 date::weekday_last weekday_last() const NOEXCEPT
CONSTCD11 month_weekday(const date::month &m, const date::weekday_indexed &wdi) NOEXCEPT
date::weekday_indexed wdi_
CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD14 month & operator--() NOEXCEPT
CONSTCD14 month & operator++() NOEXCEPT
CONSTCD14 month & operator-=(const months &m) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 month & operator+=(const months &m) NOEXCEPT
weekday_indexed()=default
CONSTCD11 unsigned index() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 date::weekday weekday() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 weekday_last(const date::weekday &wd) NOEXCEPT
CONSTCD11 date::weekday weekday() const NOEXCEPT
CONSTCD14 weekday & operator-=(const days &d) NOEXCEPT
CONSTCD11 unsigned c_encoding() const NOEXCEPT
static CONSTCD14 unsigned char weekday_from_days(int z) NOEXCEPT
CONSTCD14 weekday & operator--() NOEXCEPT
CONSTCD11 weekday_indexed operator[](unsigned index) const NOEXCEPT
CONSTCD11 unsigned iso_encoding() const NOEXCEPT
CONSTCD14 weekday & operator++() NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD14 weekday & operator+=(const days &d) NOEXCEPT
CONSTCD11 year_month_day_last(const date::year &y, const date::month_day_last &mdl) NOEXCEPT
date::month_day_last mdl_
CONSTCD14 year_month_day_last & operator+=(const months &m) NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 date::month_day_last month_day_last() const NOEXCEPT
CONSTCD14 date::day day() const NOEXCEPT
CONSTCD14 year_month_day_last & operator-=(const months &m) NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 date::year year() const NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
CONSTCD11 date::year year() const NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD14 year_month_day & operator-=(const months &m) NOEXCEPT
CONSTCD11 date::day day() const NOEXCEPT
static CONSTCD14 year_month_day from_days(days dp) NOEXCEPT
CONSTCD14 year_month_day & operator+=(const months &m) NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 year_month_weekday_last(const date::year &y, const date::month &m, const date::weekday_last &wdl) NOEXCEPT
CONSTCD14 year_month_weekday_last & operator+=(const months &m) NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
CONSTCD11 date::weekday weekday() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD14 year_month_weekday_last & operator-=(const months &m) NOEXCEPT
CONSTCD11 date::weekday_last weekday_last() const NOEXCEPT
CONSTCD11 date::year year() const NOEXCEPT
CONSTCD14 year_month_weekday & operator-=(const months &m) NOEXCEPT
CONSTCD11 unsigned index() const NOEXCEPT
date::weekday_indexed wdi_
CONSTCD11 date::weekday_indexed weekday_indexed() const NOEXCEPT
CONSTCD11 date::year year() const NOEXCEPT
CONSTCD14 days to_days() const NOEXCEPT
CONSTCD14 bool ok() const NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
static CONSTCD14 year_month_weekday from_days(days dp) NOEXCEPT
year_month_weekday()=default
CONSTCD11 date::weekday weekday() const NOEXCEPT
CONSTCD14 year_month_weekday & operator+=(const months &m) NOEXCEPT
CONSTCD14 year_month & operator+=(const months &dm) NOEXCEPT
CONSTCD14 year_month & operator-=(const months &dm) NOEXCEPT
CONSTCD11 date::month month() const NOEXCEPT
CONSTCD11 date::year year() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 year operator+() const NOEXCEPT
CONSTCD11 bool is_leap() const NOEXCEPT
CONSTCD11 bool ok() const NOEXCEPT
CONSTCD11 year operator-() const NOEXCEPT
CONSTCD14 year & operator++() NOEXCEPT
static CONSTCD11 year max() NOEXCEPT
CONSTCD14 year & operator--() NOEXCEPT
CONSTCD14 year & operator-=(const years &y) NOEXCEPT
static CONSTCD11 year min() NOEXCEPT
CONSTCD14 year & operator+=(const years &y) NOEXCEPT
#define HAS_UNCAUGHT_EXCEPTIONS
std::chrono::time_point< Clock, Duration > time_point
unsigned read_unsigned(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
void checked_set(T &value, T from, T not_a_value, std::basic_ios< CharT, Traits > &is)
CONSTCD11 std::chrono::time_point< Clock, To > round_i(const std::chrono::time_point< Clock, FromDuration > &tp)
CONSTCD11 std::enable_if<!std::numeric_limits< Rep >::is_signed, std::chrono::duration< Rep, Period > >::type abs(std::chrono::duration< Rep, Period > d)
CONSTCD14 std::enable_if<!std::chrono::treat_as_floating_point< typenameTo::rep >::value, To >::type round_i(const std::chrono::duration< Rep, Period > &d)
CONSTCD11 std::enable_if< std::numeric_limits< Rep >::is_signed, std::chrono::duration< Rep, Period > >::type abs(std::chrono::duration< Rep, Period > d)
decltype(std::ratio_divide< R1, R2 >{}) ratio_divide
void read(std::basic_istream< CharT, Traits > &)
int read_signed(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
decltype(std::ratio_multiply< R1, R2 >{}) ratio_multiply
unsigned extract_month(std::basic_ostream< CharT, Traits > &os, const fields< Duration > &fds)
unsigned extract_weekday(std::basic_ostream< CharT, Traits > &os, const fields< Duration > &fds)
void read(std::basic_istream< CharT, Traits > &is, rld a0, Args &&...args)
bool read_char(std::basic_istream< CharT, Traits > &is, CharT fmt, std::ios::iostate &err)
std::basic_ostream< CharT, Traits > & low_level_fmt(std::basic_ostream< CharT, Traits > &os, const day &d)
long double read_long_double(std::basic_istream< CharT, Traits > &is, unsigned m=1, unsigned M=10)
CONSTCD11 std::enable_if<!std::chrono::treat_as_floating_point< T >::value, T >::type trunc(T t) NOEXCEPT
std::basic_ostream< CharT, Traits > & low_level_fmt(std::basic_ostream< CharT, Traits > &os, const year_month_day_last &ymdl)
CONSTDATA date::month apr
CONSTDATA date::weekday tue
CONSTDATA date::month nov
CONSTDATA date::month jun
CONSTDATA date::weekday mon
CONSTDATA date::month jul
CONSTDATA date::weekday wed
CONSTDATA date::last_spec last
CONSTDATA date::month oct
CONSTDATA date::month feb
CONSTDATA date::month sep
CONSTDATA date::weekday fri
CONSTDATA date::month aug
CONSTDATA date::month dec
CONSTDATA date::month may
CONSTDATA date::weekday sun
CONSTDATA date::weekday sat
CONSTDATA date::weekday thu
CONSTDATA date::month mar
CONSTDATA date::month jan
CONSTDATA date::weekday Friday
CONSTCD11 bool operator>=(const day &x, const day &y) NOEXCEPT
CONSTCD14 To round(const std::chrono::duration< Rep, Period > &d)
CONSTCD14 std::chrono::hours make12(std::chrono::hours h) NOEXCEPT
local_time< std::chrono::seconds > local_seconds
CONSTCD11 day operator+(const day &x, const days &y) NOEXCEPT
CONSTCD11 std::chrono::time_point< Clock, To > round(const std::chrono::time_point< Clock, FromDuration > &tp)
CONSTCD11 day operator-(const day &x, const days &y) NOEXCEPT
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 146097, 400 >, days::period > > years
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)
std::basic_ostream< CharT, Traits > & operator<<(std::basic_ostream< CharT, Traits > &os, const day &d)
local_time< days > local_days
CONSTDATA date::month May
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 >{})
CONSTCD14 bool is_am(std::chrono::hours const &h) NOEXCEPT
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 7 >, days::period > > weeks
CONSTDATA date::month August
CONSTDATA date::weekday Saturday
CONSTDATA date::month January
CONSTDATA date::month October
CONSTCD11 bool operator>(const day &x, const day &y) NOEXCEPT
CONSTDATA date::weekday Wednesday
CONSTCD11 year_month operator/(const year &y, const month &m) NOEXCEPT
CONSTCD14 std::chrono::hours make24(std::chrono::hours h, bool is_pm) NOEXCEPT
auto parse(const std::basic_string< CharT, Traits, Alloc > &format, Parsable &tp) -> decltype(date::from_stream(std::declval< std::basic_istream< CharT, Traits > & >(), format.c_str(), tp), parse_manip< Parsable, CharT, Traits, Alloc >{format, tp})
CONSTCD11 bool operator==(const day &x, const day &y) NOEXCEPT
std::chrono::time_point< std::chrono::system_clock, Duration > sys_time
CONSTCD11 std::chrono::time_point< Clock, To > floor(const std::chrono::time_point< Clock, FromDuration > &tp)
CONSTCD14 std::enable_if< detail::no_overflow< Period, typenameTo::period >::value, To >::type floor(const std::chrono::duration< Rep, Period > &d)
CONSTDATA date::weekday Tuesday
CONSTCD11 hh_mm_ss< std::chrono::duration< Rep, Period > > make_time(const std::chrono::duration< Rep, Period > &d)
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)
CONSTDATA date::month December
CONSTCD11 std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
std::basic_istream< CharT, Traits > & operator>>(std::basic_istream< CharT, Traits > &is, const parse_manip< Parsable, CharT, Traits, Alloc > &x)
CONSTCD11 bool operator!=(const day &x, const day &y) NOEXCEPT
CONSTDATA date::weekday Sunday
CONSTDATA date::weekday Monday
CONSTCD11 std::enable_if< detail::no_overflow< Period, typenameTo::period >::value, To >::type trunc(const std::chrono::duration< Rep, Period > &d)
CONSTCD11 std::chrono::time_point< Clock, To > ceil(const std::chrono::time_point< Clock, FromDuration > &tp)
CONSTCD14 bool is_pm(std::chrono::hours const &h) NOEXCEPT
CONSTCD11 bool operator<=(const day &x, const day &y) NOEXCEPT
CONSTDATA date::month July
CONSTDATA date::month April
CONSTDATA date::month November
CONSTDATA date::weekday Thursday
CONSTCD11 bool operator<(const day &x, const day &y) NOEXCEPT
std::chrono::duration< int, detail::ratio_multiply< std::ratio< 24 >, std::chrono::hours::period > > days
CONSTDATA date::month February
std::chrono::time_point< local_t, Duration > local_time
sys_time< std::chrono::seconds > sys_seconds
CONSTDATA date::month March
std::chrono::duration< int, detail::ratio_divide< years::period, std::ratio< 12 > > > months
sys_time< days > sys_days
CONSTCD14 To ceil(const std::chrono::duration< Rep, Period > &d)
CONSTDATA date::month September
CONSTDATA date::month June
Namespace for mathematical applications.
typename std::conditional< digits< 32, std::int32_t, typename std::conditional< digits< 64, std::int64_t, std::int64_t >::type >::type type
std::ratio< mul< n1, d2, !value >::value, mul< n2, d1, !value >::value > type
fields(year_month_day ymd_, weekday wd_)
fields(year_month_day ymd_, hh_mm_ss< Duration > tod_)
fields(year_month_day ymd_, weekday wd_, hh_mm_ss< Duration > tod_)
fields(hh_mm_ss< Duration > tod_)
fields(year_month_day ymd_)
fields(weekday wd_, hh_mm_ss< Duration > tod_)
std::basic_string< CharT, Traits, Alloc > * abbrev_
std::chrono::minutes * offset_
parse_manip(std::basic_string< CharT, Traits, Alloc > format, Parsable &tp, std::basic_string< CharT, Traits, Alloc > *abbrev=nullptr, std::chrono::minutes *offset=nullptr)
const std::basic_string< CharT, Traits, Alloc > format_