40 #ifndef HAS_STRING_VIEW
41 # if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
42 # define HAS_STRING_VIEW 1
44 # define HAS_STRING_VIEW 0
46 #endif // HAS_STRING_VIEW
53 #if !(__cplusplus >= 201402)
72 # include <string_view>
75 #include <type_traits>
78 # pragma GCC diagnostic push
79 # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 7)
80 # pragma GCC diagnostic ignored "-Wpedantic"
84 # pragma GCC diagnostic ignored "-Wmissing-field-initializers"
89 # pragma warning(push)
91 # pragma warning(disable : 4127)
101 #ifndef ONLY_C_LOCALE
102 # define ONLY_C_LOCALE 0
105 #if defined(_MSC_VER) && (!defined(__clang__) || (_MSC_VER < 1910))
107 # ifndef _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING
108 # define _SILENCE_CXX17_UNCAUGHT_EXCEPTION_DEPRECATION_WARNING
112 # define CONSTDATA const
115 # define NOEXCEPT _NOEXCEPT
118 # define CONSTDATA constexpr const
119 # define CONSTCD11 constexpr
120 # define CONSTCD14 constexpr
121 # define NOEXCEPT noexcept
124 #elif defined(__SUNPRO_CC) && __SUNPRO_CC <= 0x5150
126 # define CONSTDATA constexpr const
127 # define CONSTCD11 constexpr
129 # define NOEXCEPT noexcept
131 #elif __cplusplus >= 201402
133 # define CONSTDATA constexpr const
134 # define CONSTCD11 constexpr
135 # define CONSTCD14 constexpr
136 # define NOEXCEPT noexcept
139 # define CONSTDATA constexpr const
140 # define CONSTCD11 constexpr
142 # define NOEXCEPT noexcept
145 #ifndef HAS_UNCAUGHT_EXCEPTIONS
146 # if __cplusplus > 201703 || (defined(_MSVC_LANG) && _MSVC_LANG > 201703L)
147 # define HAS_UNCAUGHT_EXCEPTIONS 1
149 # define HAS_UNCAUGHT_EXCEPTIONS 0
151 #endif // HAS_UNCAUGHT_EXCEPTIONS
154 # if __cplusplus >= 201703 || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
155 # define HAS_VOID_T 1
157 # define HAS_VOID_T 0
170 template <
typename R1,
typename R2>
173 template <
typename R1,
typename R2>
183 using days = std::chrono::duration
186 using weeks = std::chrono::duration
189 using years = std::chrono::duration
192 using months = std::chrono::duration
197 template <
class Duration>
198 using sys_time = std::chrono::time_point<std::chrono::system_clock, Duration>;
205 template <
class Duration>
206 using local_time = std::chrono::time_point<local_t, Duration>;
358 template<
class CharT,
class Traits>
359 std::basic_ostream<CharT, Traits>&
360 operator<<(std::basic_ostream<CharT, Traits>& os,
const day& d);
396 template<
class CharT,
class Traits>
397 std::basic_ostream<CharT, Traits>&
442 template<
class CharT,
class Traits>
443 std::basic_ostream<CharT, Traits>&
444 operator<<(std::basic_ostream<CharT, Traits>& os,
const year& y);
479 template<
class CharT,
class Traits>
480 friend std::basic_ostream<CharT, Traits>&
493 template<
class CharT,
class Traits>
494 std::basic_ostream<CharT, Traits>&
501 unsigned char wd_ : 4;
502 unsigned char index_ : 4;
516 template<
class CharT,
class Traits>
517 std::basic_ostream<CharT, Traits>&
536 template<
class CharT,
class Traits>
537 std::basic_ostream<CharT, Traits>&
561 template<
class = detail::unspecified_month_disambiguator>
563 template<
class = detail::unspecified_month_disambiguator>
578 template<
class = detail::unspecified_month_disambiguator>
580 template<
class = detail::unspecified_month_disambiguator>
582 template<
class = detail::unspecified_month_disambiguator>
590 template<
class CharT,
class Traits>
591 std::basic_ostream<CharT, Traits>&
618 template<
class CharT,
class Traits>
619 std::basic_ostream<CharT, Traits>&
642 template<
class CharT,
class Traits>
643 std::basic_ostream<CharT, Traits>&
665 template<
class CharT,
class Traits>
666 std::basic_ostream<CharT, Traits>&
691 template<
class CharT,
class Traits>
692 std::basic_ostream<CharT, Traits>&
712 template<
class = detail::unspecified_month_disambiguator>
714 template<
class = detail::unspecified_month_disambiguator>
739 template<
class = detail::unspecified_month_disambiguator>
741 template<
class = detail::unspecified_month_disambiguator>
743 template<
class = detail::unspecified_month_disambiguator>
749 template<
class CharT,
class Traits>
750 std::basic_ostream<CharT, Traits>&
764 template<
class = detail::unspecified_month_disambiguator>
766 template<
class = detail::unspecified_month_disambiguator>
794 template<
class = detail::unspecified_month_disambiguator>
799 template<
class = detail::unspecified_month_disambiguator>
812 template<
class = detail::unspecified_month_disambiguator>
821 template<
class CharT,
class Traits>
822 std::basic_ostream<CharT, Traits>&
840 template<
class = detail::unspecified_month_disambiguator>
842 template<
class = detail::unspecified_month_disambiguator>
867 template<
class = detail::unspecified_month_disambiguator>
872 template<
class = detail::unspecified_month_disambiguator>
885 template<
class = detail::unspecified_month_disambiguator>
894 template<
class CharT,
class Traits>
895 std::basic_ostream<CharT, Traits>&
910 template<
class = detail::unspecified_month_disambiguator>
912 template<
class = detail::unspecified_month_disambiguator>
938 template<
class = detail::unspecified_month_disambiguator>
943 template<
class = detail::unspecified_month_disambiguator>
956 template<
class = detail::unspecified_month_disambiguator>
965 template<
class CharT,
class Traits>
966 std::basic_ostream<CharT, Traits>&
969 #if !defined(_MSC_VER) || (_MSC_VER >= 1900)
970 inline namespace literals
977 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
1002 template <
class T,
class = std::
void_t<>>
1008 struct is_clock<T, std::void_t<decltype(T::now()), typename T::rep, typename T::period,
1009 typename T::duration, typename T::time_point,
1010 decltype(T::is_steady)>>
1014 #endif // HAS_VOID_T
1023 template<
class CharT,
class Traits = std::
char_traits<CharT>>
1027 std::basic_ios<CharT, Traits>&
is_;
1031 std::basic_ostream<CharT, Traits>*
tie_;
1052 ,
tie_(is.tie(nullptr))
1055 if (
tie_ !=
nullptr)
1060 template<
class CharT,
class Traits = std::
char_traits<CharT>>
1067 if ((this->
flags_ & std::ios::unitbuf) &&
1069 std::uncaught_exceptions() == 0 &&
1071 !std::uncaught_exception() &&
1074 this->
is_.rdbuf()->pubsync();
1089 static const int digits = std::numeric_limits<T>::digits;
1090 using type =
typename std::conditional
1094 typename std::conditional
1098 #ifdef __SIZEOF_INT128__
1110 typename std::enable_if
1112 !std::chrono::treat_as_floating_point<T>::value,
1123 typename std::enable_if
1125 std::chrono::treat_as_floating_point<T>::value,
1130 using std::numeric_limits;
1132 CONSTDATA auto digits = numeric_limits<T>::digits;
1133 static_assert(digits < numeric_limits<I>::digits,
"");
1134 CONSTDATA auto max = I{1} << (digits-1);
1136 const auto negative = t < T{0};
1137 if (min <= t && t <= max && t != 0 && t == t)
1139 t =
static_cast<T
>(
static_cast<I
>(t));
1140 if (t == 0 && negative)
1146 template <std::
intmax_t Xp, std::
intmax_t Yp>
1152 template <std::
intmax_t Xp>
1164 template <
class R1,
class R2>
1170 static const std::intmax_t n1 = R1::num / gcd_n1_n2;
1171 static const std::intmax_t d1 = R1::den / gcd_d1_d2;
1172 static const std::intmax_t n2 = R2::num / gcd_n1_n2;
1173 static const std::intmax_t d2 = R2::den / gcd_d1_d2;
1174 static const std::intmax_t max = std::numeric_limits<std::intmax_t>::max();
1176 template <std::
intmax_t Xp, std::
intmax_t Yp,
bool overflow>
1179 static const std::intmax_t
value = Xp * Yp;
1182 template <std::
intmax_t Xp, std::
intmax_t Yp>
1183 struct mul<Xp, Yp, true>
1185 static const std::intmax_t
value = 1;
1189 static const bool value = (n1 <= max / d2) && (n2 <= max / d1);
1190 typedef std::ratio<mul<n1, d2, !value>::value,
1197 template <
class To,
class Rep,
class Period>
1200 typename std::enable_if
1205 trunc(
const std::chrono::duration<Rep, Period>& d)
1207 return To{
detail::trunc(std::chrono::duration_cast<To>(d).count())};
1210 template <
class To,
class Rep,
class Period>
1213 typename std::enable_if
1218 trunc(
const std::chrono::duration<Rep, Period>& d)
1220 using std::chrono::duration_cast;
1221 using std::chrono::duration;
1222 using rep =
typename std::common_type<Rep, typename To::rep>::type;
1223 return To{
detail::trunc(duration_cast<To>(duration_cast<duration<rep>>(d)).count())};
1226 #ifndef HAS_CHRONO_ROUNDING
1227 # if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 190023918 || (_MSC_FULL_VER >= 190000000 && defined (__clang__)))
1228 # define HAS_CHRONO_ROUNDING 1
1229 # elif defined(__cpp_lib_chrono) && __cplusplus > 201402 && __cpp_lib_chrono >= 201510
1230 # define HAS_CHRONO_ROUNDING 1
1231 # elif defined(_LIBCPP_VERSION) && __cplusplus > 201402 && _LIBCPP_VERSION >= 3800
1232 # define HAS_CHRONO_ROUNDING 1
1234 # define HAS_CHRONO_ROUNDING 0
1236 #endif // HAS_CHRONO_ROUNDING
1238 #if HAS_CHRONO_ROUNDING == 0
1241 template <
class To,
class Rep,
class Period>
1244 typename std::enable_if
1249 floor(
const std::chrono::duration<Rep, Period>& d)
1251 auto t = trunc<To>(d);
1257 template <
class To,
class Rep,
class Period>
1260 typename std::enable_if
1265 floor(
const std::chrono::duration<Rep, Period>& d)
1267 using rep =
typename std::common_type<Rep, typename To::rep>::type;
1268 return floor<To>(
floor<std::chrono::duration<rep>>(d));
1272 template <
class To,
class Rep,
class Period>
1276 round(
const std::chrono::duration<Rep, Period>& d)
1278 auto t0 = floor<To>(d);
1279 auto t1 = t0 + To{1};
1280 if (t1 == To{0} && t0 < To{0})
1282 auto diff0 = d - t0;
1283 auto diff1 = t1 - d;
1286 if (t0 - trunc<To>(t0/2)*2 == To{0})
1296 template <
class To,
class Rep,
class Period>
1300 ceil(
const std::chrono::duration<Rep, Period>& d)
1302 auto t = trunc<To>(d);
1308 template <
class Rep,
class Period,
1309 class =
typename std::enable_if
1311 std::numeric_limits<Rep>::is_signed
1314 std::chrono::duration<Rep, Period>
1315 abs(std::chrono::duration<Rep, Period> d)
1317 return d >= d.zero() ? d : -d;
1321 template <
class To,
class Clock,
class FromDuration>
1324 std::chrono::time_point<Clock, To>
1325 floor(
const std::chrono::time_point<Clock, FromDuration>& tp)
1327 using std::chrono::time_point;
1328 return time_point<Clock, To>{date::floor<To>(tp.time_since_epoch())};
1332 template <
class To,
class Clock,
class FromDuration>
1335 std::chrono::time_point<Clock, To>
1336 round(
const std::chrono::time_point<Clock, FromDuration>& tp)
1338 using std::chrono::time_point;
1339 return time_point<Clock, To>{round<To>(tp.time_since_epoch())};
1343 template <
class To,
class Clock,
class FromDuration>
1346 std::chrono::time_point<Clock, To>
1347 ceil(
const std::chrono::time_point<Clock, FromDuration>& tp)
1349 using std::chrono::time_point;
1350 return time_point<Clock, To>{ceil<To>(tp.time_since_epoch())};
1353 #else // HAS_CHRONO_ROUNDING == 1
1360 #endif // HAS_CHRONO_ROUNDING
1363 template <
class To,
class Clock,
class FromDuration>
1366 std::chrono::time_point<Clock, To>
1367 trunc(
const std::chrono::time_point<Clock, FromDuration>& tp)
1369 using std::chrono::time_point;
1370 return time_point<Clock, To>{trunc<To>(tp.time_since_epoch())};
1390 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
1406 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
1438 return days{
static_cast<days::rep
>(
static_cast<unsigned>(x)
1439 -
static_cast<unsigned>(y))};
1447 return day{
static_cast<unsigned>(x) +
static_cast<unsigned>(y.count())};
1466 template<
class CharT,
class Traits>
1468 std::basic_ostream<CharT, Traits>&
1475 os << static_cast<unsigned>(d);
1477 os <<
" is not a valid day";
1515 return static_cast<unsigned>(x) ==
static_cast<unsigned>(y);
1531 return static_cast<unsigned>(x) <
static_cast<unsigned>(y);
1563 auto const d =
static_cast<unsigned>(x) -
static_cast<unsigned>(y);
1564 return months(d <= 11 ? d : d + 12);
1572 auto const mu =
static_cast<long long>(
static_cast<unsigned>(x)) + y.count() - 1;
1573 auto const yr = (mu >= 0 ? mu : mu-11) / 12;
1574 return month{
static_cast<unsigned>(mu - yr * 12 + 1)};
1593 template<
class CharT,
class Traits>
1595 std::basic_ostream<CharT, Traits>&
1600 CharT fmt[] = {
'%',
'b', 0};
1601 os <<
format(os.getloc(), fmt, m);
1604 os << static_cast<unsigned>(m) <<
" is not a valid month";
1625 return y_ % 4 == 0 && (y_ % 100 != 0 || y_ % 400 == 0);
1635 return y_ != std::numeric_limits<short>::min();
1643 return static_cast<int>(x) ==
static_cast<int>(y);
1659 return static_cast<int>(x) <
static_cast<int>(y);
1691 return years{
static_cast<int>(x) -
static_cast<int>(y)};
1699 return year{
static_cast<int>(x) + y.count()};
1715 return year{
static_cast<int>(x) - y.count()};
1718 template<
class CharT,
class Traits>
1720 std::basic_ostream<CharT, Traits>&
1726 os.width(4 + (y <
year{0}));
1727 os.imbue(std::locale::classic());
1728 os << static_cast<int>(y);
1730 os <<
" is not a valid year";
1739 weekday::weekday_from_days(
int z)
NOEXCEPT
1741 auto u =
static_cast<unsigned>(z);
1742 return static_cast<unsigned char>(z >= -4 ? (u+4) % 7 : u % 7);
1748 : wd_(
static_cast<decltype(wd_)
>(wd != 7 ? wd : 0))
1754 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1760 : wd_(weekday_from_days(dp.time_since_epoch().count()))
1792 return unsigned{wd_};
1799 return unsigned{((wd_ == 0u) ? 7u : wd_)};
1807 return x.wd_ == y.wd_;
1823 auto const wdu = x.wd_ - y.wd_;
1824 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1825 return days{wdu - wk * 7};
1833 auto const wdu =
static_cast<long long>(
static_cast<unsigned>(x.wd_)) + y.count();
1834 auto const wk = (wdu >= 0 ? wdu : wdu-6) / 7;
1835 return weekday{
static_cast<unsigned>(wdu - wk * 7)};
1854 template<
class CharT,
class Traits>
1856 std::basic_ostream<CharT, Traits>&
1861 CharT fmt[] = {
'%',
'a', 0};
1865 os << static_cast<unsigned>(wd.wd_) <<
" is not a valid weekday";
1869 #if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1870 inline namespace literals
1878 return date::day{
static_cast<unsigned>(d)};
1888 #endif // !defined(_MSC_VER) || (_MSC_VER >= 1900)
1913 #if !defined(_MSC_VER) || (_MSC_VER >= 1900)
1955 return weekday().
ok() && 1 <= index_ && index_ <= 5;
1959 # pragma GCC diagnostic push
1960 # pragma GCC diagnostic ignored "-Wconversion"
1966 : wd_(
static_cast<decltype(wd_)
>(
static_cast<unsigned>(wd.wd_)))
1967 , index_(
static_cast<decltype(index_)
>(index))
1971 # pragma GCC diagnostic pop
1974 template<
class CharT,
class Traits>
1976 std::basic_ostream<CharT, Traits>&
1981 os <<
" is not a valid index";
1991 return {*
this, index};
1999 return x.weekday() == y.weekday() && x.index() == y.index();
2021 return x.weekday() == y.weekday();
2032 template<
class CharT,
class Traits>
2034 std::basic_ostream<CharT, Traits>&
2037 return os << wdl.
weekday() <<
"[last]";
2104 return x.year() == y.year() && x.month() == y.month();
2120 return x.year() < y.year() ? true
2121 : (x.year() > y.year() ? false
2122 : (x.month() < y.month()));
2155 auto dmi =
static_cast<int>(
static_cast<unsigned>(ym.month())) - 1 + dm.count();
2156 auto dy = (dmi >= 0 ? dmi : dmi-11) / 12;
2157 dmi = dmi - dy * 12 + 1;
2158 return (ym.year() +
years(dy)) /
month(
static_cast<unsigned>(dmi));
2184 return (x.year() - y.year()) +
2185 months(
static_cast<unsigned>(x.month()) -
static_cast<unsigned>(y.month()));
2193 return (ym.year() + dy) / ym.month();
2212 template<
class CharT,
class Traits>
2214 std::basic_ostream<CharT, Traits>&
2217 return os << ym.
year() <<
'/' << ym.
month();
2244 return m_.
ok() &&
date::day{1} <= d_ && d_ <= d[static_cast<unsigned>(m_)-1];
2252 return x.month() == y.month() && x.day() == y.day();
2268 return x.month() < y.month() ? true
2269 : (x.month() > y.month() ? false
2270 : (x.day() < y.day()));
2297 template<
class CharT,
class Traits>
2299 std::basic_ostream<CharT, Traits>&
2302 return os << md.
month() <<
'/' << md.
day();
2316 return x.month() == y.month();
2332 return x.month() < y.month();
2359 template<
class CharT,
class Traits>
2361 std::basic_ostream<CharT, Traits>&
2364 return os << mdl.
month() <<
"/last";
2392 return m_.
ok() && wdi_.
ok();
2400 return x.month() == y.month() && x.weekday_indexed() == y.weekday_indexed();
2411 template<
class CharT,
class Traits>
2413 std::basic_ostream<CharT, Traits>&
2444 return m_.
ok() && wdl_.
ok();
2452 return x.month() == y.month() && x.weekday_last() == y.weekday_last();
2463 template<
class CharT,
class Traits>
2465 std::basic_ostream<CharT, Traits>&
2565 return y_.
ok() && mdl_.
ok();
2573 return x.year() == y.year() && x.month_day_last() == y.month_day_last();
2589 return x.year() < y.year() ? true
2590 : (x.year() > y.year() ? false
2591 : (x.month_day_last() < y.month_day_last()));
2618 template<
class CharT,
class Traits>
2620 std::basic_ostream<CharT, Traits>&
2632 return (ymdl.year() / ymdl.month() + dm) /
last;
2650 return ymdl + (-dm);
2658 return {ymdl.year()+dy, ymdl.month_day_last()};
2674 return ymdl + (-dy);
2753 year_month_day::to_days() const
NOEXCEPT
2755 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2756 "This algorithm has not been ported to a 16 bit unsigned integer");
2757 static_assert(std::numeric_limits<int>::digits >= 20,
2758 "This algorithm has not been ported to a 16 bit signed integer");
2759 auto const y =
static_cast<int>(y_) - (m_ <=
February);
2760 auto const m =
static_cast<unsigned>(m_);
2761 auto const d =
static_cast<unsigned>(d_);
2762 auto const era = (y >= 0 ? y : y-399) / 400;
2763 auto const yoe =
static_cast<unsigned>(y - era * 400);
2764 auto const doy = (153*(m > 2 ? m-3 : m+9) + 2)/5 + d-1;
2765 auto const doe = yoe * 365 + yoe/4 - yoe/100 + doy;
2766 return days{era * 146097 +
static_cast<int>(doe) - 719468};
2788 if (!(y_.
ok() && m_.
ok()))
2798 return x.year() == y.year() && x.month() == y.month() && x.day() == y.day();
2814 return x.year() < y.year() ? true
2815 : (x.year() > y.year() ? false
2816 : (x.month() < y.month() ? true
2817 : (x.month() > y.month() ? false
2818 : (x.day() < y.day()))));
2845 template<
class CharT,
class Traits>
2847 std::basic_ostream<CharT, Traits>&
2853 os.imbue(std::locale::classic());
2854 os << ymd.
year() <<
'-';
2856 os << static_cast<unsigned>(ymd.
month()) <<
'-';
2859 os <<
" is not a valid date";
2868 static_assert(std::numeric_limits<unsigned>::digits >= 18,
2869 "This algorithm has not been ported to a 16 bit unsigned integer");
2870 static_assert(std::numeric_limits<int>::digits >= 20,
2871 "This algorithm has not been ported to a 16 bit signed integer");
2872 auto const z = dp.count() + 719468;
2873 auto const era = (z >= 0 ? z : z - 146096) / 146097;
2874 auto const doe =
static_cast<unsigned>(z - era * 146097);
2875 auto const yoe = (doe - doe/1460 + doe/36524 - doe/146096) / 365;
2876 auto const y =
static_cast<days::rep
>(yoe) + era * 400;
2877 auto const doy = doe - (365*yoe + yoe/4 - yoe/100);
2878 auto const mp = (5*doy + 2)/153;
2879 auto const d = doy - (153*mp+2)/5 + 1;
2880 auto const m = mp < 10 ? mp+3 : mp-9;
2890 return (ymd.year() / ymd.month() + dm) / ymd.day();
2916 return (ymd.year() + dy) / ymd.month() / ymd.day();
3013 return wdi_.
index();
3045 if (wdi_.
index() <= 4)
3049 return static_cast<unsigned>(d2.count()) <=
static_cast<unsigned>((y_/m_/
last).day());
3059 auto const ymd = year_month_day(dp);
3060 return {ymd.year(), ymd.month(), wd[(
static_cast<unsigned>(ymd.day())-1)/7+1]};
3066 year_month_weekday::to_days() const
NOEXCEPT
3070 ).time_since_epoch();
3078 return x.year() == y.year() && x.month() == y.month() &&
3079 x.weekday_indexed() == y.weekday_indexed();
3090 template<
class CharT,
class Traits>
3092 std::basic_ostream<CharT, Traits>&
3095 return os << ymwdi.
year() <<
'/' << ymwdi.
month()
3105 return (ymwd.year() / ymwd.month() + dm) / ymwd.weekday_indexed();
3123 return ymwd + (-dm);
3131 return {ymwd.year()+dy, ymwd.month(), ymwd.weekday_indexed()};
3147 return ymwd + (-dy);
3238 return y_.
ok() && m_.
ok() && wdl_.
ok();
3244 year_month_weekday_last::to_days() const
NOEXCEPT
3255 return x.year() == y.year() && x.month() == y.month() &&
3256 x.weekday_last() == y.weekday_last();
3267 template<
class CharT,
class Traits>
3269 std::basic_ostream<CharT, Traits>&
3278 year_month_weekday_last
3281 return (ymwdl.year() / ymwdl.month() + dm) / ymwdl.weekday_last();
3287 year_month_weekday_last
3296 year_month_weekday_last
3299 return ymwdl + (-dm);
3304 year_month_weekday_last
3307 return {ymwdl.year()+dy, ymwdl.month(), ymwdl.weekday_last()};
3312 year_month_weekday_last
3320 year_month_weekday_last
3323 return ymwdl + (-dy);
3341 return y /
month(
static_cast<unsigned>(m));
3367 return m /
day(
static_cast<unsigned>(d));
3375 return month(
static_cast<unsigned>(m)) / d;
3403 return month(
static_cast<unsigned>(m))/
last;
3437 return month(
static_cast<unsigned>(m)) / wdi;
3471 return month(
static_cast<unsigned>(m)) / wdl;
3489 return {ym.year(), ym.month(), d};
3497 return ym /
day(
static_cast<unsigned>(d));
3505 return y / md.month() / md.day();
3513 return year(y) / md;
3529 return year(y) / md;
3555 return year(y) / mdl;
3571 return year(y) / mdl;
3581 return {ym.year(), ym.month(), wdi};
3589 return {y, mwd.month(), mwd.weekday_indexed()};
3597 return year(y) / mwd;
3613 return year(y) / mwd;
3620 year_month_weekday_last
3623 return {ym.year(), ym.month(), wdl};
3628 year_month_weekday_last
3631 return {y, mwdl.month(), mwdl.weekday_last()};
3636 year_month_weekday_last
3639 return year(y) / mwdl;
3644 year_month_weekday_last
3652 year_month_weekday_last
3655 return year(y) / mwdl;
3658 template <
class Duration>
3661 template <
class CharT,
class Traits,
class Duration>
3662 std::basic_ostream<CharT, Traits>&
3663 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
3665 const std::chrono::seconds* offset_sec =
nullptr);
3667 template <
class CharT,
class Traits,
class Duration,
class Alloc>
3668 std::basic_istream<CharT, Traits>&
3669 from_stream(std::basic_istream<CharT, Traits>& is,
const CharT* fmt,
3670 fields<Duration>& fds, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
3671 std::chrono::minutes* offset =
nullptr);
3689 template <std::uint64_t n, std::uint64_t d = 10,
unsigned w = 0,
3690 bool should_continue = !(n < 2) && d != 0 && (w < 19)>
3696 template <std::u
int64_t n, std::u
int64_t d,
unsigned w>
3702 template <
unsigned exp>
3708 static CONSTDATA std::uint64_t value = h * h * (exp % 2 ? 10 : 1);
3717 template <
class Duration>
3720 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
3721 using rep =
typename CT::rep;
3725 using precision = std::chrono::duration<rep,
3726 std::ratio<1, static_pow10<width>::value>>;
3729 std::chrono::seconds s_;
3739 : s_(std::chrono::duration_cast<std::chrono::seconds>(d))
3740 , sub_s_(std::chrono::duration_cast<precision>(d - s_))
3754 return sub_s_ < std::chrono::seconds{1} && s_ < std::chrono::minutes{1};
3757 template <
class CharT,
class Traits>
3759 std::basic_ostream<CharT, Traits>&
3762 return x.
print(os, std::chrono::treat_as_floating_point<rep>{});
3765 template <
class CharT,
class Traits>
3766 std::basic_ostream<CharT, Traits>&
3767 print(std::basic_ostream<CharT, Traits>& os, std::true_type)
const
3770 std::chrono::duration<rep> d = s_ + sub_s_;
3771 if (d < std::chrono::seconds{10})
3773 os << std::fixed << d.count();
3777 template <
class CharT,
class Traits>
3778 std::basic_ostream<CharT, Traits>&
3779 print(std::basic_ostream<CharT, Traits>& os, std::false_type)
const
3789 os << std::use_facet<std::numpunct<CharT>>(os.getloc()).decimal_point();
3794 os.imbue(std::locale::classic());
3796 os << sub_s_.count();
3802 template <
class Rep,
class Period>
3805 typename std::enable_if
3807 std::numeric_limits<Rep>::is_signed,
3808 std::chrono::duration<Rep, Period>
3810 abs(std::chrono::duration<Rep, Period> d)
3812 return d >= d.zero() ? +d : -d;
3815 template <
class Rep,
class Period>
3818 typename std::enable_if
3820 !std::numeric_limits<Rep>::is_signed,
3821 std::chrono::duration<Rep, Period>
3823 abs(std::chrono::duration<Rep, Period> d)
3830 template <
class Duration>
3834 std::chrono::seconds>::type>;
3836 std::chrono::hours h_;
3837 std::chrono::minutes m_;
3850 : h_(std::chrono::duration_cast<std::chrono::hours>(
detail::abs(d)))
3851 , m_(std::chrono::duration_cast<std::chrono::minutes>(
detail::abs(d)) - h_)
3853 , neg_(d < Duration::zero())
3866 {
return (s_.
to_duration() + m_ + h_) * (1-2*neg_);}
3870 return !neg_ && h_ <
days{1} && m_ < std::chrono::hours{1} &&
3876 template <
class charT,
class traits>
3878 std::basic_ostream<charT, traits>&
3883 if (tod.h_ < std::chrono::hours{10})
3885 os << tod.h_.count() <<
':';
3886 if (tod.m_ < std::chrono::minutes{10})
3888 os << tod.m_.count() <<
':' << tod.s_;
3892 template <
class CharT,
class Traits,
class Duration2>
3894 std::basic_ostream<CharT, Traits>&
3895 date::to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
3897 const std::chrono::seconds* offset_sec);
3899 template <
class CharT,
class Traits,
class Duration2,
class Alloc>
3901 std::basic_istream<CharT, Traits>&
3904 std::basic_string<CharT, Traits, Alloc>* abbrev, std::chrono::minutes* offset);
3912 using std::chrono::hours;
3913 return hours{0} <= h && h < hours{12};
3921 using std::chrono::hours;
3922 return hours{12} <= h && h < hours{24};
3930 using std::chrono::hours;
3949 using std::chrono::hours;
3955 else if (h == hours{12})
3960 template <
class Duration>
3963 template <
class Rep,
class Period,
3964 class =
typename std::enable_if
3965 <!std::chrono::treat_as_floating_point<Rep>::value>::type>
3974 template <
class CharT,
class Traits,
class Duration>
3976 typename std::enable_if
3978 !std::chrono::treat_as_floating_point<typename Duration::rep>::value &&
3979 std::ratio_less<typename Duration::period, days::period>::value
3980 , std::basic_ostream<CharT, Traits>&
3984 auto const dp = date::floor<days>(tp);
3988 template <
class CharT,
class Traits>
3990 std::basic_ostream<CharT, Traits>&
3996 template <
class CharT,
class Traits,
class Duration>
3998 std::basic_ostream<CharT, Traits>&
4007 template <
class CharT, std::
size_t N>
4010 template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4013 string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4017 template <
class CharT, std::
size_t N>
4027 using const_iterator =
const CharT*;
4029 string_literal(string_literal
const&) =
default;
4030 string_literal& operator=(string_literal
const&) =
delete;
4032 template <std::size_t N1 = 2,
4033 class =
typename std::enable_if<N1 == N>::type>
4039 template <std::size_t N1 = 3,
4040 class =
typename std::enable_if<N1 == N>::type>
4046 template <std::size_t N1 = 4,
4047 class =
typename std::enable_if<N1 == N>::type>
4056 for (std::size_t i = 0; i < N; ++i)
4060 template <
class U = CharT,
4061 class =
typename std::enable_if<(1 <
sizeof(U))>::type>
4065 for (std::size_t i = 0; i < N; ++i)
4069 template <
class CharT2,
4070 class =
typename std::enable_if<!std::is_same<CharT2, CharT>::value>::type>
4074 for (std::size_t i = 0; i < N; ++i)
4089 template <
class Traits>
4091 std::basic_ostream<CharT, Traits>&
4092 operator<<(std::basic_ostream<CharT, Traits>& os,
const string_literal& s)
4097 template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4100 string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4102 operator+(
const string_literal<CharT1, N1>& x,
const string_literal<CharT2, N2>& y)
NOEXCEPT;
4105 template <
class CharT>
4108 string_literal<CharT, 3>
4109 operator+(
const string_literal<CharT, 2>& x,
const string_literal<CharT, 2>& y)
NOEXCEPT
4111 return string_literal<CharT, 3>(x[0], y[0]);
4114 template <
class CharT>
4117 string_literal<CharT, 4>
4118 operator+(
const string_literal<CharT, 3>& x,
const string_literal<CharT, 2>& y)
NOEXCEPT
4120 return string_literal<CharT, 4>(x[0], x[1], y[0]);
4123 template <
class CharT1,
class CharT2, std::
size_t N1, std::
size_t N2>
4126 string_literal<
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type,
4128 operator+(
const string_literal<CharT1, N1>& x,
const string_literal<CharT2, N2>& y)
NOEXCEPT
4130 using CT =
typename std::conditional<
sizeof(CharT2) <=
sizeof(CharT1), CharT1, CharT2>::type;
4132 string_literal<CT, N1 + N2 - 1> r;
4134 for (; i < N1-1; ++i)
4135 r.p_[i] = CT(x.p_[i]);
4136 for (std::size_t j = 0; j < N2; ++j, ++i)
4137 r.p_[i] = CT(y.p_[j]);
4143 template <
class CharT,
class Traits,
class Alloc, std::
size_t N>
4145 std::basic_string<CharT, Traits, Alloc>
4146 operator+(std::basic_string<CharT, Traits, Alloc> x,
const string_literal<CharT, N>& y)
4148 x.append(y.data(), y.size());
4152 #if __cplusplus >= 201402 && (!defined(__EDG_VERSION__) || __EDG_VERSION__ > 411) \
4153 && (!defined(__SUNPRO_CC) || __SUNPRO_CC > 0x5150)
4155 template <
class CharT,
4156 class = std::enable_if_t<std::is_same<CharT, char>::value ||
4157 std::is_same<CharT, wchar_t>::value ||
4158 std::is_same<CharT, char16_t>::value ||
4159 std::is_same<CharT, char32_t>::value>>
4162 string_literal<CharT, 2>
4165 return string_literal<CharT, 2>{c};
4171 to_string_len(std::intmax_t i)
4182 template <std::
intmax_t N>
4188 string_literal<char, to_string_len(N)+1>
4192 return msl(
char(N % 10 +
'0'));
4195 template <std::
intmax_t N>
4201 string_literal<char, to_string_len(N)+1>
4205 return msl<N/10>() + msl(
char(N % 10 +
'0'));
4208 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4213 std::ratio<N, D>::type::den != 1,
4214 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) +
4215 to_string_len(std::ratio<N, D>::type::den) + 4>
4219 using R =
typename std::ratio<N, D>::type;
4220 return msl(CharT{
'['}) + msl<R::num>() + msl(CharT{
'/'}) +
4221 msl<R::den>() + msl(CharT{
']'});
4224 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4229 std::ratio<N, D>::type::den == 1,
4230 string_literal<CharT, to_string_len(std::ratio<N, D>::type::num) + 3>
4234 using R =
typename std::ratio<N, D>::type;
4235 return msl(CharT{
'['}) + msl<R::num>() + msl(CharT{
']'});
4239 #else // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411)
4243 to_string(std::uint64_t x)
4245 return std::to_string(x);
4248 template <
class CharT>
4250 std::basic_string<CharT>
4251 to_string(std::uint64_t x)
4253 auto y = std::to_string(x);
4254 return std::basic_string<CharT>(y.begin(), y.end());
4257 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4259 typename std::enable_if
4261 std::ratio<N, D>::type::den != 1,
4262 std::basic_string<CharT>
4264 msl(std::ratio<N, D>)
4266 using R =
typename std::ratio<N, D>::type;
4267 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
'/'} +
4268 to_string<CharT>(R::den) + CharT{
']'};
4271 template <
class CharT, std::
intmax_t N, std::
intmax_t D>
4273 typename std::enable_if
4275 std::ratio<N, D>::type::den == 1,
4276 std::basic_string<CharT>
4278 msl(std::ratio<N, D>)
4280 using R =
typename std::ratio<N, D>::type;
4281 return std::basic_string<CharT>(1,
'[') + to_string<CharT>(R::num) + CharT{
']'};
4284 #endif // __cplusplus < 201402 || (defined(__EDG_VERSION__) && __EDG_VERSION__ <= 411)
4286 template <
class CharT>
4289 string_literal<CharT, 2>
4292 return string_literal<CharT, 2>{
'a'};
4295 template <
class CharT>
4298 string_literal<CharT, 2>
4301 return string_literal<CharT, 2>{
'f'};
4304 template <
class CharT>
4307 string_literal<CharT, 2>
4310 return string_literal<CharT, 2>{
'p'};
4313 template <
class CharT>
4316 string_literal<CharT, 2>
4319 return string_literal<CharT, 2>{
'n'};
4322 template <
class CharT>
4325 typename std::enable_if
4327 std::is_same<CharT, char>::value,
4328 string_literal<char, 3>
4332 return string_literal<char, 3>{
'\xC2',
'\xB5'};
4335 template <
class CharT>
4338 typename std::enable_if
4340 !std::is_same<CharT, char>::value,
4341 string_literal<CharT, 2>
4345 return string_literal<CharT, 2>{CharT{
static_cast<unsigned char>(
'\xB5')}};
4348 template <
class CharT>
4351 string_literal<CharT, 2>
4354 return string_literal<CharT, 2>{
'm'};
4357 template <
class CharT>
4360 string_literal<CharT, 2>
4363 return string_literal<CharT, 2>{
'c'};
4366 template <
class CharT>
4369 string_literal<CharT, 3>
4372 return string_literal<CharT, 3>{
'd',
'a'};
4375 template <
class CharT>
4378 string_literal<CharT, 2>
4381 return string_literal<CharT, 2>{
'd'};
4384 template <
class CharT>
4387 string_literal<CharT, 2>
4390 return string_literal<CharT, 2>{
'h'};
4393 template <
class CharT>
4396 string_literal<CharT, 2>
4399 return string_literal<CharT, 2>{
'k'};
4402 template <
class CharT>
4405 string_literal<CharT, 2>
4408 return string_literal<CharT, 2>{
'M'};
4411 template <
class CharT>
4414 string_literal<CharT, 2>
4417 return string_literal<CharT, 2>{
'G'};
4420 template <
class CharT>
4423 string_literal<CharT, 2>
4426 return string_literal<CharT, 2>{
'T'};
4429 template <
class CharT>
4432 string_literal<CharT, 2>
4435 return string_literal<CharT, 2>{
'P'};
4438 template <
class CharT>
4441 string_literal<CharT, 2>
4444 return string_literal<CharT, 2>{
'E'};
4447 template <
class CharT,
class Period>
4452 -> decltype(msl<CharT>(p) + string_literal<CharT, 2>{
's'})
4454 return msl<CharT>(p) + string_literal<CharT, 2>{
's'};
4457 template <
class CharT>
4460 string_literal<CharT, 2>
4461 get_units(std::ratio<1>)
4463 return string_literal<CharT, 2>{
's'};
4466 template <
class CharT>
4469 string_literal<CharT, 2>
4470 get_units(std::ratio<3600>)
4472 return string_literal<CharT, 2>{
'h'};
4475 template <
class CharT>
4478 string_literal<CharT, 4>
4479 get_units(std::ratio<60>)
4481 return string_literal<CharT, 4>{
'm',
'i',
'n'};
4484 template <
class CharT>
4487 string_literal<CharT, 2>
4488 get_units(std::ratio<86400>)
4490 return string_literal<CharT, 2>{
'd'};
4493 template <
class CharT,
class Traits = std::
char_traits<CharT>>
4497 struct make_string<char>
4499 template <
class Rep>
4504 return std::to_string(n);
4508 template <
class Traits>
4509 struct make_string<char, Traits>
4511 template <
class Rep>
4513 std::basic_string<char, Traits>
4516 auto s = std::to_string(n);
4517 return std::basic_string<char, Traits>(s.begin(), s.end());
4522 struct make_string<wchar_t>
4524 template <
class Rep>
4529 return std::to_wstring(n);
4533 template <
class Traits>
4534 struct make_string<wchar_t, Traits>
4536 template <
class Rep>
4538 std::basic_string<wchar_t, Traits>
4541 auto s = std::to_wstring(n);
4542 return std::basic_string<wchar_t, Traits>(s.begin(), s.end());
4552 template <
class Duration>
4583 template <
class CharT,
class Traits,
class Duration>
4587 if (!fds.ymd.ok() && !fds.wd.ok())
4590 os.setstate(std::ios::failbit);
4597 if (fds.wd.ok() && wd != fds.wd)
4600 os.setstate(std::ios::failbit);
4606 return static_cast<unsigned>((wd -
Sunday).count());
4609 template <
class CharT,
class Traits,
class Duration>
4613 if (!fds.ymd.month().ok())
4616 os.setstate(std::ios::failbit);
4619 return static_cast<unsigned>(fds.ymd.month());
4630 std::pair<const std::string*, const std::string*>
4633 static const std::string nm[] =
4650 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4654 std::pair<const std::string*, const std::string*>
4657 static const std::string nm[] =
4684 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4688 std::pair<const std::string*, const std::string*>
4691 static const std::string nm[] =
4696 return std::make_pair(nm, nm+
sizeof(nm)/
sizeof(nm[0]));
4699 template <
class CharT,
class Traits,
class FwdIter>
4701 scan_keyword(std::basic_istream<CharT, Traits>& is, FwdIter kb, FwdIter ke)
4703 size_t nkw =
static_cast<size_t>(std::distance(kb, ke));
4704 const unsigned char doesnt_match =
'\0';
4705 const unsigned char might_match =
'\1';
4706 const unsigned char does_match =
'\2';
4707 unsigned char statbuf[100];
4708 unsigned char* status = statbuf;
4709 std::unique_ptr<
unsigned char, void(*)(
void*)> stat_hold(0, free);
4710 if (nkw >
sizeof(statbuf))
4712 status = (
unsigned char*)std::malloc(nkw);
4713 if (status ==
nullptr)
4714 throw std::bad_alloc();
4715 stat_hold.reset(status);
4717 size_t n_might_match = nkw;
4718 size_t n_does_match = 0;
4720 unsigned char* st = status;
4721 for (
auto ky = kb; ky != ke; ++ky, ++st)
4733 for (
size_t indx = 0; is && n_might_match > 0; ++indx)
4736 auto ic = is.peek();
4739 is.setstate(std::ios::eofbit);
4742 auto c =
static_cast<char>(toupper(ic));
4743 bool consume =
false;
4751 for (
auto ky = kb; ky != ke; ++ky, ++st)
4753 if (*st == might_match)
4755 if (c ==
static_cast<char>(toupper((*ky)[indx])))
4758 if (ky->size() == indx+1)
4779 if (n_might_match + n_does_match > 1)
4782 for (
auto ky = kb; ky != ke; ++ky, ++st)
4784 if (*st == does_match && ky->size() != indx+1)
4795 for (st = status; kb != ke; ++kb, ++st)
4796 if (*st == does_match)
4799 is.setstate(std::ios::failbit);
4805 #endif // ONLY_C_LOCALE
4807 template <
class CharT,
class Traits,
class Duration>
4808 std::basic_ostream<CharT, Traits>&
4809 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
4811 const std::chrono::seconds* offset_sec)
4814 using detail::weekday_names;
4815 using detail::month_names;
4816 using detail::ampm_names;
4819 using detail::get_units;
4823 using std::chrono::duration_cast;
4824 using std::chrono::seconds;
4825 using std::chrono::minutes;
4826 using std::chrono::hours;
4832 bool insert_negative = fds.has_tod && fds.tod.to_duration() < Duration::zero();
4834 auto& facet = std::use_facet<std::time_put<CharT>>(os.getloc());
4836 const CharT* command =
nullptr;
4837 CharT modified = CharT{};
4846 if (modified == CharT{})
4852 const CharT f[] = {
'%', *fmt};
4853 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
4854 #else // ONLY_C_LOCALE
4855 os << weekday_names().first[tm.tm_wday+7*(*fmt ==
'a')];
4856 #endif // ONLY_C_LOCALE
4860 os << CharT{
'%'} << modified << *fmt;
4873 if (modified == CharT{})
4877 const CharT f[] = {
'%', *fmt};
4878 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
4879 #else // ONLY_C_LOCALE
4880 os << month_names().first[tm.tm_mon+12*(*fmt !=
'B')];
4881 #endif // ONLY_C_LOCALE
4885 os << CharT{
'%'} << modified << *fmt;
4897 if (modified == CharT{
'O'})
4898 os << CharT{
'%'} << modified << *fmt;
4902 os.setstate(std::ios::failbit);
4903 if (*fmt ==
'c' && !fds.has_tod)
4904 os.setstate(std::ios::failbit);
4907 auto const& ymd = fds.ymd;
4911 tm.tm_sec =
static_cast<int>(fds.tod.seconds().count());
4912 tm.tm_min =
static_cast<int>(fds.tod.minutes().count());
4913 tm.tm_hour =
static_cast<int>(fds.tod.hours().count());
4915 tm.tm_mday =
static_cast<int>(
static_cast<unsigned>(ymd.day()));
4917 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
4921 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
4923 auto fe = std::begin(f) + 1;
4924 if (modified == CharT{
'E'})
4927 facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
4928 #else // ONLY_C_LOCALE
4932 os << weekday_names().first[
static_cast<unsigned>(wd)+7]
4934 os << month_names().first[
extract_month(os, fds)-1+12] <<
' ';
4935 auto d =
static_cast<int>(
static_cast<unsigned>(fds.ymd.day()));
4939 <<
make_time(duration_cast<seconds>(fds.tod.to_duration()))
4940 <<
' ' << fds.ymd.year();
4945 auto const& ymd = fds.ymd;
4946 save_ostream<CharT, Traits> _(os);
4950 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
4952 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
4954 os << static_cast<int>(ymd.year()) % 100;
4956 #endif // ONLY_C_LOCALE
4967 if (modified == CharT{
'O'})
4968 os << CharT{
'%'} << modified << *fmt;
4971 if (!fds.ymd.year().ok())
4972 os.setstate(std::ios::failbit);
4973 auto y =
static_cast<int>(fds.ymd.year());
4975 if (modified == CharT{})
4978 save_ostream<CharT, Traits> _(os);
4994 else if (modified == CharT{
'E'})
4996 tm.tm_year = y - 1900;
4997 CharT f[3] = {
'%',
'E',
'C'};
4998 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5012 if (modified == CharT{
'E'})
5013 os << CharT{
'%'} << modified << *fmt;
5016 if (!fds.ymd.day().ok())
5017 os.setstate(std::ios::failbit);
5018 auto d =
static_cast<int>(
static_cast<unsigned>(fds.ymd.day()));
5020 if (modified == CharT{})
5023 save_ostream<CharT, Traits> _(os);
5024 if (*fmt == CharT{
'd'})
5033 else if (modified == CharT{
'O'})
5036 CharT f[3] = {
'%',
'O', *fmt};
5037 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5050 if (modified == CharT{})
5053 os.setstate(std::ios::failbit);
5054 auto const& ymd = fds.ymd;
5055 save_ostream<CharT, Traits> _(os);
5059 os << static_cast<unsigned>(ymd.month()) << CharT{
'/'};
5061 os << static_cast<unsigned>(ymd.day()) << CharT{
'/'};
5063 os << static_cast<int>(ymd.year()) % 100;
5067 os << CharT{
'%'} << modified << *fmt;
5078 if (modified == CharT{})
5081 os.setstate(std::ios::failbit);
5082 auto const& ymd = fds.ymd;
5083 save_ostream<CharT, Traits> _(os);
5084 os.imbue(std::locale::classic());
5088 os << static_cast<int>(ymd.year()) << CharT{
'-'};
5090 os << static_cast<unsigned>(ymd.month()) << CharT{
'-'};
5092 os << static_cast<unsigned>(ymd.day());
5096 os << CharT{
'%'} << modified << *fmt;
5108 if (modified == CharT{})
5111 os.setstate(std::ios::failbit);
5118 if (*fmt == CharT{
'G'})
5122 save_ostream<CharT, Traits> _(os);
5126 os << std::abs(static_cast<int>(y)) % 100;
5131 os << CharT{
'%'} << modified << *fmt;
5143 if (modified == CharT{
'E'})
5144 os << CharT{
'%'} << modified << *fmt;
5148 os.setstate(std::ios::failbit);
5149 if (insert_negative)
5152 insert_negative =
false;
5156 if (modified == CharT{})
5159 auto h = *fmt == CharT{
'I'} ?
date::make12(hms.hours()) : hms.hours();
5165 else if (modified == CharT{
'O'})
5167 const CharT f[] = {
'%', modified, *fmt};
5168 tm.tm_hour =
static_cast<int>(hms.hours().count());
5169 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5182 if (modified == CharT{})
5184 if (fds.ymd.ok() || fds.has_tod)
5190 auto y = fds.ymd.year();
5195 doy = duration_cast<days>(fds.tod.to_duration());
5197 save_ostream<CharT, Traits> _(os);
5205 os.setstate(std::ios::failbit);
5210 os << CharT{
'%'} << modified << *fmt;
5221 if (modified == CharT{
'E'})
5222 os << CharT{
'%'} << modified << *fmt;
5225 if (!fds.ymd.month().ok())
5226 os.setstate(std::ios::failbit);
5227 auto m =
static_cast<unsigned>(fds.ymd.month());
5229 if (modified == CharT{})
5237 else if (modified == CharT{
'O'})
5239 const CharT f[] = {
'%', modified, *fmt};
5240 tm.tm_mon =
static_cast<int>(m-1);
5241 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5254 if (modified == CharT{
'E'})
5255 os << CharT{
'%'} << modified << *fmt;
5259 os.setstate(std::ios::failbit);
5260 if (insert_negative)
5263 insert_negative =
false;
5266 if (modified == CharT{})
5269 if (fds.tod.minutes() < minutes{10})
5271 os << fds.tod.minutes().count();
5274 else if (modified == CharT{
'O'})
5276 const CharT f[] = {
'%', modified, *fmt};
5277 tm.tm_min =
static_cast<int>(fds.tod.minutes().count());
5278 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5291 if (modified == CharT{})
5295 os << CharT{
'%'} << modified << *fmt;
5306 if (modified == CharT{})
5309 os.setstate(std::ios::failbit);
5311 const CharT f[] = {
'%', *fmt};
5312 tm.tm_hour =
static_cast<int>(fds.tod.hours().count());
5313 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5316 os << ampm_names().first[0];
5318 os << ampm_names().first[1];
5323 os << CharT{
'%'} << modified << *fmt;
5335 if (modified == CharT{})
5338 os.setstate(std::ios::failbit);
5339 auto d = fds.tod.to_duration();
5341 os << get_units<CharT>(
typename decltype(d)::period::type{});
5347 os << CharT{
'%'} << modified << *fmt;
5358 if (modified == CharT{})
5361 os.setstate(std::ios::failbit);
5363 const CharT f[] = {
'%', *fmt};
5364 tm.tm_hour =
static_cast<int>(fds.tod.hours().count());
5365 tm.tm_min =
static_cast<int>(fds.tod.minutes().count());
5366 tm.tm_sec =
static_cast<int>(fds.tod.seconds().count());
5367 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5370 save_ostream<CharT, Traits> _(os);
5375 os << tod.
minutes().count() << CharT{
':'};
5377 os << tod.
seconds().count() << CharT{
' '};
5379 os << ampm_names().first[0];
5381 os << ampm_names().first[1];
5386 os << CharT{
'%'} << modified << *fmt;
5397 if (modified == CharT{})
5400 os.setstate(std::ios::failbit);
5401 if (fds.tod.hours() < hours{10})
5403 os << fds.tod.hours().count() << CharT{
':'};
5404 if (fds.tod.minutes() < minutes{10})
5406 os << fds.tod.minutes().count();
5410 os << CharT{
'%'} << modified << *fmt;
5421 if (modified == CharT{
'E'})
5422 os << CharT{
'%'} << modified << *fmt;
5426 os.setstate(std::ios::failbit);
5427 if (insert_negative)
5430 insert_negative =
false;
5433 if (modified == CharT{})
5439 else if (modified == CharT{
'O'})
5441 const CharT f[] = {
'%', modified, *fmt};
5442 tm.tm_sec =
static_cast<int>(fds.tod.s_.seconds().count());
5443 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5456 if (modified == CharT{})
5460 os << CharT{
'%'} << modified << *fmt;
5471 if (modified == CharT{})
5474 os.setstate(std::ios::failbit);
5479 os << CharT{
'%'} << modified << *fmt;
5490 if (modified == CharT{
'E'})
5491 os << CharT{
'%'} << modified << *fmt;
5496 if (modified == CharT{})
5499 os << (wd != 0 ? wd : 7u);
5502 else if (modified == CharT{
'O'})
5504 const CharT f[] = {
'%', modified, *fmt};
5505 tm.tm_wday =
static_cast<int>(wd);
5506 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5519 if (modified == CharT{
'E'})
5520 os << CharT{
'%'} << modified << *fmt;
5523 auto const& ymd = fds.ymd;
5525 os.setstate(std::ios::failbit);
5528 if (modified == CharT{})
5533 os << CharT{
'0'} << CharT{
'0'};
5536 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5543 else if (modified == CharT{
'O'})
5545 const CharT f[] = {
'%', modified, *fmt};
5546 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5550 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5551 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5564 if (modified == CharT{
'E'})
5565 os << CharT{
'%'} << modified << *fmt;
5569 os.setstate(std::ios::failbit);
5572 if (modified == CharT{})
5584 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5590 else if (modified == CharT{
'O'})
5592 const CharT f[] = {
'%', modified, *fmt};
5593 auto const& ymd = fds.ymd;
5594 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5598 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5599 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5616 if (modified == CharT{})
5618 if (modified != CharT{
'E'})
5624 else if (modified == CharT{
'O'})
5626 const CharT f[] = {
'%', modified, *fmt};
5627 tm.tm_wday =
static_cast<int>(wd);
5628 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5633 os << CharT{
'%'} << modified << *fmt;
5644 if (modified == CharT{
'E'})
5645 os << CharT{
'%'} << modified << *fmt;
5648 auto const& ymd = fds.ymd;
5650 os.setstate(std::ios::failbit);
5653 if (modified == CharT{})
5658 os << CharT{
'0'} << CharT{
'0'};
5661 auto wn = duration_cast<weeks>(ld - st).count() + 1;
5668 else if (modified == CharT{
'O'})
5670 const CharT f[] = {
'%', modified, *fmt};
5671 tm.tm_year =
static_cast<int>(ymd.year()) - 1900;
5675 tm.tm_yday =
static_cast<int>((ld -
local_days(ymd.year()/1/1)).count());
5676 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5689 if (modified == CharT{
'O'})
5690 os << CharT{
'%'} << modified << *fmt;
5694 os.setstate(std::ios::failbit);
5697 tm.tm_sec =
static_cast<int>(fds.tod.seconds().count());
5698 tm.tm_min =
static_cast<int>(fds.tod.minutes().count());
5699 tm.tm_hour =
static_cast<int>(fds.tod.hours().count());
5701 auto fe = std::begin(f) + 1;
5702 if (modified == CharT{
'E'})
5705 facet.put(os, os, os.fill(), &tm, std::begin(f), fe);
5719 if (!fds.ymd.year().ok())
5720 os.setstate(std::ios::failbit);
5721 auto y =
static_cast<int>(fds.ymd.year());
5723 if (modified == CharT{})
5734 const CharT f[] = {
'%', modified, *fmt};
5735 tm.tm_year = y - 1900;
5736 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5748 if (modified == CharT{
'O'})
5749 os << CharT{
'%'} << modified << *fmt;
5752 if (!fds.ymd.year().ok())
5753 os.setstate(std::ios::failbit);
5754 auto y = fds.ymd.year();
5756 if (modified == CharT{})
5759 save_ostream<CharT, Traits> _(os);
5760 os.imbue(std::locale::classic());
5764 else if (modified == CharT{
'E'})
5766 const CharT f[] = {
'%', modified, *fmt};
5767 tm.tm_year =
static_cast<int>(y) - 1900;
5768 facet.put(os, os, os.fill(), &tm, std::begin(f), std::end(f));
5781 if (offset_sec ==
nullptr)
5784 os.setstate(ios::failbit);
5787 auto m = duration_cast<minutes>(*offset_sec);
5788 auto neg = m < minutes{0};
5790 auto h = duration_cast<hours>(m);
5799 if (modified != CharT{})
5801 if (m < minutes{10})
5813 if (modified == CharT{})
5815 if (abbrev ==
nullptr)
5818 os.setstate(ios::failbit);
5821 for (
auto c : *abbrev)
5826 os << CharT{
'%'} << modified << *fmt;
5838 if (modified == CharT{})
5844 os << CharT{
'%'} << modified << *fmt;
5855 if (modified == CharT{})
5862 os << CharT{
'%'} << modified << CharT{
'%'};
5876 if (modified != CharT{})
5887 if (modified != CharT{})
5892 template <
class CharT,
class Traits>
5894 std::basic_ostream<CharT, Traits>&
5895 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const year& y)
5897 using CT = std::chrono::seconds;
5902 template <
class CharT,
class Traits>
5904 std::basic_ostream<CharT, Traits>&
5907 using CT = std::chrono::seconds;
5912 template <
class CharT,
class Traits>
5914 std::basic_ostream<CharT, Traits>&
5915 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
const day& d)
5917 using CT = std::chrono::seconds;
5922 template <
class CharT,
class Traits>
5924 std::basic_ostream<CharT, Traits>&
5927 using CT = std::chrono::seconds;
5932 template <
class CharT,
class Traits>
5934 std::basic_ostream<CharT, Traits>&
5937 using CT = std::chrono::seconds;
5942 template <
class CharT,
class Traits>
5944 std::basic_ostream<CharT, Traits>&
5947 using CT = std::chrono::seconds;
5952 template <
class CharT,
class Traits>
5954 std::basic_ostream<CharT, Traits>&
5955 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5958 using CT = std::chrono::seconds;
5963 template <
class CharT,
class Traits,
class Rep,
class Period>
5965 std::basic_ostream<CharT, Traits>&
5966 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5967 const std::chrono::duration<Rep, Period>& d)
5969 using Duration = std::chrono::duration<Rep, Period>;
5970 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
5975 template <
class CharT,
class Traits,
class Duration>
5976 std::basic_ostream<CharT, Traits>&
5977 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5979 const std::chrono::seconds* offset_sec =
nullptr)
5981 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
5982 auto ld = floor<days>(tp);
5984 return to_stream(os, fmt, fds, abbrev, offset_sec);
5987 template <
class CharT,
class Traits,
class Duration>
5988 std::basic_ostream<CharT, Traits>&
5989 to_stream(std::basic_ostream<CharT, Traits>& os,
const CharT* fmt,
5992 using std::chrono::seconds;
5993 using CT =
typename std::common_type<Duration, seconds>::type;
5994 const std::string abbrev(
"UTC");
5996 auto sd = floor<days>(tp);
5998 return to_stream(os, fmt, fds, &abbrev, &offset);
6003 template <
class CharT,
class Streamable>
6005 format(
const std::locale& loc,
const CharT* fmt,
const Streamable& tp)
6006 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
6007 std::basic_string<CharT>{})
6009 std::basic_ostringstream<CharT> os;
6010 os.exceptions(std::ios::failbit | std::ios::badbit);
6016 template <
class CharT,
class Streamable>
6018 format(
const CharT* fmt,
const Streamable& tp)
6019 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT>&>(), fmt, tp),
6020 std::basic_string<CharT>{})
6022 std::basic_ostringstream<CharT> os;
6023 os.exceptions(std::ios::failbit | std::ios::badbit);
6028 template <
class CharT,
class Traits,
class Alloc,
class Streamable>
6030 format(
const std::locale& loc,
const std::basic_string<CharT, Traits, Alloc>& fmt,
6031 const Streamable& tp)
6032 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
6033 std::basic_string<CharT, Traits, Alloc>{})
6035 std::basic_ostringstream<CharT, Traits, Alloc> os;
6036 os.exceptions(std::ios::failbit | std::ios::badbit);
6042 template <
class CharT,
class Traits,
class Alloc,
class Streamable>
6044 format(
const std::basic_string<CharT, Traits, Alloc>& fmt,
const Streamable& tp)
6045 -> decltype(
to_stream(std::declval<std::basic_ostream<CharT, Traits>&>(), fmt.c_str(), tp),
6046 std::basic_string<CharT, Traits, Alloc>{})
6048 std::basic_ostringstream<CharT, Traits, Alloc> os;
6049 os.exceptions(std::ios::failbit | std::ios::badbit);
6059 template <
class CharT,
class Traits>
6061 read_char(std::basic_istream<CharT, Traits>& is, CharT fmt, std::ios::iostate& err)
6064 if (Traits::eq_int_type(ic, Traits::eof()) ||
6065 !Traits::eq(Traits::to_char_type(ic), fmt))
6067 err |= std::ios::failbit;
6068 is.setstate(std::ios::failbit);
6074 template <
class CharT,
class Traits>
6076 read_unsigned(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
6082 auto ic = is.peek();
6083 if (Traits::eq_int_type(ic, Traits::eof()))
6085 auto c =
static_cast<char>(Traits::to_char_type(ic));
6086 if (!(
'0' <= c && c <=
'9'))
6090 x = 10*x +
static_cast<unsigned>(c -
'0');
6095 is.setstate(std::ios::failbit);
6099 template <
class CharT,
class Traits>
6101 read_signed(std::basic_istream<CharT, Traits>& is,
unsigned m = 1,
unsigned M = 10)
6103 auto ic = is.peek();
6104 if (!Traits::eq_int_type(ic, Traits::eof()))
6106 auto c =
static_cast<char>(Traits::to_char_type(ic));
6107 if ((
'0' <= c && c <=
'9') || c ==
'-' || c ==
'+')
6109 if (c ==
'-' || c ==
'+')
6111 auto x =
static_cast<int>(
read_unsigned(is, std::max(m, 1u), M));
6121 is.setstate(std::ios::failbit);
6125 template <
class CharT,
class Traits>
6130 auto decimal_point = Traits::to_int_type(
6131 std::use_facet<std::numpunct<CharT>>(is.getloc()).decimal_point());
6135 auto ic = is.peek();
6136 if (Traits::eq_int_type(ic, Traits::eof()))
6138 if (Traits::eq_int_type(ic, decimal_point))
6141 decimal_point = Traits::eof();
6146 auto c =
static_cast<char>(Traits::to_char_type(ic));
6147 if (!(
'0' <= c && c <=
'9'))
6157 is.setstate(std::ios::failbit);
6160 return std::stold(buf);
6184 template <
class CharT,
class Traits>
6186 read(std::basic_istream<CharT, Traits>&)
6190 template <
class CharT,
class Traits,
class ...Args>
6192 read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args);
6194 template <
class CharT,
class Traits,
class ...Args>
6196 read(std::basic_istream<CharT, Traits>& is, rs a0, Args&& ...args);
6198 template <
class CharT,
class Traits,
class ...Args>
6200 read(std::basic_istream<CharT, Traits>& is, ru a0, Args&& ...args);
6202 template <
class CharT,
class Traits,
class ...Args>
6204 read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args);
6206 template <
class CharT,
class Traits,
class ...Args>
6208 read(std::basic_istream<CharT, Traits>& is, rld a0, Args&& ...args);
6210 template <
class CharT,
class Traits,
class ...Args>
6212 read(std::basic_istream<CharT, Traits>& is, CharT a0, Args&& ...args)
6217 auto ic = is.peek();
6218 if (Traits::eq_int_type(ic, Traits::eof()))
6220 is.setstate(std::ios::failbit | std::ios::eofbit);
6223 if (!Traits::eq(Traits::to_char_type(ic), a0))
6225 is.setstate(std::ios::failbit);
6230 read(is, std::forward<Args>(args)...);
6233 template <
class CharT,
class Traits,
class ...Args>
6235 read(std::basic_istream<CharT, Traits>& is,
rs a0, Args&& ...args)
6241 read(is, std::forward<Args>(args)...);
6244 template <
class CharT,
class Traits,
class ...Args>
6246 read(std::basic_istream<CharT, Traits>& is,
ru a0, Args&& ...args)
6251 a0.
i =
static_cast<int>(x);
6252 read(is, std::forward<Args>(args)...);
6255 template <
class CharT,
class Traits,
class ...Args>
6257 read(std::basic_istream<CharT, Traits>& is,
int a0, Args&& ...args)
6261 auto u =
static_cast<unsigned>(a0);
6262 CharT buf[std::numeric_limits<unsigned>::digits10+2u] = {};
6266 *e++ =
static_cast<CharT
>(CharT(u % 10) + CharT{
'0'});
6269 std::reverse(buf, e);
6270 for (
auto p = buf; p != e && is.rdstate() == std::ios::goodbit; ++p)
6273 if (is.rdstate() == std::ios::goodbit)
6274 read(is, std::forward<Args>(args)...);
6277 template <
class CharT,
class Traits,
class ...Args>
6279 read(std::basic_istream<CharT, Traits>& is,
rld a0, Args&& ...args)
6285 read(is, std::forward<Args>(args)...);
6288 template <
class T,
class CharT,
class Traits>
6291 checked_set(T& value, T from, T not_a_value, std::basic_ios<CharT, Traits>& is)
6295 if (value == not_a_value)
6296 value = std::move(from);
6297 else if (value != from)
6298 is.setstate(std::ios::failbit);
6304 template <
class CharT,
class Traits,
class Duration,
class Alloc = std::allocator<CharT>>
6305 std::basic_istream<CharT, Traits>&
6308 std::chrono::minutes* offset)
6310 using std::numeric_limits;
6312 using std::chrono::duration;
6313 using std::chrono::duration_cast;
6314 using std::chrono::seconds;
6315 using std::chrono::minutes;
6316 using std::chrono::hours;
6317 typename std::basic_istream<CharT, Traits>::sentry ok{is,
true};
6325 auto& f = std::use_facet<std::time_get<CharT>>(is.getloc());
6328 const CharT* command =
nullptr;
6329 auto modified = CharT{};
6332 CONSTDATA int not_a_year = numeric_limits<int>::min();
6334 CONSTDATA int not_a_century = not_a_year / 100;
6337 CONSTDATA int not_a_hour = numeric_limits<int>::min();
6339 CONSTDATA int not_a_minute = not_a_hour;
6340 CONSTDATA Duration not_a_second = Duration::min();
6345 CONSTDATA minutes not_a_offset = minutes::min();
6348 int y = not_a_2digit_year;
6349 int g = not_a_2digit_year;
6351 int C = not_a_century;
6352 int m = not_a_month;
6355 int wd = not_a_weekday;
6357 int I = not_a_hour_12_value;
6359 int M = not_a_minute;
6360 Duration s = not_a_second;
6361 int U = not_a_week_num;
6362 int V = not_a_week_num;
6363 int W = not_a_week_num;
6364 std::basic_string<CharT, Traits, Alloc> temp_abbrev;
6365 minutes temp_offset = not_a_offset;
6372 for (; *fmt != CharT{} && !is.fail(); ++fmt)
6382 int trial_wd = not_a_weekday;
6383 if (*fmt ==
'a' || *fmt ==
'A')
6385 if (modified == CharT{})
6388 ios::iostate err = ios::goodbit;
6389 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6392 trial_wd = tm.tm_wday;
6394 auto nm = detail::weekday_names();
6395 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6401 read(is, CharT{
'%'}, width, modified, *fmt);
6406 if (modified == CharT{})
6408 if (modified != CharT{
'E'})
6411 read(is, ru{trial_wd, 1, width == -1 ?
6412 1u :
static_cast<unsigned>(width)});
6417 if (!(1 <= trial_wd && trial_wd <= 7))
6419 trial_wd = not_a_weekday;
6420 is.setstate(ios::failbit);
6422 else if (trial_wd == 7)
6427 if (!(0 <= trial_wd && trial_wd <= 6))
6429 trial_wd = not_a_weekday;
6430 is.setstate(ios::failbit);
6436 else if (modified == CharT{
'O'})
6438 ios::iostate err = ios::goodbit;
6439 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6442 trial_wd = tm.tm_wday;
6446 read(is, CharT{
'%'}, width, modified, *fmt);
6448 if (trial_wd != not_a_weekday)
6462 if (modified == CharT{})
6464 int ttm = not_a_month;
6466 ios::iostate err = ios::goodbit;
6467 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6468 if ((err & ios::failbit) == 0)
6469 ttm = tm.tm_mon + 1;
6472 auto nm = detail::month_names();
6473 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6480 read(is, CharT{
'%'}, width, modified, *fmt);
6491 if (modified != CharT{
'O'})
6494 ios::iostate err = ios::goodbit;
6495 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6496 if ((err & ios::failbit) == 0)
6498 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
6503 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
6509 auto nm = detail::weekday_names();
6510 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6511 checked_set(wd,
static_cast<int>(i % 7), not_a_weekday, is);
6513 nm = detail::month_names();
6514 i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6515 checked_set(m,
static_cast<int>(i % 12 + 1), not_a_month, is);
6518 read(is, rs{td, 1, 2});
6522 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6526 read(is, ru{tH, 1, 2}, CharT{
':'}, ru{tM, 1, 2},
6527 CharT{
':'}, rld{S, 1, w});
6530 checked_set(s, round<Duration>(duration<long double>{S}),
6533 int tY = not_a_year;
6534 read(is, rs{tY, 1, 4u});
6539 read(is, CharT{
'%'}, width, modified, *fmt);
6550 if (modified != CharT{
'O'})
6553 ios::iostate err = ios::goodbit;
6554 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6555 if ((err & ios::failbit) == 0)
6557 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
6564 int ty = not_a_2digit_year;
6565 int tm = not_a_month;
6567 read(is, ru{tm, 1, 2}, CharT{
'/'}, ru{td, 1, 2}, CharT{
'/'},
6575 read(is, CharT{
'%'}, width, modified, *fmt);
6586 if (modified != CharT{
'O'})
6589 ios::iostate err = ios::goodbit;
6590 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6591 if ((err & ios::failbit) == 0)
6595 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
6602 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6603 int tH = not_a_hour;
6604 int tM = not_a_minute;
6606 read(is, ru{tH, 1, 2}, CharT{
':'}, ru{tM, 1, 2},
6607 CharT{
':'}, rld{S, 1, w});
6610 checked_set(s, round<Duration>(duration<long double>{S}),
6615 read(is, CharT{
'%'}, width, modified, *fmt);
6626 int tC = not_a_century;
6628 if (modified == CharT{})
6631 read(is, rs{tC, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6636 ios::iostate err = ios::goodbit;
6637 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6638 if ((err & ios::failbit) == 0)
6640 auto tY = tm.tm_year + 1900;
6641 tC = (tY >= 0 ? tY : tY-99) / 100;
6657 if (modified == CharT{})
6659 int tn = not_a_month;
6661 int ty = not_a_2digit_year;
6662 read(is, ru{tn, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6663 ru{td, 1, 2}, CharT{
'\0'}, CharT{
'/'}, CharT{
'\0'},
6670 read(is, CharT{
'%'}, width, modified, *fmt);
6681 if (modified == CharT{})
6683 int tY = not_a_year;
6684 int tn = not_a_month;
6686 read(is, rs{tY, 1, width == -1 ? 4u :
static_cast<unsigned>(width)},
6687 CharT{
'-'}, ru{tn, 1, 2}, CharT{
'-'}, ru{td, 1, 2});
6693 read(is, CharT{
'%'}, width, modified, *fmt);
6706 if (modified == CharT{})
6708 if (modified != CharT{
'E'})
6712 read(is, rs{td, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6716 else if (modified == CharT{
'O'})
6718 ios::iostate err = ios::goodbit;
6719 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6723 if ((err & ios::failbit) == 0)
6729 read(is, CharT{
'%'}, width, modified, *fmt);
6741 if (modified == CharT{})
6743 if (modified != CharT{
'E'})
6746 int tH = not_a_hour;
6747 read(is, ru{tH, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6751 else 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)
6761 read(is, CharT{
'%'}, width, modified, *fmt);
6772 if (modified == CharT{})
6774 int tI = not_a_hour_12_value;
6776 read(is, rs{tI, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6777 if (!(1 <= tI && tI <= 12))
6778 is.setstate(ios::failbit);
6782 read(is, CharT{
'%'}, width, modified, *fmt);
6793 if (modified == CharT{})
6796 read(is, ru{tj, 1, width == -1 ? 3u :
static_cast<unsigned>(width)});
6800 read(is, CharT{
'%'}, width, modified, *fmt);
6812 if (modified == CharT{})
6814 if (modified != CharT{
'E'})
6817 int tM = not_a_minute;
6818 read(is, ru{tM, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6822 else if (modified == CharT{
'O'})
6824 ios::iostate err = ios::goodbit;
6825 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6826 if ((err & ios::failbit) == 0)
6832 read(is, CharT{
'%'}, width, modified, *fmt);
6844 if (modified == CharT{})
6846 if (modified != CharT{
'E'})
6849 int tn = not_a_month;
6850 read(is, rs{tn, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
6854 else if (modified == CharT{
'O'})
6856 ios::iostate err = ios::goodbit;
6857 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6858 if ((err & ios::failbit) == 0)
6864 read(is, CharT{
'%'}, width, modified, *fmt);
6876 if (modified == CharT{})
6880 auto ic = is.peek();
6881 if (Traits::eq_int_type(ic, Traits::eof()))
6883 ios::iostate err = ios::eofbit;
6885 err |= ios::failbit;
6893 else if (*fmt ==
'n')
6894 is.setstate(ios::failbit);
6897 read(is, CharT{
'%'}, width, modified, *fmt);
6908 if (modified == CharT{})
6910 int tp = not_a_ampm;
6914 ios::iostate err = ios::goodbit;
6915 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6917 if (tm.tm_hour == 1)
6919 else if (tm.tm_hour == 13)
6924 auto nm = detail::ampm_names();
6925 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6931 read(is, CharT{
'%'}, width, modified, *fmt);
6943 if (modified == CharT{})
6946 ios::iostate err = ios::goodbit;
6947 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
6948 if ((err & ios::failbit) == 0)
6952 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
6959 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
6961 int tI = not_a_hour_12_value;
6962 int tM = not_a_minute;
6963 read(is, ru{tI, 1, 2}, CharT{
':'}, ru{tM, 1, 2},
6964 CharT{
':'}, rld{S, 1, w});
6967 checked_set(s, round<Duration>(duration<long double>{S}),
6970 auto nm = detail::ampm_names();
6971 auto i = detail::scan_keyword(is, nm.first, nm.second) - nm.first;
6972 checked_set(p,
static_cast<int>(i), not_a_ampm, is);
6976 read(is, CharT{
'%'}, width, modified, *fmt);
6987 if (modified == CharT{})
6989 int tH = not_a_hour;
6990 int tM = not_a_minute;
6991 read(is, ru{tH, 1, 2}, CharT{
'\0'}, CharT{
':'}, CharT{
'\0'},
6992 ru{tM, 1, 2}, CharT{
'\0'});
6997 read(is, CharT{
'%'}, width, modified, *fmt);
7009 if (modified == CharT{})
7011 if (modified != CharT{
'E'})
7015 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
7017 read(is, rld{S, 1, width == -1 ? w :
static_cast<unsigned>(width)});
7018 checked_set(s, round<Duration>(duration<long double>{S}),
7022 else if (modified == CharT{
'O'})
7024 ios::iostate err = ios::goodbit;
7025 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7026 if ((err & ios::failbit) == 0)
7027 checked_set(s, duration_cast<Duration>(seconds{tm.tm_sec}),
7033 read(is, CharT{
'%'}, width, modified, *fmt);
7044 if (modified == CharT{})
7047 CONSTDATA auto w = Duration::period::den == 1 ? 2 : 3 + dfs::width;
7048 int tH = not_a_hour;
7049 int tM = not_a_minute;
7051 read(is, ru{tH, 1, 2}, CharT{
':'}, ru{tM, 1, 2},
7052 CharT{
':'}, rld{S, 1, w});
7055 checked_set(s, round<Duration>(duration<long double>{S}),
7059 read(is, CharT{
'%'}, width, modified, *fmt);
7071 if (modified == CharT{})
7073 if (modified != CharT{
'O'})
7076 int tY = not_a_year;
7077 read(is, rs{tY, 1, width == -1 ? 4u :
static_cast<unsigned>(width)});
7081 else if (modified == CharT{
'E'})
7083 ios::iostate err = ios::goodbit;
7084 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7085 if ((err & ios::failbit) == 0)
7086 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
7091 read(is, CharT{
'%'}, width, modified, *fmt);
7103 if (modified == CharT{})
7106 int ty = not_a_2digit_year;
7107 read(is, ru{ty, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
7113 ios::iostate err = ios::goodbit;
7114 f.get(is,
nullptr, is, err, &tm, command, fmt+1);
7115 if ((err & ios::failbit) == 0)
7116 checked_set(Y, tm.tm_year + 1900, not_a_year, is);
7130 if (modified == CharT{})
7132 int tg = not_a_2digit_year;
7133 read(is, ru{tg, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
7137 read(is, CharT{
'%'}, width, modified, *fmt);
7148 if (modified == CharT{})
7150 int tG = not_a_year;
7151 read(is, rs{tG, 1, width == -1 ? 4u :
static_cast<unsigned>(width)});
7155 read(is, CharT{
'%'}, width, modified, *fmt);
7166 if (modified == CharT{})
7168 int tU = not_a_week_num;
7169 read(is, ru{tU, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
7173 read(is, CharT{
'%'}, width, modified, *fmt);
7184 if (modified == CharT{})
7186 int tV = not_a_week_num;
7187 read(is, ru{tV, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
7191 read(is, CharT{
'%'}, width, modified, *fmt);
7202 if (modified == CharT{})
7204 int tW = not_a_week_num;
7205 read(is, ru{tW, 1, width == -1 ? 2u :
static_cast<unsigned>(width)});
7209 read(is, CharT{
'%'}, width, modified, *fmt);
7221 if (modified == CharT{})
7227 read(is, CharT{
'%'}, width, modified, *fmt);
7239 if (modified == CharT{})
7242 read(is, CharT{
'%'}, width, modified, *fmt);
7254 minutes toff = not_a_offset;
7256 auto ic = is.peek();
7257 if (!Traits::eq_int_type(ic, Traits::eof()))
7259 auto c =
static_cast<char>(Traits::to_char_type(ic));
7263 if (modified == CharT{})
7265 read(is, rs{tH, 2, 2});
7271 if (!Traits::eq_int_type(ic, Traits::eof()))
7273 auto c =
static_cast<char>(Traits::to_char_type(ic));
7274 if (
'0' <= c && c <=
'9')
7276 read(is, ru{tM, 2, 2});
7278 toff += minutes{tM};
7285 read(is, rs{tH, 1, 2});
7291 if (!Traits::eq_int_type(ic, Traits::eof()))
7293 auto c =
static_cast<char>(Traits::to_char_type(ic));
7297 read(is, ru{tM, 2, 2});
7299 toff += minutes{tM};
7317 if (modified == CharT{})
7319 std::basic_string<CharT, Traits, Alloc> buf;
7320 while (is.rdstate() == std::ios::goodbit)
7322 auto i = is.rdbuf()->sgetc();
7323 if (Traits::eq_int_type(i, Traits::eof()))
7325 is.setstate(ios::eofbit);
7328 auto wc = Traits::to_char_type(i);
7329 auto c =
static_cast<char>(wc);
7331 if (!(CharT{1} < wc && wc < CharT{127}) || !(isalnum(c) ||
7332 c ==
'_' || c ==
'/' || c ==
'-' || c ==
'+'))
7335 is.rdbuf()->sbumpc();
7338 is.setstate(ios::failbit);
7342 read(is, CharT{
'%'}, width, modified, *fmt);
7353 if (width == -1 && modified == CharT{} &&
'0' <= *fmt && *fmt <=
'9')
7355 width =
static_cast<char>(*fmt) -
'0';
7356 while (
'0' <= fmt[1] && fmt[1] <=
'9')
7357 width = 10*width +
static_cast<char>(*++fmt) -
'0';
7361 if (modified == CharT{})
7362 read(is, CharT{
'%'}, width, *fmt);
7364 read(is, CharT{
'%'}, width, modified, *fmt);
7372 if (isspace(
static_cast<unsigned char>(*fmt)))
7385 if (is.rdstate() == ios::goodbit && command)
7387 if (modified == CharT{})
7388 read(is, CharT{
'%'}, width);
7390 read(is, CharT{
'%'}, width, modified);
7394 if (y != not_a_2digit_year)
7397 if (!(0 <= y && y <= 99))
7399 if (C == not_a_century)
7401 if (Y == not_a_year)
7410 C = (Y >= 0 ? Y : Y-100) / 100;
7417 tY = 100*(C+1) - (y == 0 ? 100 : y);
7418 if (Y != not_a_year && Y != tY)
7422 if (g != not_a_2digit_year)
7425 if (!(0 <= g && g <= 99))
7427 if (C == not_a_century)
7429 if (G == not_a_year)
7438 C = (G >= 0 ? G : G-100) / 100;
7445 tG = 100*(C+1) - (g == 0 ? 100 : g);
7446 if (G != not_a_year && G != tG)
7452 bool computed =
false;
7453 if (G != not_a_year && V != not_a_week_num && wd != not_a_weekday)
7458 if (Y == not_a_year)
7459 Y =
static_cast<int>(ymd_trial.
year());
7460 else if (
year{Y} != ymd_trial.
year())
7462 if (m == not_a_month)
7463 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7464 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7467 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7468 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7472 if (Y != not_a_year && U != not_a_week_num && wd != not_a_weekday)
7477 if (Y == not_a_year)
7478 Y =
static_cast<int>(ymd_trial.
year());
7479 else if (
year{Y} != ymd_trial.
year())
7481 if (m == not_a_month)
7482 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7483 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7486 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7487 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7491 if (Y != not_a_year && W != not_a_week_num && wd != not_a_weekday)
7496 if (Y == not_a_year)
7497 Y =
static_cast<int>(ymd_trial.
year());
7498 else if (
year{Y} != ymd_trial.
year())
7500 if (m == not_a_month)
7501 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
month()));
7502 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7505 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.
day()));
7506 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7510 if (j != not_a_doy && Y != not_a_year)
7514 m =
static_cast<int>(
static_cast<unsigned>(ymd_trial.month()));
7515 else if (
month(
static_cast<unsigned>(m)) != ymd_trial.
month())
7518 d =
static_cast<int>(
static_cast<unsigned>(ymd_trial.day()));
7519 else if (
day(
static_cast<unsigned>(d)) != ymd_trial.
day())
7523 auto ymd =
year{Y}/m/d;
7526 if (wd == not_a_weekday)
7532 if (G != not_a_year || V != not_a_week_num)
7541 if (V != not_a_week_num)
7545 if (G != not_a_year && G !=
static_cast<int>(G_trial))
7547 if (V != not_a_week_num)
7549 auto V_trial = duration_cast<weeks>(sd - start).count() + 1;
7554 if (U != not_a_week_num)
7557 auto U_trial = floor<weeks>(
sys_days(ymd) - start).count() + 1;
7561 if (W != not_a_week_num)
7564 auto W_trial = floor<weeks>(
sys_days(ymd) - start).count() + 1;
7571 if (I != not_a_hour_12_value)
7573 if (!(1 <= I && I <= 12))
7575 if (p != not_a_ampm)
7583 if (H == not_a_hour)
7591 if (H != not_a_hour)
7595 if (H != 0 && H != 12)
7598 else if (!(I == H || I == H+12))
7605 if (H != not_a_hour)
7610 if (M != not_a_minute)
7613 fds.tod.m_ = minutes{M};
7615 if (s != not_a_second)
7623 fds.tod.h_ += hours{
days{j}};
7625 if (wd != not_a_weekday)
7626 fds.wd =
weekday{
static_cast<unsigned>(wd)};
7627 if (abbrev !=
nullptr)
7628 *abbrev = std::move(temp_abbrev);
7629 if (offset !=
nullptr && temp_offset != not_a_offset)
7630 *offset = temp_offset;
7635 is.setstate(ios::failbit);
7639 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7640 std::basic_istream<CharT, Traits>&
7642 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7643 std::chrono::minutes* offset =
nullptr)
7645 using CT = std::chrono::seconds;
7648 if (!fds.ymd.year().ok())
7649 is.setstate(std::ios::failbit);
7655 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7656 std::basic_istream<CharT, Traits>&
7658 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7659 std::chrono::minutes* offset =
nullptr)
7661 using CT = std::chrono::seconds;
7664 if (!fds.ymd.month().ok())
7665 is.setstate(std::ios::failbit);
7667 m = fds.ymd.
month();
7671 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7672 std::basic_istream<CharT, Traits>&
7674 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7675 std::chrono::minutes* offset =
nullptr)
7677 using CT = std::chrono::seconds;
7680 if (!fds.ymd.day().ok())
7681 is.setstate(std::ios::failbit);
7687 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7688 std::basic_istream<CharT, Traits>&
7690 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7691 std::chrono::minutes* offset =
nullptr)
7693 using CT = std::chrono::seconds;
7697 is.setstate(std::ios::failbit);
7703 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7704 std::basic_istream<CharT, Traits>&
7706 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7707 std::chrono::minutes* offset =
nullptr)
7709 using CT = std::chrono::seconds;
7712 if (!fds.ymd.month().ok())
7713 is.setstate(std::ios::failbit);
7715 ym = fds.ymd.
year()/fds.ymd.month();
7719 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7720 std::basic_istream<CharT, Traits>&
7722 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7723 std::chrono::minutes* offset =
nullptr)
7725 using CT = std::chrono::seconds;
7728 if (!fds.ymd.month().ok() || !fds.ymd.day().ok())
7729 is.setstate(std::ios::failbit);
7731 md = fds.ymd.
month()/fds.ymd.day();
7735 template <
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7736 std::basic_istream<CharT, Traits>&
7738 year_month_day& ymd, std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7739 std::chrono::minutes* offset =
nullptr)
7741 using CT = std::chrono::seconds;
7745 is.setstate(std::ios::failbit);
7751 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7752 std::basic_istream<CharT, Traits>&
7755 std::chrono::minutes* offset =
nullptr)
7757 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
7758 std::chrono::minutes offset_local{};
7759 auto offptr = offset ? offset : &offset_local;
7763 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
7764 is.setstate(std::ios::failbit);
7766 tp = round<Duration>(
sys_days(fds.ymd) - *offptr + fds.tod.to_duration());
7770 template <
class Duration,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7771 std::basic_istream<CharT, Traits>&
7774 std::chrono::minutes* offset =
nullptr)
7776 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
7780 if (!fds.ymd.ok() || !fds.tod.in_conventional_range())
7781 is.setstate(std::ios::failbit);
7787 template <
class Rep,
class Period,
class CharT,
class Traits,
class Alloc = std::allocator<CharT>>
7788 std::basic_istream<CharT, Traits>&
7790 std::chrono::duration<Rep, Period>& d,
7791 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7792 std::chrono::minutes* offset =
nullptr)
7794 using Duration = std::chrono::duration<Rep, Period>;
7795 using CT =
typename std::common_type<Duration, std::chrono::seconds>::type;
7799 is.setstate(std::ios::failbit);
7801 d = std::chrono::duration_cast<Duration>(fds.tod.to_duration());
7805 template <
class Parsable,
class CharT,
class Traits = std::
char_traits<CharT>,
7806 class Alloc = std::allocator<CharT>>
7809 const std::basic_string<CharT, Traits, Alloc>
format_;
7816 std::basic_string<CharT, Traits, Alloc>* abbrev =
nullptr,
7817 std::chrono::minutes* offset =
nullptr)
7826 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7827 std::basic_istream<CharT, Traits>&
7834 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7837 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp)
7838 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7845 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7848 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7849 std::basic_string<CharT, Traits, Alloc>& abbrev)
7850 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7851 format.c_str(), tp, &abbrev),
7854 return {
format, tp, &abbrev};
7857 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7860 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7861 std::chrono::minutes& offset)
7862 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7864 std::declval<std::basic_string<CharT, Traits, Alloc>*>(),
7868 return {
format, tp,
nullptr, &offset};
7871 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7874 parse(
const std::basic_string<CharT, Traits, Alloc>&
format, Parsable& tp,
7875 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
7876 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
7877 format.c_str(), tp, &abbrev, &offset),
7880 return {
format, tp, &abbrev, &offset};
7885 template <
class Parsable,
class CharT>
7889 -> decltype(
from_stream(std::declval<std::basic_istream<CharT>&>(),
format, tp),
7895 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7898 parse(
const CharT*
format, Parsable& tp, std::basic_string<CharT, Traits, Alloc>& abbrev)
7899 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
format,
7903 return {
format, tp, &abbrev};
7906 template <
class Parsable,
class CharT>
7909 parse(
const CharT*
format, Parsable& tp, std::chrono::minutes& offset)
7911 tp, std::declval<std::basic_string<CharT>*>(), &offset),
7914 return {
format, tp,
nullptr, &offset};
7917 template <
class Parsable,
class CharT,
class Traits,
class Alloc>
7921 std::basic_string<CharT, Traits, Alloc>& abbrev, std::chrono::minutes& offset)
7922 -> decltype(
from_stream(std::declval<std::basic_istream<CharT, Traits>&>(),
format,
7923 tp, &abbrev, &offset),
7926 return {
format, tp, &abbrev, &offset};
7931 template <
class CharT,
class Traits,
class Rep,
class Period>
7933 std::basic_ostream<CharT, Traits>&
7935 const std::chrono::duration<Rep, Period>& d)
7937 return os << detail::make_string<CharT, Traits>::from(d.count()) +
7938 detail::get_units<CharT>(
typename Period::type{});
7944 # pragma warning(pop)
7948 # pragma GCC diagnostic pop