28#if FMT_HAS_INCLUDE("winapifamily.h")
29#include <winapifamily.h>
31#if defined(_WIN32) && (!defined(WINAPI_FAMILY) || \
32 (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
33#define FMT_USE_TZSET 1
35#define FMT_USE_TZSET 0
40#ifndef FMT_SAFE_DURATION_CAST
41#define FMT_SAFE_DURATION_CAST 1
43#if FMT_SAFE_DURATION_CAST
54 template <
typename To,
typename From, FMT_ENABLE_IF(!std::is_same<From, To>::value && std::numeric_limits<From>::is_
signed == std::numeric_limits<To>::is_
signed)>
58 using F = std::numeric_limits<From>;
59 using T = std::numeric_limits<To>;
60 static_assert(F::is_integer,
"From must be integral");
61 static_assert(T::is_integer,
"To must be integral");
64 if (detail::const_check(F::digits <= T::digits))
71 if (from < (T::min)() || from > (T::max)())
78 return static_cast<To
>(from);
85 template <
typename To,
typename From, FMT_ENABLE_IF(!std::is_same<From, To>::value && std::numeric_limits<From>::is_
signed != std::numeric_limits<To>::is_
signed)>
89 using F = std::numeric_limits<From>;
90 using T = std::numeric_limits<To>;
91 static_assert(F::is_integer,
"From must be integral");
92 static_assert(T::is_integer,
"To must be integral");
94 if (detail::const_check(F::is_signed && !T::is_signed))
97 if (fmt::detail::is_negative(from))
103 if (detail::const_check(F::digits > T::digits) &&
104 from >
static_cast<From
>(detail::max_value<To>()))
111 if (detail::const_check(!F::is_signed && T::is_signed &&
112 F::digits >= T::digits) &&
113 from >
static_cast<From
>(detail::max_value<To>()))
118 return static_cast<To
>(from);
121 template <
typename To,
typename From, FMT_ENABLE_IF(std::is_same<From, To>::value)>
142 template <
typename To,
typename From, FMT_ENABLE_IF(!std::is_same<From, To>::value)>
146 using T = std::numeric_limits<To>;
147 static_assert(std::is_floating_point<From>::value,
"From must be floating");
148 static_assert(std::is_floating_point<To>::value,
"To must be floating");
151 if (std::isfinite(from))
153 if (from >= T::lowest() && from <= (T::max)())
155 return static_cast<To
>(from);
163 return static_cast<To
>(from);
166 template <
typename To,
typename From, FMT_ENABLE_IF(std::is_same<From, To>::value)>
170 static_assert(std::is_floating_point<From>::value,
"From must be floating");
177 template <
typename To,
typename FromRep,
typename FromPeriod, FMT_ENABLE_IF(std::is_
integral<FromRep>::value), FMT_ENABLE_IF(std::is_
integral<
typename To::rep>::value)>
181 using From = std::chrono::duration<FromRep, FromPeriod>;
186 : std::ratio_divide<typename From::period, typename To::period>
190 static_assert(Factor::num > 0,
"num must be positive");
191 static_assert(Factor::den > 0,
"den must be positive");
197 using IntermediateRep =
198 typename std::common_type<
typename From::rep,
typename To::rep,
199 decltype(Factor::num)>
::type;
202 IntermediateRep
count =
203 lossless_integral_conversion<IntermediateRep>(from.count(), ec);
207 if (detail::const_check(Factor::num != 1))
209 const auto max1 = detail::max_value<IntermediateRep>() / Factor::num;
216 (std::numeric_limits<IntermediateRep>::min)() / Factor::num;
217 if (!std::is_unsigned<IntermediateRep>::value &&
count < min1)
222 count *= Factor::num;
225 if (detail::const_check(Factor::den != 1))
226 count /= Factor::den;
227 auto tocount = lossless_integral_conversion<typename To::rep>(
count, ec);
228 return ec ? To() : To(tocount);
234 template <
typename To,
typename FromRep,
typename FromPeriod, FMT_ENABLE_IF(std::is_
floating_po
int<FromRep>::value), FMT_ENABLE_IF(std::is_
floating_po
int<
typename To::rep>::value)>
238 using From = std::chrono::duration<FromRep, FromPeriod>;
240 if (std::isnan(from.count()))
243 return To{std::numeric_limits<typename To::rep>::quiet_NaN()};
249 if (std::isinf(from.count()))
251 return To{from.count()};
257 : std::ratio_divide<typename From::period, typename To::period>
261 static_assert(Factor::num > 0,
"num must be positive");
262 static_assert(Factor::den > 0,
"den must be positive");
268 using IntermediateRep =
269 typename std::common_type<
typename From::rep,
typename To::rep,
270 decltype(Factor::num)>
::type;
274 IntermediateRep
count =
275 safe_float_conversion<IntermediateRep>(from.count(), ec);
282 if (detail::const_check(Factor::num != 1))
284 constexpr auto max1 = detail::max_value<IntermediateRep>() /
285 static_cast<IntermediateRep
>(Factor::num);
291 constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() /
292 static_cast<IntermediateRep
>(Factor::num);
298 count *=
static_cast<IntermediateRep
>(Factor::num);
302 if (detail::const_check(Factor::den != 1))
304 using common_t =
typename std::common_type<IntermediateRep, intmax_t>::type;
305 count /=
static_cast<common_t
>(Factor::den);
309 using ToRep =
typename To::rep;
311 const ToRep tocount = safe_float_conversion<ToRep>(
count, ec);
327 template <
typename T =
void>
350 static const auto& locale = std::locale::classic();
354 template <
typename CodeUnit>
361 template <
typename CodeUnit>
364 template <
typename CodeUnit>
368#pragma clang diagnostic push
369#pragma clang diagnostic ignored "-Wdeprecated"
370 auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);
371#pragma clang diagnostic pop
373 auto& f = std::use_facet<std::codecvt<CodeUnit, char, std::mbstate_t>>(loc);
375 auto mb = std::mbstate_t();
376 const char* from_next =
nullptr;
377 auto result = f.in(mb, in_buf.
begin(), in_buf.
end(), from_next,
378 std::begin(
out.buf), std::end(
out.buf),
out.end);
379 if (result != std::codecvt_base::ok)
383 template <
typename OutputIt>
391#if FMT_MSC_VERSION != 0 || \
392 (defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI))
395 using code_unit = wchar_t;
397 using code_unit = char32_t;
405 for (code_unit*
p = unit.buf;
p != unit.end; ++
p)
407 uint32_t c =
static_cast<uint32_t
>(*p);
408 if (
sizeof(code_unit) == 2 && c >= 0xd800 && c <= 0xdfff)
412 if (
p == unit.end || (c & 0xfc00) != 0xd800 ||
413 (*
p & 0xfc00) != 0xdc00)
417 c = (c << 10) + static_cast<uint32_t>(*
p) - 0x35fdc00;
421 buf.push_back(
static_cast<char>(c));
425 buf.push_back(
static_cast<char>(0xc0 | (c >> 6)));
426 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
428 else if ((c >= 0x800 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xffff))
430 buf.push_back(
static_cast<char>(0xe0 | (c >> 12)));
431 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
432 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
434 else if (c >= 0x10000 && c <= 0x10ffff)
436 buf.push_back(
static_cast<char>(0xf0 | (c >> 18)));
437 buf.push_back(
static_cast<char>(0x80 | ((c & 0x3ffff) >> 12)));
438 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
439 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
446 return copy_str<char>(buf.data(), buf.data() + buf.size(),
out);
448 return copy_str<char>(
in.data(),
in.data() +
in.size(),
out);
451 template <
typename Char,
typename OutputIt, FMT_ENABLE_IF(!std::is_same<Char,
char>::value)>
457 return copy_str<Char>(unit.
buf, unit.
end,
out);
460 template <
typename Char,
typename OutputIt, FMT_ENABLE_IF(std::is_same<Char,
char>::value)>
467 template <
typename Char>
468 inline void do_write(buffer<Char>& buf,
const std::tm&
time,
const std::locale& loc,
char format,
char modifier)
471 auto&& os = std::basic_ostream<Char>(&format_buf);
473 using iterator = std::ostreambuf_iterator<Char>;
474 const auto& facet = std::use_facet<std::time_put<Char, iterator>>(loc);
475 auto end = facet.put(os, os, Char(
' '), &
time,
format, modifier);
480 template <
typename Char,
typename OutputIt, FMT_ENABLE_IF(!std::is_same<Char,
char>::value)>
481 auto write(OutputIt
out,
const std::tm&
time,
const std::locale& loc,
char format,
char modifier = 0) -> OutputIt
483 auto&& buf = get_buffer<Char>(
out);
484 do_write<Char>(buf,
time, loc,
format, modifier);
488 template <
typename Char,
typename OutputIt, FMT_ENABLE_IF(std::is_same<Char,
char>::value)>
489 auto write(OutputIt
out,
const std::tm&
time,
const std::locale& loc,
char format,
char modifier = 0) -> OutputIt
492 do_write<char>(buf,
time, loc,
format, modifier);
512 dispatcher(std::time_t t)
519 using namespace fmt::detail;
520 return handle(localtime_r(&time_, &tm_));
523 bool handle(std::tm* tm)
525 return tm !=
nullptr;
530 using namespace fmt::detail;
531 return fallback(localtime_s(&tm_, &time_));
534 bool fallback(
int res)
542 using namespace fmt::detail;
543 std::tm* tm = std::localtime(&time_);
546 return tm !=
nullptr;
558 std::chrono::time_point<std::chrono::system_clock> time_point)
560 return localtime(std::chrono::system_clock::to_time_t(time_point));
575 dispatcher(std::time_t t)
582 using namespace fmt::detail;
583 return handle(gmtime_r(&time_, &tm_));
586 bool handle(std::tm* tm)
588 return tm !=
nullptr;
593 using namespace fmt::detail;
594 return fallback(gmtime_s(&tm_, &time_));
597 bool fallback(
int res)
605 std::tm* tm = std::gmtime(&time_);
608 return tm !=
nullptr;
620 std::chrono::time_point<std::chrono::system_clock> time_point)
622 return gmtime(std::chrono::system_clock::to_time_t(time_point));
632 unsigned long long digits =
633 a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
643 digits += (((
digits * 205) >> 11) & 0x000f00000f00000f) * 6;
646 ((
digits & 0x000f00000f00000f) << 8);
647 auto usep =
static_cast<unsigned long long>(sep);
649 digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
651 constexpr const size_t len = 8;
655 std::memcpy(tmp, &
digits, len);
656 std::reverse_copy(tmp, tmp + len, buf);
660 std::memcpy(buf, &
digits, len);
664template <
typename Period>
667 if (std::is_same<Period, std::atto>::value)
669 if (std::is_same<Period, std::femto>::value)
671 if (std::is_same<Period, std::pico>::value)
673 if (std::is_same<Period, std::nano>::value)
675 if (std::is_same<Period, std::micro>::value)
677 if (std::is_same<Period, std::milli>::value)
679 if (std::is_same<Period, std::centi>::value)
681 if (std::is_same<Period, std::deci>::value)
683 if (std::is_same<Period, std::ratio<1>>
::value)
685 if (std::is_same<Period, std::deca>::value)
687 if (std::is_same<Period, std::hecto>::value)
689 if (std::is_same<Period, std::kilo>::value)
691 if (std::is_same<Period, std::mega>::value)
693 if (std::is_same<Period, std::giga>::value)
695 if (std::is_same<Period, std::tera>::value)
697 if (std::is_same<Period, std::peta>::value)
699 if (std::is_same<Period, std::exa>::value)
701 if (std::is_same<Period, std::ratio<60>>
::value)
703 if (std::is_same<Period, std::ratio<3600>>
::value)
716template <
typename Char,
typename Handler>
733 handler.on_text(begin,
ptr);
741 handler.on_text(
ptr - 1,
ptr);
744 const Char newline[] = {
'\n'};
745 handler.on_text(newline, newline + 1);
749 const Char tab[] = {
'\t'};
750 handler.on_text(tab, tab + 1);
764 handler.on_iso_week_based_year();
767 handler.on_iso_week_based_short_year();
771 handler.on_abbr_weekday();
774 handler.on_full_weekday();
785 handler.on_abbr_month();
788 handler.on_full_month();
804 handler.on_day_of_year();
836 handler.on_us_date();
839 handler.on_iso_date();
842 handler.on_12_hour_time();
845 handler.on_24_hour_time();
848 handler.on_iso_time();
854 handler.on_duration_value();
857 handler.on_duration_unit();
860 handler.on_utc_offset();
863 handler.on_tz_name();
876 handler.on_offset_year();
950 handler.on_text(begin,
ptr);
954template <
typename Derived>
1114 template <
typename Char>
1224 static constexpr const char* full_name_list[] = {
1225 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
1226 "Thursday",
"Friday",
"Saturday"};
1227 return wday >= 0 && wday <= 6 ? full_name_list[wday] :
"?";
1231 static constexpr const char* short_name_list[] = {
"Sun",
"Mon",
"Tue",
"Wed",
1232 "Thu",
"Fri",
"Sat"};
1233 return wday >= 0 && wday <= 6 ? short_name_list[wday] :
"???";
1238 static constexpr const char* full_name_list[] = {
1239 "January",
"February",
"March",
"April",
"May",
"June",
1240 "July",
"August",
"September",
"October",
"November",
"December"};
1241 return mon >= 0 && mon <= 11 ? full_name_list[mon] :
"?";
1245 static constexpr const char* short_name_list[] = {
1259 return mon >= 0 && mon <= 11 ? short_name_list[mon] :
"???";
1262template <
typename T,
typename =
void>
1266template <
typename T>
1272template <
typename T,
typename =
void>
1276template <
typename T>
1283inline void tzset_once()
1285 static bool init = []() ->
bool {
1293template <
typename OutputIt,
typename Char>
1331 return 1900ll +
tm_.tm_year;
1347 const auto z = h < 12 ? h : h - 12;
1348 return z == 0 ? 12 : z;
1357 auto l = year % 100;
1360 return static_cast<int>(l);
1367 const auto prev_year = curr_year - 1;
1369 (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
1372 (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
1374 return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);
1425 if (width > num_digits)
1426 out_ = std::fill_n(
out_, width - num_digits,
'0');
1427 out_ = format_decimal<Char>(
out_, n, num_digits).end;
1431 if (year >= 0 && year < 10000)
1433 write2(
static_cast<int>(year / 100));
1434 write2(
static_cast<int>(year % 100));
1457 template <
typename T, FMT_ENABLE_IF(has_member_data_tm_gmtoff<T>::value)>
1462 template <
typename T, FMT_ENABLE_IF(!has_member_data_tm_gmtoff<T>::value)>
1465#if defined(_WIN32) && defined(_UCRT)
1474 _get_dstbias(&dstbias);
1484 template <
typename T, FMT_ENABLE_IF(has_member_data_tm_zone<T>::value)>
1492 template <
typename T, FMT_ENABLE_IF(!has_member_data_tm_zone<T>::value)>
1519 out_ = copy_str<Char>(begin, end,
out_);
1609 out_ = copy_str<Char>(std::begin(buf), std::end(buf),
out_);
1616 if (year >= 0 && year < 10000)
1629 out_ = copy_str<Char>(std::begin(buf) +
offset, std::end(buf),
out_);
1665 auto upper = year / 100;
1666 if (year >= -99 && year < 0)
1672 else if (upper >= 0 && upper < 100)
1674 write2(
static_cast<int>(upper));
1747 const char* d2 =
digits2(mday);
1748 *
out_++ = mday < 10 ?
' ' : d2[0];
1789 out_ = copy_str<Char>(std::begin(buf), std::end(buf),
out_);
1809 out_ = copy_str<Char>(std::begin(buf), std::end(buf),
out_);
1841 template <
typename Char>
1877template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1884template <
typename T,
typename Int, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1891 return static_cast<Int
>(
value);
1893template <
typename T,
typename Int, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
1896 if (value < 0 || value >
static_cast<T
>(upper))
1898 return static_cast<Int
>(
value);
1901template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1904 return x %
static_cast<T
>(y);
1906template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
1907inline T
mod(T x,
int y)
1909 return std::fmod(x,
static_cast<T
>(y));
1914template <typename T, bool INTEGRAL = std::is_integral<T>::value>
1920template <
typename T>
1923 using type =
typename std::make_unsigned<T>::type;
1926#if FMT_SAFE_DURATION_CAST
1928template <
typename To,
typename FromRep,
typename FromPeriod>
1932 To to = safe_duration_cast::safe_duration_cast<To>(from, ec);
1939template <
typename Rep,
typename Period, FMT_ENABLE_IF(std::is_
integral<Rep>::value)>
1941 std::chrono::duration<Rep, Period> d)
1945#if FMT_SAFE_DURATION_CAST
1946 using CommonSecondsType =
1947 typename std::common_type<
decltype(d), std::chrono::seconds>
::type;
1948 const auto d_as_common = fmt_safe_duration_cast<CommonSecondsType>(d);
1949 const auto d_as_whole_seconds =
1950 fmt_safe_duration_cast<std::chrono::seconds>(d_as_common);
1952 const auto diff = d_as_common - d_as_whole_seconds;
1954 fmt_safe_duration_cast<std::chrono::duration<Rep, std::milli>>(diff);
1957 auto s = std::chrono::duration_cast<std::chrono::seconds>(d);
1958 return std::chrono::duration_cast<std::chrono::milliseconds>(d -
s);
1965template <long long Num, long long Den, int N = 0, bool Enabled = (N < 19) && (Num <= max_value<long long>() / 10)>
1974template <
long long Num,
long long Den,
int N>
1977 static constexpr int value = (Num % Den == 0) ? N : 6;
1980constexpr long long pow10(std::uint32_t n)
1982 return n == 0 ? 1 : 10 *
pow10(n - 1);
1985template <
class Rep,
class Period, FMT_ENABLE_IF(std::numeric_limits<Rep>::is_
signed)>
1986constexpr std::chrono::duration<Rep, Period>
abs(
1987 std::chrono::duration<Rep, Period> d)
1995 return d.count() >= d.zero().count() ? d : -d;
1998template <
class Rep,
class Period, FMT_ENABLE_IF(!std::numeric_limits<Rep>::is_
signed)>
1999constexpr std::chrono::duration<Rep, Period>
abs(
2000 std::chrono::duration<Rep, Period> d)
2005template <
typename Char,
typename Rep,
typename OutputIt, FMT_ENABLE_IF(std::is_
integral<Rep>::value)>
2008 return write<Char>(
out, val);
2011template <
typename Char,
typename Rep,
typename OutputIt, FMT_ENABLE_IF(std::is_
floating_po
int<Rep>::value)>
2015 specs.precision = precision;
2018 return write<Char>(
out, val, specs);
2021template <
typename Char,
typename OutputIt>
2027template <
typename OutputIt>
2033 return std::copy(
u.c_str(),
u.c_str() +
u.size(),
out);
2036template <
typename Char,
typename Period,
typename OutputIt>
2039 if (
const char* unit = get_units<Period>())
2042 out = write<Char>(
out, Period::num);
2046 out = write<Char>(
out, Period::den);
2066 ::new (&
locale_) std::locale(loc.template get<std::locale>());
2073 operator const std::locale&()
const
2079template <
typename FormatContext,
typename OutputIt,
typename Rep,
typename Period>
2114#if FMT_SAFE_DURATION_CAST
2116 auto tmpval = std::chrono::duration<rep, Period>(
val);
2117 s = fmt_safe_duration_cast<seconds>(tmpval);
2119 s = std::chrono::duration_cast<seconds>(
2120 std::chrono::duration<rep, Period>(
val));
2150 return static_cast<Rep
>(
mod((
s.count() / 3600), 24));
2155 Rep
hour =
static_cast<Rep
>(
mod((
s.count() / 3600), 12));
2161 return static_cast<Rep
>(
mod((
s.count() / 60), 60));
2165 return static_cast<Rep
>(
mod(
s.count(), 60));
2170 auto time = std::tm();
2193 int num_digits = detail::count_digits(n);
2194 if (width > num_digits)
2195 out = std::fill_n(
out, width - num_digits,
'0');
2196 out = format_decimal<char_type>(
out, n, num_digits).end;
2199 template <
typename Duration>
2202 FMT_ASSERT(!std::is_floating_point<typename Duration::rep>::value,
"");
2203 constexpr auto num_fractional_digits =
2205 Duration::period::den>
::value;
2207 using subsecond_precision = std::chrono::duration<
2208 typename std::common_type<
typename Duration::rep,
2209 std::chrono::seconds::rep>
::type,
2210 std::ratio<1, detail::pow10(num_fractional_digits)>>;
2211 if (std::ratio_less<
typename subsecond_precision::period,
2212 std::chrono::seconds::period>
::value)
2216 detail::abs(d) - std::chrono::duration_cast<std::chrono::seconds>(d);
2218 std::chrono::treat_as_floating_point<
2219 typename subsecond_precision::rep>
::value
2220 ? fractional.count()
2221 : std::chrono::duration_cast<subsecond_precision>(fractional)
2225 int num_digits = detail::count_digits(n);
2226 if (num_fractional_digits > num_digits)
2227 out = std::fill_n(
out, num_fractional_digits - num_digits,
'0');
2228 out = format_decimal<char_type>(
out, n, num_digits).end;
2234 std::copy_n(
"nan", 3,
out);
2238 std::copy_n(
"inf", 3,
out);
2242 std::copy_n(
"-inf", 4,
out);
2245 template <
typename Callback,
typename... Args>
2258 std::copy(begin, end,
out);
2384 if (std::is_floating_point<rep>::value)
2386 constexpr auto num_fractional_digits =
2390 std::fmod(
val *
static_cast<rep>(Period::num) /
2391 static_cast<rep>(Period::den),
2392 static_cast<rep>(60)),
2393 num_fractional_digits);
2396 if (buf.size() < 2 || buf[1] ==
'.')
2398 out = std::copy(buf.begin(), buf.end(),
out);
2459 out = format_duration_unit<char_type, Period>(
out);
2465#if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
2466using weekday = std::chrono::weekday;
2477 :
value(
static_cast<unsigned char>(wd != 7 ? wd : 0))
2492template <
typename Char>
2496 bool localized =
false;
2500 ->
decltype(ctx.begin())
2502 auto begin = ctx.begin(), end = ctx.end();
2503 if (begin != end && *begin ==
'L')
2511 template <
typename FormatContext>
2514 auto time = std::tm();
2515 time.tm_wday =
static_cast<int>(wd.c_encoding());
2516 detail::get_locale loc(localized, ctx.locale());
2517 auto w = detail::tm_writer<
decltype(ctx.out()), Char>(loc, ctx.out(),
time);
2518 w.on_abbr_weekday();
2523template <
typename Rep,
typename Period,
typename Char>
2532 bool localized =
false;
2542 template <
typename Id>
2566 f.specs.fill =
fill;
2570 f.specs.align =
align;
2574 f.specs.width = width;
2578 f.precision = _precision;
2584 template <
typename Id>
2587 f.width_ref = make_arg_ref(arg_id);
2590 template <
typename Id>
2593 f.precision_ref = make_arg_ref(arg_id);
2606 auto begin = ctx.
begin(), end = ctx.
end();
2607 if (begin == end || *begin ==
'}')
2608 return {begin, begin};
2609 spec_handler handler{*
this, ctx, format_str};
2610 begin = detail::parse_align(begin, end, handler);
2612 return {begin, begin};
2613 begin = detail::parse_width(begin, end, handler);
2615 return {begin, begin};
2618 if (std::is_floating_point<Rep>::value)
2619 begin = detail::parse_precision(begin, end, handler);
2621 handler.on_error(
"precision not allowed for this argument type");
2623 if (begin != end && *begin ==
'L')
2628 end = detail::parse_chrono_format(begin, end,
2629 detail::chrono_format_checker());
2630 return {begin, end};
2635 ->
decltype(ctx.begin())
2637 auto range = do_parse(ctx);
2639 &*range.begin, detail::to_unsigned(range.end - range.begin));
2643 template <
typename FormatContext>
2645 ->
decltype(ctx.out())
2647 auto specs_copy = specs;
2648 auto precision_copy = precision;
2649 auto begin = format_str.
begin(), end = format_str.
end();
2653 auto out = std::back_inserter(buf);
2654 detail::handle_dynamic_spec<detail::width_checker>(specs_copy.width,
2656 detail::handle_dynamic_spec<detail::precision_checker>(precision_copy,
2657 precision_ref, ctx);
2658 if (begin == end || *begin ==
'}')
2660 out = detail::format_duration_value<Char>(
out, d.count(), precision_copy);
2661 detail::format_duration_unit<Char, Period>(
out);
2665 detail::chrono_formatter<FormatContext,
decltype(
out), Rep, Period> f(
2667 f.precision = precision_copy;
2668 f.localized = localized;
2669 detail::parse_chrono_format(begin, end, f);
2676template <
typename Char,
typename Duration>
2677struct formatter<
std::chrono::time_point<std::chrono::system_clock, Duration>,
2684 this->do_parse(default_specs.
begin(), default_specs.
end());
2687 template <
typename FormatContext>
2688 auto format(std::chrono::time_point<std::chrono::system_clock> val,
2689 FormatContext& ctx)
const ->
decltype(ctx.out())
2695template <
typename Char>
2709 template <
typename It>
2712 if (begin != end && *begin ==
':')
2714 end = detail::parse_chrono_format(begin, end, detail::tm_format_checker());
2717 specs = {begin, detail::to_unsigned(end - begin)};
2723 ->
decltype(ctx.begin())
2725 auto end = this->do_parse(ctx.begin(), ctx.end());
2727 if (specs.
size() == 2 && specs[0] == Char(
'%'))
2729 if (specs[1] == Char(
'F'))
2730 spec_ = spec::year_month_day;
2731 else if (specs[1] == Char(
'T'))
2732 spec_ = spec::hh_mm_ss;
2737 template <
typename FormatContext>
2738 auto format(
const std::tm& tm, FormatContext& ctx)
const
2739 ->
decltype(ctx.out())
2741 const auto loc_ref = ctx.locale();
2742 detail::get_locale loc(
static_cast<bool>(loc_ref), loc_ref);
2743 auto w = detail::tm_writer<
decltype(ctx.out()), Char>(loc, ctx.out(), tm);
2744 if (spec_ == spec::year_month_day)
2746 else if (spec_ == spec::hh_mm_ss)
2749 detail::parse_chrono_format(specs.
begin(), specs.
end(), w);
constexpr long long pow10(std::uint32_t n)
Definition chrono.h:1980
To fmt_safe_duration_cast(std::chrono::duration< FromRep, FromPeriod > from)
Definition chrono.h:1929
#define FMT_NOMACRO
Definition chrono.h:323
const char * tm_mon_full_name(int mon)
Definition chrono.h:1236
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition chrono.h:1986
FMT_CONSTEXPR const Char * parse_chrono_format(const Char *begin, const Char *end, Handler &&handler)
Definition chrono.h:717
numeric_system
Definition chrono.h:709
OutputIt copy_unit(string_view unit, OutputIt out, Char)
Definition chrono.h:2022
OutputIt format_duration_value(OutputIt out, Rep val, int)
Definition chrono.h:2006
FMT_MODULE_EXPORT_BEGIN std::tm localtime(std::time_t time)
Definition chrono.h:505
std::chrono::duration< Rep, std::milli > get_milliseconds(std::chrono::duration< Rep, Period > d)
Definition chrono.h:1940
OutputIt format_duration_unit(OutputIt out)
Definition chrono.h:2037
const char * tm_wday_full_name(int wday)
Definition chrono.h:1222
std::tm gmtime(std::time_t time)
Definition chrono.h:568
bool isfinite(T)
Definition chrono.h:1878
const char * tm_wday_short_name(int wday)
Definition chrono.h:1229
const char * tm_mon_short_name(int mon)
Definition chrono.h:1243
FMT_CONSTEXPR const char * get_units()
Definition chrono.h:665
T mod(T x, int y)
Definition chrono.h:1902
Int to_nonnegative_int(T value, Int upper)
Definition chrono.h:1885
FMT_BEGIN_DETAIL_NAMESPACE void write_digit2_separated(char *buf, unsigned a, unsigned b, unsigned c, char sep)
Definition chrono.h:630
FMT_CONSTEXPR void check_arg_id(int id)
Definition core.h:830
constexpr auto end() const noexcept -> iterator
Definition core.h:799
typename basic_string_view< Char >::iterator iterator
Definition core.h:779
FMT_CONSTEXPR auto next_arg_id() -> int
Definition core.h:814
constexpr auto begin() const noexcept -> iterator
Definition core.h:791
constexpr auto end() const noexcept -> iterator
Definition core.h:550
constexpr auto size() const noexcept -> size_t
Definition core.h:541
constexpr auto begin() const noexcept -> iterator
Definition core.h:546
get_locale(bool localized, locale_ref loc)
Definition chrono.h:2062
std::locale locale_
Definition chrono.h:2057
bool has_locale_
Definition chrono.h:2059
~get_locale()
Definition chrono.h:2068
auto split_year_lower(long long year) const noexcept -> int
Definition chrono.h:1355
auto tm_mday() const noexcept -> int
Definition chrono.h:1319
void on_am_pm()
Definition chrono.h:1812
void on_duration_value()
Definition chrono.h:1826
void on_datetime(numeric_system ns)
Definition chrono.h:1570
void write_utc_offset(long offset)
Definition chrono.h:1442
void on_abbr_weekday()
Definition chrono.h:1522
void on_dec1_weekday(numeric_system ns)
Definition chrono.h:1542
tm_writer(const std::locale &loc, OutputIt out, const std::tm &tm)
Definition chrono.h:1504
void format_tz_name_impl(const T &)
Definition chrono.h:1493
void on_minute(numeric_system ns)
Definition chrono.h:1769
void write1(int value)
Definition chrono.h:1402
void format_utc_offset_impl(const T &tm)
Definition chrono.h:1458
void on_day_of_month_space(numeric_system ns)
Definition chrono.h:1742
void on_tz_name()
Definition chrono.h:1636
void on_year(numeric_system ns)
Definition chrono.h:1641
FMT_CONSTEXPR void on_text(const Char *begin, const Char *end)
Definition chrono.h:1517
auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int
Definition chrono.h:1376
auto tm_hour12() const noexcept -> int
Definition chrono.h:1344
void format_tz_name_impl(const T &tm)
Definition chrono.h:1485
void on_duration_unit()
Definition chrono.h:1829
void on_iso_time()
Definition chrono.h:1804
void on_dec_month(numeric_system ns)
Definition chrono.h:1687
void on_iso_week_based_year()
Definition chrono.h:1721
auto tm_iso_week_of_year() const noexcept -> int
Definition chrono.h:1391
OutputIt out_
Definition chrono.h:1301
auto tm_wday() const noexcept -> int
Definition chrono.h:1333
void on_loc_time(numeric_system ns)
Definition chrono.h:1596
void on_offset_year()
Definition chrono.h:1653
void on_second(numeric_system ns)
Definition chrono.h:1775
OutputIt out() const
Definition chrono.h:1512
void on_iso_week_based_short_year()
Definition chrono.h:1725
void on_dec1_week_of_year(numeric_system ns)
Definition chrono.h:1700
void on_abbr_month()
Definition chrono.h:1555
void on_dec0_weekday(numeric_system ns)
Definition chrono.h:1536
void on_24_hour(numeric_system ns)
Definition chrono.h:1757
void on_iso_date()
Definition chrono.h:1611
void on_day_of_year()
Definition chrono.h:1730
void on_iso_week_of_year(numeric_system ns)
Definition chrono.h:1714
auto tm_year() const noexcept -> long long
Definition chrono.h:1329
auto tm_min() const noexcept -> int
Definition chrono.h:1309
auto tm_yday() const noexcept -> int
Definition chrono.h:1338
auto iso_year_weeks(long long curr_year) const noexcept -> int
Definition chrono.h:1365
void on_24_hour_time()
Definition chrono.h:1798
void on_full_weekday()
Definition chrono.h:1529
void on_us_date()
Definition chrono.h:1603
const std::tm & tm_
Definition chrono.h:1302
auto tm_sec() const noexcept -> int
Definition chrono.h:1304
const std::locale & loc_
Definition chrono.h:1299
void write_year(long long year)
Definition chrono.h:1429
void on_full_month()
Definition chrono.h:1562
void on_12_hour_time()
Definition chrono.h:1782
void on_short_year(numeric_system ns)
Definition chrono.h:1647
void write_year_extended(long long year)
Definition chrono.h:1413
void on_dec0_week_of_year(numeric_system ns)
Definition chrono.h:1694
void on_loc_date(numeric_system ns)
Definition chrono.h:1589
void on_utc_offset()
Definition chrono.h:1632
auto tm_iso_week_year() const noexcept -> long long
Definition chrono.h:1381
void write2(int value)
Definition chrono.h:1406
static constexpr int days_per_week
Definition chrono.h:1297
auto tm_mon() const noexcept -> int
Definition chrono.h:1324
const bool is_classic_
Definition chrono.h:1300
void on_century(numeric_system ns)
Definition chrono.h:1660
void format_localized(char format, char modifier=0)
Definition chrono.h:1498
void on_12_hour(numeric_system ns)
Definition chrono.h:1763
void on_day_of_month(numeric_system ns)
Definition chrono.h:1736
auto tm_hour() const noexcept -> int
Definition chrono.h:1314
unsigned char value
Definition chrono.h:2472
constexpr weekday(unsigned wd) noexcept
Definition chrono.h:2476
constexpr unsigned c_encoding() const noexcept
Definition chrono.h:2480
auto format_to(OutputIt out, const text_style &ts, const S &format_str, Args &&... args) -> typename std::enable_if< enable, OutputIt >::type
Definition color.h:677
std::basic_string< Char > format(const text_style &ts, const S &format_str, const Args &... args)
Definition color.h:646
constexpr FMT_INLINE auto const_check(T value) -> T
Definition core.h:390
#define FMT_ASSERT(condition, message)
Definition core.h:403
basic_string_view< char > string_view
Definition core.h:604
align::type align_t
Definition core.h:2687
#define FMT_END_DETAIL_NAMESPACE
Definition core.h:231
#define FMT_MODULE_EXPORT_BEGIN
Definition core.h:226
constexpr auto count() -> size_t
Definition core.h:1538
#define FMT_CONSTEXPR
Definition core.h:106
type
Definition core.h:681
#define FMT_BEGIN_NAMESPACE
Definition core.h:214
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition core.h:228
FMT_BEGIN_DETAIL_NAMESPACE FMT_CONSTEXPR void ignore_unused(const T &...)
Definition core.h:373
void void_t
Definition core.h:2201
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition core.h:455
#define FMT_NORETURN
Definition core.h:163
typename std::conditional< B, T, F >::type conditional_t
Definition core.h:304
auto runtime(string_view s) -> basic_runtime< char >
Definition core.h:4070
#define FMT_END_NAMESPACE
Definition core.h:219
#define FMT_MODULE_EXPORT_END
Definition core.h:227
#define offset(member)
Definition css_properties.cpp:5
#define out
Definition encodings.cpp:5
#define in
Definition internal.h:15
null gmtime_s(...)
Definition chrono.h:343
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition chrono.h:481
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale &loc) -> OutputIt
Definition chrono.h:384
void do_write(buffer< Char > &buf, const std::tm &time, const std::locale &loc, char format, char modifier)
Definition chrono.h:468
null gmtime_r(...)
Definition chrono.h:339
const std::locale & get_classic_locale()
Definition chrono.h:348
null localtime_s(...)
Definition chrono.h:335
auto write_tm_str(OutputIt out, string_view sv, const std::locale &loc) -> OutputIt
Definition chrono.h:452
void write_codecvt(codecvt_result< CodeUnit > &out, string_view in_buf, const std::locale &loc)
Definition chrono.h:365
FMT_CONSTEXPR To safe_float_conversion(const From from, int &ec)
Definition chrono.h:143
FMT_CONSTEXPR To lossless_integral_conversion(const From from, int &ec)
Definition chrono.h:55
static constexpr const size_t max_size
Definition chrono.h:357
CodeUnit * end
Definition chrono.h:359
CodeUnit buf[max_size]
Definition chrono.h:358
typename std::make_unsigned< T >::type type
Definition chrono.h:1923
T type
Definition chrono.h:1917
FMT_CONSTEXPR void on_datetime(numeric_system)
Definition chrono.h:1053
FMT_CONSTEXPR void on_offset_year()
Definition chrono.h:969
FMT_CONSTEXPR void on_full_month()
Definition chrono.h:1005
FMT_CONSTEXPR void on_day_of_month_space(numeric_system)
Definition chrono.h:1033
FMT_CONSTEXPR void on_second(numeric_system)
Definition chrono.h:1049
FMT_CONSTEXPR void on_abbr_month()
Definition chrono.h:1001
FMT_CONSTEXPR void on_dec1_week_of_year(numeric_system)
Definition chrono.h:1017
FMT_CONSTEXPR void on_short_year(numeric_system)
Definition chrono.h:965
FMT_CONSTEXPR void on_us_date()
Definition chrono.h:1065
FMT_CONSTEXPR void on_am_pm()
Definition chrono.h:1085
FMT_CONSTEXPR void on_dec0_weekday(numeric_system)
Definition chrono.h:993
FMT_CONSTEXPR void on_abbr_weekday()
Definition chrono.h:985
FMT_CONSTEXPR void on_utc_offset()
Definition chrono.h:1097
FMT_CONSTEXPR void on_iso_date()
Definition chrono.h:1069
FMT_CONSTEXPR void on_day_of_month(numeric_system)
Definition chrono.h:1029
FMT_CONSTEXPR void on_duration_unit()
Definition chrono.h:1093
FMT_CONSTEXPR void on_24_hour(numeric_system)
Definition chrono.h:1037
FMT_CONSTEXPR void on_dec_month(numeric_system)
Definition chrono.h:1009
FMT_CONSTEXPR void on_dec0_week_of_year(numeric_system)
Definition chrono.h:1013
FMT_CONSTEXPR void on_iso_week_based_year()
Definition chrono.h:977
FMT_CONSTEXPR void on_12_hour(numeric_system)
Definition chrono.h:1041
FMT_CONSTEXPR void on_full_weekday()
Definition chrono.h:989
FMT_CONSTEXPR void on_day_of_year()
Definition chrono.h:1025
FMT_CONSTEXPR void unsupported()
Definition chrono.h:957
FMT_CONSTEXPR void on_duration_value()
Definition chrono.h:1089
FMT_CONSTEXPR void on_12_hour_time()
Definition chrono.h:1073
FMT_CONSTEXPR void on_loc_date(numeric_system)
Definition chrono.h:1057
FMT_CONSTEXPR void on_iso_time()
Definition chrono.h:1081
FMT_CONSTEXPR void on_dec1_weekday(numeric_system)
Definition chrono.h:997
FMT_CONSTEXPR void on_century(numeric_system)
Definition chrono.h:973
FMT_CONSTEXPR void on_24_hour_time()
Definition chrono.h:1077
FMT_CONSTEXPR void on_year(numeric_system)
Definition chrono.h:961
FMT_CONSTEXPR void on_loc_time(numeric_system)
Definition chrono.h:1061
FMT_CONSTEXPR void on_iso_week_based_short_year()
Definition chrono.h:981
FMT_CONSTEXPR void on_minute(numeric_system)
Definition chrono.h:1045
FMT_CONSTEXPR void on_tz_name()
Definition chrono.h:1101
FMT_CONSTEXPR void on_iso_week_of_year(numeric_system)
Definition chrono.h:1021
b
Definition tag_strings.h:61
s
Definition tag_strings.h:47
a
Definition tag_strings.h:43
ms
Definition tag_strings.h:92
u
Definition tag_strings.h:62
time
Definition tag_strings.h:53
p
Definition tag_strings.h:29