Agora
1.2.0
Agora project
|
Go to the documentation of this file.
17 #include <type_traits>
26 # if FMT_HAS_INCLUDE("winapifamily.h")
27 # include <winapifamily.h>
29 # if defined(_WIN32) && (!defined(WINAPI_FAMILY) || \
30 (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
31 # define FMT_USE_TZSET 1
33 # define FMT_USE_TZSET 0
38 #ifndef FMT_SAFE_DURATION_CAST
39 # define FMT_SAFE_DURATION_CAST 1
41 #if FMT_SAFE_DURATION_CAST
51 template <
typename To,
typename From,
57 using F = std::numeric_limits<From>;
58 using T = std::numeric_limits<To>;
67 if (from < (T::min)() || from > (
T::max)()) {
73 return static_cast<To
>(from);
80 template <
typename To,
typename From,
86 using F = std::numeric_limits<From>;
87 using T = std::numeric_limits<To>;
99 from >
static_cast<From
>(detail::max_value<To>())) {
106 F::digits >= T::digits) &&
107 from >
static_cast<From
>(detail::max_value<To>())) {
111 return static_cast<To
>(from);
114 template <
typename To,
typename From,
135 template <
typename To,
typename From,
139 using T = std::numeric_limits<To>;
145 if (from >= T::lowest() && from <= (
T::max)()) {
146 return static_cast<To
>(from);
154 return static_cast<To
>(from);
157 template <
typename To,
typename From,
168 template <
typename To,
typename FromRep,
typename FromPeriod,
173 using From = std::chrono::duration<FromRep, FromPeriod>;
178 : std::ratio_divide<typename From::period, typename To::period> {};
180 static_assert(Factor::num > 0,
"num must be positive");
181 static_assert(Factor::den > 0,
"den must be positive");
187 using IntermediateRep =
188 typename std::common_type<
typename From::rep,
typename To::rep,
189 decltype(Factor::num)>
::type;
192 IntermediateRep
count =
193 lossless_integral_conversion<IntermediateRep>(from.count(), ec);
197 const auto max1 = detail::max_value<IntermediateRep>() / Factor::num;
203 (std::numeric_limits<IntermediateRep>::min)() / Factor::num;
208 count *= Factor::num;
212 auto tocount = lossless_integral_conversion<typename To::rep>(
count, ec);
213 return ec ? To() : To(tocount);
219 template <
typename To,
typename FromRep,
typename FromPeriod,
224 using From = std::chrono::duration<FromRep, FromPeriod>;
228 return To{std::numeric_limits<typename To::rep>::quiet_NaN()};
235 return To{from.count()};
241 : std::ratio_divide<typename From::period, typename To::period> {};
243 static_assert(Factor::num > 0,
"num must be positive");
244 static_assert(Factor::den > 0,
"den must be positive");
250 using IntermediateRep =
251 typename std::common_type<
typename From::rep,
typename To::rep,
252 decltype(Factor::num)>
::type;
256 IntermediateRep
count =
257 safe_float_conversion<IntermediateRep>(from.count(), ec);
264 constexpr
auto max1 = detail::max_value<IntermediateRep>() /
265 static_cast<IntermediateRep
>(Factor::num);
270 constexpr
auto min1 = std::numeric_limits<IntermediateRep>::lowest() /
271 static_cast<IntermediateRep
>(Factor::num);
276 count *=
static_cast<IntermediateRep
>(Factor::num);
282 count /=
static_cast<common_t
>(Factor::den);
286 using ToRep =
typename To::rep;
288 const ToRep tocount = safe_float_conversion<ToRep>(
count, ec);
302 template <
typename T =
void>
struct null {};
309 static const auto& locale = std::locale::classic();
314 static constexpr
const size_t max_size = 32;
315 CodeUnit buf[max_size];
318 template <
typename CodeUnit>
321 template <
typename CodeUnit>
323 const std::locale& loc) {
324 using codecvt = std::codecvt<CodeUnit, char, std::mbstate_t>;
325 #if FMT_CLANG_VERSION
326 # pragma clang diagnostic push
327 # pragma clang diagnostic ignored "-Wdeprecated"
328 auto& f = std::use_facet<codecvt>(loc);
329 # pragma clang diagnostic pop
331 auto& f = std::use_facet<codecvt>(loc);
333 auto mb = std::mbstate_t();
334 const char* from_next =
nullptr;
337 if (
result != std::codecvt_base::ok)
341 template <
typename OutputIt>
347 #if FMT_MSC_VER != 0 || \
348 (defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI))
351 using code_unit = wchar_t;
353 using code_unit = char32_t;
361 for (code_unit*
p = unit.buf;
p != unit.end; ++
p) {
362 uint32_t c =
static_cast<uint32_t
>(*p);
363 if (
sizeof(code_unit) == 2 && c >= 0xd800 && c <= 0xdfff) {
366 if (
p == unit.end || (c & 0xfc00) != 0xd800 ||
367 (*
p & 0xfc00) != 0xdc00) {
370 c = (c << 10) + static_cast<uint32_t>(*
p) - 0x35fdc00;
373 buf.push_back(
static_cast<char>(c));
374 }
else if (c < 0x800) {
375 buf.push_back(
static_cast<char>(0xc0 | (c >> 6)));
376 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
377 }
else if ((c >= 0x800 && c <= 0xd7ff) || (c >= 0xe000 && c <= 0xffff)) {
378 buf.push_back(
static_cast<char>(0xe0 | (c >> 12)));
379 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
380 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
381 }
else if (c >= 0x10000 && c <= 0x10ffff) {
382 buf.push_back(
static_cast<char>(0xf0 | (c >> 18)));
383 buf.push_back(
static_cast<char>(0x80 | ((c & 0x3ffff) >> 12)));
384 buf.push_back(
static_cast<char>(0x80 | ((c & 0xfff) >> 6)));
385 buf.push_back(
static_cast<char>(0x80 | (c & 0x3f)));
390 return copy_str<char>(buf.data(), buf.data() + buf.size(), out);
392 return copy_str<char>(in.data(), in.data() + in.size(), out);
395 template <
typename Char,
typename OutputIt,
401 return copy_str<Char>(unit.
buf, unit.
end, out);
404 template <
typename Char,
typename OutputIt,
411 template <
typename Char>
413 const std::locale& loc,
char format,
char modifier) {
415 auto&& os = std::basic_ostream<Char>(&format_buf);
417 using iterator = std::ostreambuf_iterator<Char>;
418 const auto& facet = std::use_facet<std::time_put<Char, iterator>>(loc);
419 auto end = facet.put(os, os, Char(
' '), &time,
format, modifier);
423 template <
typename Char,
typename OutputIt,
425 auto write(OutputIt out,
const std::tm& time,
const std::locale& loc,
426 char format,
char modifier = 0) -> OutputIt {
427 auto&& buf = get_buffer<Char>(out);
428 do_write<Char>(buf, time, loc,
format, modifier);
432 template <
typename Char,
typename OutputIt,
434 auto write(OutputIt out,
const std::tm& time,
const std::locale& loc,
435 char format,
char modifier = 0) -> OutputIt {
437 do_write<char>(buf, time, loc,
format, modifier);
455 dispatcher(std::time_t t) : time_(t) {}
458 using namespace fmt::detail;
462 bool handle(std::tm* tm) {
return tm !=
nullptr; }
465 using namespace fmt::detail;
469 bool fallback(
int res) {
return res == 0; }
473 using namespace fmt::detail;
476 return tm !=
nullptr;
487 std::chrono::time_point<std::chrono::system_clock> time_point) {
488 return localtime(std::chrono::system_clock::to_time_t(time_point));
496 inline std::tm
gmtime(std::time_t time) {
501 dispatcher(std::time_t t) : time_(t) {}
504 using namespace fmt::detail;
505 return handle(
gmtime_r(&time_, &tm_));
508 bool handle(std::tm* tm) {
return tm !=
nullptr; }
511 using namespace fmt::detail;
512 return fallback(
gmtime_s(&tm_, &time_));
515 bool fallback(
int res) {
return res == 0; }
521 return tm !=
nullptr;
532 std::chrono::time_point<std::chrono::system_clock> time_point) {
533 return gmtime(std::chrono::system_clock::to_time_t(time_point));
542 unsigned c,
char sep) {
543 unsigned long long digits =
544 a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
554 digits += (((digits * 205) >> 11) & 0x000f00000f00000f) * 6;
556 digits = ((digits & 0x00f00000f00000f0) >> 4) |
557 ((digits & 0x000f00000f00000f) << 8);
558 auto usep =
static_cast<unsigned long long>(sep);
560 digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
562 constexpr
const size_t len = 8;
565 memcpy(tmp, &digits,
len);
566 std::reverse_copy(tmp, tmp +
len, buf);
568 memcpy(buf, &digits,
len);
581 if (std::is_same<Period, std::ratio<1>>::
value)
return "s";
590 if (std::is_same<Period, std::ratio<60>>::
value)
return "m";
591 if (std::is_same<Period, std::ratio<3600>>::
value)
return "h";
602 template <
typename Char,
typename Handler>
620 handler.on_text(
ptr - 1,
ptr);
623 const Char newline[] = {
'\n'};
624 handler.on_text(newline, newline + 1);
628 const Char tab[] = {
'\t'};
629 handler.on_text(tab, tab + 1);
634 handler.on_year(numeric_system::standard);
637 handler.on_short_year(numeric_system::standard);
640 handler.on_century(numeric_system::standard);
643 handler.on_iso_week_based_year();
646 handler.on_iso_week_based_short_year();
650 handler.on_abbr_weekday();
653 handler.on_full_weekday();
656 handler.on_dec0_weekday(numeric_system::standard);
659 handler.on_dec1_weekday(numeric_system::standard);
664 handler.on_abbr_month();
667 handler.on_full_month();
670 handler.on_dec_month(numeric_system::standard);
674 handler.on_dec0_week_of_year(numeric_system::standard);
677 handler.on_dec1_week_of_year(numeric_system::standard);
680 handler.on_iso_week_of_year(numeric_system::standard);
683 handler.on_day_of_year();
686 handler.on_day_of_month(numeric_system::standard);
689 handler.on_day_of_month_space(numeric_system::standard);
693 handler.on_24_hour(numeric_system::standard);
696 handler.on_12_hour(numeric_system::standard);
699 handler.on_minute(numeric_system::standard);
702 handler.on_second(numeric_system::standard);
706 handler.on_datetime(numeric_system::standard);
709 handler.on_loc_date(numeric_system::standard);
712 handler.on_loc_time(numeric_system::standard);
715 handler.on_us_date();
718 handler.on_iso_date();
721 handler.on_12_hour_time();
724 handler.on_24_hour_time();
727 handler.on_iso_time();
733 handler.on_duration_value();
736 handler.on_duration_unit();
739 handler.on_utc_offset();
742 handler.on_tz_name();
750 handler.on_year(numeric_system::alternative);
753 handler.on_offset_year();
756 handler.on_century(numeric_system::alternative);
759 handler.on_datetime(numeric_system::alternative);
762 handler.on_loc_date(numeric_system::alternative);
765 handler.on_loc_time(numeric_system::alternative);
777 handler.on_short_year(numeric_system::alternative);
780 handler.on_dec_month(numeric_system::alternative);
783 handler.on_dec0_week_of_year(numeric_system::alternative);
786 handler.on_dec1_week_of_year(numeric_system::alternative);
789 handler.on_iso_week_of_year(numeric_system::alternative);
792 handler.on_day_of_month(numeric_system::alternative);
795 handler.on_day_of_month_space(numeric_system::alternative);
798 handler.on_dec0_weekday(numeric_system::alternative);
801 handler.on_dec1_weekday(numeric_system::alternative);
804 handler.on_24_hour(numeric_system::alternative);
807 handler.on_12_hour(numeric_system::alternative);
810 handler.on_minute(numeric_system::alternative);
813 handler.on_second(numeric_system::alternative);
830 static_cast<Derived*
>(
this)->unsupported();
873 template <
typename Char>
912 static constexpr
const char* full_name_list[] = {
913 "Sunday",
"Monday",
"Tuesday",
"Wednesday",
914 "Thursday",
"Friday",
"Saturday"};
915 return wday >= 0 && wday <= 6 ? full_name_list[wday] :
"?";
918 static constexpr
const char* short_name_list[] = {
"Sun",
"Mon",
"Tue",
"Wed",
919 "Thu",
"Fri",
"Sat"};
920 return wday >= 0 && wday <= 6 ? short_name_list[wday] :
"???";
924 static constexpr
const char* full_name_list[] = {
925 "January",
"February",
"March",
"April",
"May",
"June",
926 "July",
"August",
"September",
"October",
"November",
"December"};
927 return mon >= 0 && mon <= 11 ? full_name_list[mon] :
"?";
930 static constexpr
const char* short_name_list[] = {
931 "Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
932 "Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec",
934 return mon >= 0 && mon <= 11 ? short_name_list[mon] :
"???";
937 template <
typename T,
typename =
void>
939 template <
typename T>
943 template <
typename T,
typename =
void>
945 template <
typename T>
950 inline void tzset_once() {
951 static bool init = []() ->
bool {
959 template <
typename OutputIt,
typename Char>
class tm_writer {
961 static constexpr
int days_per_week = 7;
969 FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61,
"");
973 FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59,
"");
977 FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23,
"");
981 FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31,
"");
985 FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11,
"");
988 auto tm_year() const noexcept ->
long long {
return 1900ll + tm_.tm_year; }
990 FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6,
"");
994 FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365,
"");
999 const auto h = tm_hour();
1000 const auto z = h < 12 ? h : h - 12;
1001 return z == 0 ? 12 : z;
1009 auto l = year % 100;
1011 return static_cast<int>(
l);
1017 const auto prev_year = curr_year - 1;
1019 (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
1022 (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
1024 return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);
1027 return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /
1031 const auto year = tm_year();
1032 const auto w = iso_week_num(tm_yday(), tm_wday());
1033 if (
w < 1)
return year - 1;
1034 if (
w > iso_year_weeks(year))
return year + 1;
1038 const auto year = tm_year();
1039 const auto w = iso_week_num(tm_yday(), tm_wday());
1040 if (
w < 1)
return iso_year_weeks(year - 1);
1041 if (
w > iso_year_weeks(year))
return 1;
1064 if (width > num_digits) out_ =
std::fill_n(out_, width - num_digits,
'0');
1065 out_ = format_decimal<Char>(out_,
n, num_digits).end;
1068 if (year >= 0 && year < 10000) {
1069 write2(
static_cast<int>(year / 100));
1070 write2(
static_cast<int>(year % 100));
1072 write_year_extended(year);
1084 write2(
static_cast<int>(offset / 60));
1085 write2(
static_cast<int>(offset % 60));
1087 template <
typename T, FMT_ENABLE_IF(has_member_data_tm_gmtoff<T>::value)>
1089 write_utc_offset(tm.tm_gmtoff);
1091 template <
typename T, FMT_ENABLE_IF(!has_member_data_tm_gmtoff<T>::value)>
1093 #if defined(_WIN32) && defined(_UCRT)
1098 _get_timezone(&offset);
1101 _get_dstbias(&dstbias);
1104 write_utc_offset(-offset);
1107 format_localized(
'z');
1111 template <
typename T, FMT_ENABLE_IF(has_member_data_tm_zone<T>::value)>
1114 out_ = write_tm_str<Char>(out_, tm.tm_zone, loc_);
1116 format_localized(
'Z');
1118 template <
typename T, FMT_ENABLE_IF(!has_member_data_tm_zone<T>::value)>
1120 format_localized(
'Z');
1124 out_ = write<Char>(out_, tm_, loc_,
format, modifier);
1128 tm_writer(
const std::locale& loc, OutputIt out,
const std::tm& tm)
1134 OutputIt
out()
const {
return out_; }
1137 out_ = copy_str<Char>(
begin,
end, out_);
1144 format_localized(
'a');
1150 format_localized(
'A');
1153 if (is_classic_ || ns == numeric_system::standard)
return write1(tm_wday());
1154 format_localized(
'w',
'O');
1157 if (is_classic_ || ns == numeric_system::standard) {
1158 auto wday = tm_wday();
1159 write1(wday == 0 ? days_per_week : wday);
1161 format_localized(
'u',
'O');
1169 format_localized(
'b');
1175 format_localized(
'B');
1184 on_day_of_month_space(numeric_system::standard);
1188 on_year(numeric_system::standard);
1190 format_localized(
'c', ns == numeric_system::standard ?
'\0' :
'E');
1197 format_localized(
'x', ns == numeric_system::standard ?
'\0' :
'E');
1203 format_localized(
'X', ns == numeric_system::standard ?
'\0' :
'E');
1213 auto year = tm_year();
1216 if (year >= 0 && year < 10000) {
1220 write_year_extended(year);
1233 if (is_classic_ || ns == numeric_system::standard)
1234 return write_year(tm_year());
1235 format_localized(
'Y',
'E');
1238 if (is_classic_ || ns == numeric_system::standard)
1239 return write2(split_year_lower(tm_year()));
1240 format_localized(
'y',
'O');
1243 if (is_classic_)
return write2(split_year_lower(tm_year()));
1244 format_localized(
'y',
'E');
1248 if (is_classic_ || ns == numeric_system::standard) {
1249 auto year = tm_year();
1250 auto upper = year / 100;
1251 if (year >= -99 && year < 0) {
1255 }
else if (upper >= 0 && upper < 100) {
1256 write2(
static_cast<int>(upper));
1258 out_ = write<Char>(out_, upper);
1261 format_localized(
'C',
'E');
1266 if (is_classic_ || ns == numeric_system::standard)
1267 return write2(tm_mon() + 1);
1268 format_localized(
'm',
'O');
1272 if (is_classic_ || ns == numeric_system::standard)
1273 return write2((tm_yday() + days_per_week - tm_wday()) / days_per_week);
1274 format_localized(
'U',
'O');
1277 if (is_classic_ || ns == numeric_system::standard) {
1278 auto wday = tm_wday();
1279 write2((tm_yday() + days_per_week -
1280 (wday == 0 ? (days_per_week - 1) : (wday - 1))) /
1283 format_localized(
'W',
'O');
1287 if (is_classic_ || ns == numeric_system::standard)
1288 return write2(tm_iso_week_of_year());
1289 format_localized(
'V',
'O');
1294 write2(split_year_lower(tm_iso_week_year()));
1298 auto yday = tm_yday() + 1;
1303 if (is_classic_ || ns == numeric_system::standard)
return write2(tm_mday());
1304 format_localized(
'd',
'O');
1307 if (is_classic_ || ns == numeric_system::standard) {
1309 const char* d2 =
digits2(mday);
1310 *out_++ = mday < 10 ?
' ' : d2[0];
1313 format_localized(
'e',
'O');
1318 if (is_classic_ || ns == numeric_system::standard)
return write2(tm_hour());
1319 format_localized(
'H',
'O');
1322 if (is_classic_ || ns == numeric_system::standard)
1323 return write2(tm_hour12());
1324 format_localized(
'I',
'O');
1327 if (is_classic_ || ns == numeric_system::standard)
return write2(tm_min());
1328 format_localized(
'M',
'O');
1331 if (is_classic_ || ns == numeric_system::standard)
return write2(tm_sec());
1332 format_localized(
'S',
'O');
1344 format_localized(
'r');
1361 *out_++ = tm_hour() < 12 ?
'A' :
'P';
1364 format_localized(
'p');
1376 template <
typename Char>
1390 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1394 template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
1399 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1405 template <
typename T,
typename Int, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1410 return static_cast<Int
>(
value);
1412 template <
typename T,
typename Int, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
1414 if (value < 0 || value >
static_cast<T>(upper))
1416 return static_cast<Int
>(
value);
1419 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
1421 return x %
static_cast<T>(
y);
1423 template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
1425 return std::fmod(
x,
static_cast<T>(
y));
1439 #if FMT_SAFE_DURATION_CAST
1441 template <
typename To,
typename FromRep,
typename FromPeriod>
1444 To to = safe_duration_cast::safe_duration_cast<To>(from, ec);
1450 template <
typename Rep,
typename Period,
1453 std::chrono::duration<Rep, Period>
d) {
1456 #if FMT_SAFE_DURATION_CAST
1457 using CommonSecondsType =
1458 typename std::common_type<decltype(
d), std::chrono::seconds>
::type;
1459 const auto d_as_common = fmt_safe_duration_cast<CommonSecondsType>(
d);
1460 const auto d_as_whole_seconds =
1461 fmt_safe_duration_cast<std::chrono::seconds>(d_as_common);
1463 const auto diff = d_as_common - d_as_whole_seconds;
1465 fmt_safe_duration_cast<std::chrono::duration<Rep, std::milli>>(diff);
1468 auto s = std::chrono::duration_cast<std::chrono::seconds>(
d);
1469 return std::chrono::duration_cast<std::chrono::milliseconds>(
d -
s);
1477 return num % den == 0
1483 return n == 0 ? 1 : 10 *
pow10(
n - 1);
1486 template <
class Rep,
class Period,
1488 constexpr std::chrono::duration<Rep, Period>
abs(
1489 std::chrono::duration<Rep, Period>
d) {
1496 return d.count() >=
d.zero().count() ?
d : -
d;
1499 template <
class Rep,
class Period,
1501 constexpr std::chrono::duration<Rep, Period>
abs(
1502 std::chrono::duration<Rep, Period>
d) {
1506 template <
typename Char,
typename Rep,
typename OutputIt,
1509 return write<Char>(out, val);
1512 template <
typename Char,
typename Rep,
typename OutputIt,
1517 specs.type =
precision >= 0 ? presentation_type::fixed_lower
1518 : presentation_type::general_lower;
1519 return write<Char>(out, val, specs);
1522 template <
typename Char,
typename OutputIt>
1527 template <
typename OutputIt>
1532 return std::copy(
u.c_str(),
u.c_str() +
u.size(), out);
1535 template <
typename Char,
typename Period,
typename OutputIt>
1537 if (
const char* unit = get_units<Period>())
1540 out = write<Char>(out, Period::num);
1543 out = write<Char>(out, Period::den);
1555 bool has_locale_ =
false;
1560 ::new (&locale_) std::locale(loc.template get<std::locale>());
1563 if (has_locale_) locale_.~locale();
1565 operator const std::locale&()
const {
1570 template <
typename FormatContext,
typename OutputIt,
typename Rep,
1576 bool localized =
false;
1591 std::chrono::duration<Rep, Period>
d)
1596 if (
d.count() < 0) {
1603 #if FMT_SAFE_DURATION_CAST
1605 auto tmpval = std::chrono::duration<rep, Period>(val);
1606 s = fmt_safe_duration_cast<seconds>(tmpval);
1608 s = std::chrono::duration_cast<seconds>(
1609 std::chrono::duration<rep, Period>(val));
1631 Rep
hour()
const {
return static_cast<Rep
>(
mod((
s.count() / 3600), 24)); }
1634 Rep hour =
static_cast<Rep
>(
mod((
s.count() / 3600), 12));
1635 return hour <= 0 ? 12 : hour;
1638 Rep
minute()
const {
return static_cast<Rep
>(
mod((
s.count() / 60), 60)); }
1639 Rep
second()
const {
return static_cast<Rep
>(
mod(
s.count(), 60)); }
1642 auto time = std::tm();
1662 if (width > num_digits) out =
std::fill_n(out, width - num_digits,
'0');
1663 out = format_decimal<char_type>(out,
n, num_digits).end;
1667 constexpr
auto num_fractional_digits =
1670 using subsecond_precision = std::chrono::duration<
1671 typename std::common_type<
typename Duration::rep,
1672 std::chrono::seconds::rep>
::type,
1674 if (std::ratio_less<
typename subsecond_precision::period,
1675 std::chrono::seconds::period>::
value) {
1680 std::chrono::duration<long double>, std::chrono::seconds>;
1681 auto fractional =
detail::abs(
d) - std::chrono::duration_cast<sec>(
d);
1682 const auto subseconds =
1683 std::chrono::treat_as_floating_point<
1684 typename subsecond_precision::rep>
::value
1685 ? fractional.count()
1686 : std::chrono::duration_cast<subsecond_precision>(fractional)
1691 if (num_fractional_digits > num_digits)
1692 out =
std::fill_n(out, num_fractional_digits - num_digits,
'0');
1693 out = format_decimal<char_type>(out,
n, num_digits).end;
1701 template <
typename Callback,
typename... Args>
1703 if (
isnan(val))
return write_nan();
1743 if (handle_nan_inf())
return;
1745 if (ns == numeric_system::standard)
return write(hour(), 2);
1748 format_tm(time, &tm_writer_type::on_24_hour, ns);
1752 if (handle_nan_inf())
return;
1754 if (ns == numeric_system::standard)
return write(hour12(), 2);
1757 format_tm(time, &tm_writer_type::on_12_hour, ns);
1761 if (handle_nan_inf())
return;
1763 if (ns == numeric_system::standard)
return write(minute(), 2);
1766 format_tm(time, &tm_writer_type::on_minute, ns);
1770 if (handle_nan_inf())
return;
1772 if (ns == numeric_system::standard) {
1774 write_fractional_seconds(std::chrono::duration<rep, Period>{val});
1779 format_tm(time, &tm_writer_type::on_second, ns);
1783 if (handle_nan_inf())
return;
1784 format_tm(time(), &tm_writer_type::on_12_hour_time);
1788 if (handle_nan_inf()) {
1802 if (handle_nan_inf())
return;
1803 on_second(numeric_system::standard);
1807 if (handle_nan_inf())
return;
1808 format_tm(time(), &tm_writer_type::on_am_pm);
1812 if (handle_nan_inf())
return;
1814 out = format_duration_value<char_type>(out, val,
precision);
1818 out = format_duration_unit<char_type, Period>(out);
1824 #if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
1825 using weekday = std::chrono::weekday;
1835 :
value(
static_cast<unsigned char>(wd != 7 ? wd : 0)) {}
1845 bool localized =
false;
1849 -> decltype(ctx.begin()) {
1850 auto begin = ctx.begin(),
end = ctx.end();
1858 template <
typename FormatContext>
1860 auto time = std::tm();
1861 time.tm_wday =
static_cast<int>(wd.c_encoding());
1864 w.on_abbr_weekday();
1869 template <
typename Rep,
typename Period,
typename Char>
1877 bool localized =
false;
1881 struct spec_handler {
1902 f.specs.fill =
fill;
1907 f.precision = _precision;
1912 f.width_ref = make_arg_ref(arg_id);
1916 f.precision_ref = make_arg_ref(arg_id);
1921 struct parse_range {
1929 spec_handler handler{*
this, ctx, format_str};
1934 if (*
begin ==
'.') {
1938 handler.on_error(
"precision not allowed for this argument type");
1951 -> decltype(ctx.begin()) {
1952 auto range = do_parse(ctx);
1958 template <
typename FormatContext>
1960 -> decltype(ctx.out()) {
1961 auto specs_copy = specs;
1967 auto out = std::back_inserter(buf);
1968 detail::handle_dynamic_spec<detail::width_checker>(specs_copy.width,
1970 detail::handle_dynamic_spec<detail::precision_checker>(precision_copy,
1971 precision_ref, ctx);
1973 out = detail::format_duration_value<Char>(out,
d.count(), precision_copy);
1974 detail::format_duration_unit<Char, Period>(out);
1978 f.precision = precision_copy;
1979 f.localized = localized;
1987 template <
typename Char,
typename Duration>
1988 struct formatter<
std::chrono::time_point<std::chrono::system_clock, Duration>,
1991 this->do_parse(default_specs,
1992 default_specs +
sizeof(default_specs) /
sizeof(Char));
1995 template <
typename ParseContext>
1997 return this->do_parse(ctx.begin(), ctx.end(),
true);
2000 template <
typename FormatContext>
2001 auto format(std::chrono::time_point<std::chrono::system_clock> val,
2002 FormatContext& ctx)
const -> decltype(ctx.out()) {
2006 static constexpr
const Char default_specs[] = {
'%',
'F',
' ',
'%',
'T'};
2009 template <
typename Char,
typename Duration>
2010 constexpr
const Char
2012 Char>::default_specs[];
2025 template <
typename It>
2033 if (specs.
size() == 2 && specs[0] == Char(
'%')) {
2034 if (specs[1] == Char(
'F'))
2035 spec_ = spec::year_month_day;
2036 else if (specs[1] == Char(
'T'))
2037 spec_ = spec::hh_mm_ss;
2043 template <
typename ParseContext>
2045 return this->do_parse(ctx.begin(), ctx.end());
2048 template <
typename FormatContext>
2049 auto format(
const std::tm& tm, FormatContext& ctx)
const
2050 -> decltype(ctx.out()) {
2051 const auto loc_ref = ctx.locale();
2054 if (spec_ == spec::year_month_day)
2056 else if (spec_ == spec::hh_mm_ss)
2067 #endif // FMT_CHRONO_H_
void on_iso_date()
Definition: chrono.h:1212
void write_digit2_separated(char *buf, unsigned a, unsigned b, unsigned c, char sep)
Definition: chrono.h:541
void on_iso_week_based_short_year()
Definition: chrono.h:837
auto tm_mday() const noexcept -> int
Definition: chrono.h:980
bool isinf(T value)
Definition: format.h:1941
basic_string_view< char > string_view
Definition: core.h:540
void on_year(numeric_system ns)
Definition: chrono.h:1232
constexpr const char * digits2(size_t value)
Definition: format.h:919
void ignore_unused(const T &...)
Definition: core.h:352
void on_24_hour_time()
Definition: chrono.h:861
void on_duration_value()
Definition: chrono.h:864
auto parse_align(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2300
bool isnan(T)
Definition: chrono.h:1391
Definition: chrono.h:1550
void on_iso_week_based_year()
Definition: chrono.h:836
std::chrono::duration< Rep, std::milli > get_milliseconds(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1452
void on_datetime(numeric_system ns)
Definition: chrono.h:1178
const Char * parse_chrono_format(const Char *begin, const Char *end, Handler &&handler)
Definition: chrono.h:603
w
Definition: mm_gui.py:119
null gmtime_s(...)
Definition: chrono.h:306
OutputIt out_
Definition: chrono.h:965
void check_arg_id(int)
Definition: core.h:683
void on_iso_week_of_year(numeric_system ns)
Definition: chrono.h:1286
constexpr auto end() const -> iterator
Definition: core.h:658
void on_12_hour(numeric_system ns)
Definition: chrono.h:1321
void write_codecvt(codecvt_result< CodeUnit > &out, string_view in_buf, const std::locale &loc)
Definition: chrono.h:322
auto tm_iso_week_of_year() const noexcept -> int
Definition: chrono.h:1037
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:425
void void_t
Definition: core.h:1641
void on_text(const Char *begin, const Char *end)
Definition: chrono.h:1136
void on_duration_unit()
Definition: chrono.h:1370
OutputIt copy_unit(string_view unit, OutputIt out, wchar_t)
Definition: chrono.h:1528
void on_utc_offset()
Definition: chrono.h:866
auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int
Definition: chrono.h:1026
std::tm localtime(std::chrono::time_point< std::chrono::system_clock > time_point)
Definition: chrono.h:486
void on_dec0_weekday(numeric_system)
Definition: chrono.h:840
Definition: chrono.h:1839
void on_dec_month(numeric_system)
Definition: chrono.h:844
conditional_t< num_bits< T >()<=32 &&! 0, uint32_t, conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > > uint32_or_64_or_128_t
Definition: format.h:909
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:3999
const bool is_classic_
Definition: chrono.h:964
constexpr auto is_utf8() -> bool
Definition: core.h:432
auto tm_wday() const noexcept -> int
Definition: chrono.h:989
void on_day_of_month_space(numeric_system)
Definition: chrono.h:850
void write_year(long long year)
Definition: chrono.h:1067
#define FMT_NOMACRO
Definition: chrono.h:299
constexpr auto size() const -> size_t
Definition: core.h:820
for p
Definition: process_rx_frame.m:36
typename std::make_unsigned< T >::type type
Definition: chrono.h:1436
void on_full_weekday()
Definition: chrono.h:839
OutputIt format_duration_value(OutputIt out, Rep val, int)
Definition: chrono.h:1508
void on_offset_year()
Definition: chrono.h:834
void on_full_month()
Definition: chrono.h:843
auto parse_width(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2383
auto parse_precision(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2417
constexpr auto size() const -> size_t
Definition: core.h:495
void on_full_month()
Definition: chrono.h:1171
numeric_system
Definition: chrono.h:595
bool_constant< is_integral< T >::value &&!std::is_same< T, bool >::value &&!std::is_same< T, char >::value &&!std::is_same< T, wchar_t >::value > is_integer
Definition: format.h:2241
To lossless_integral_conversion(const From from, int &ec)
Definition: chrono.h:55
auto is_big_endian() -> bool
Definition: format.h:298
void on_loc_date(numeric_system)
Definition: chrono.h:856
void on_dec_month(numeric_system ns)
Definition: chrono.h:1265
count
Definition: inspect_agora_results.m:96
void on_second(numeric_system)
Definition: chrono.h:854
bool fill(const std::vector< Numeric > &x, const std::vector< Numeric > &y, const std::map< std::string, std::string > &keywords)
Definition: matplotlibcpp.h:790
void on_12_hour_time()
Definition: chrono.h:1335
void on_24_hour(numeric_system ns)
Definition: chrono.h:1317
void on_loc_time(numeric_system ns)
Definition: chrono.h:1199
auto is_negative(T value) -> bool
Definition: format.h:888
void on_am_pm()
Definition: chrono.h:863
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)
Definition: catch.hpp:4693
#define FMT_NORETURN
Definition: core.h:176
unsigned char value
Definition: chrono.h:1830
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1488
void write1(int value)
Definition: chrono.h:1045
void on_dec0_week_of_year(numeric_system)
Definition: chrono.h:845
void on_abbr_weekday()
Definition: chrono.h:838
void on_minute(numeric_system)
Definition: chrono.h:853
#define FMT_ENABLE_IF(...)
Definition: core.h:344
auto next_arg_id() -> int
Definition: core.h:671
void on_am_pm()
Definition: chrono.h:1359
const char * tm_wday_short_name(int wday)
Definition: chrono.h:917
Definition: chrono.h:1828
void write_year_extended(long long year)
Definition: chrono.h:1054
OutputIt format_duration_unit(OutputIt out)
Definition: chrono.h:1536
void on_dec1_week_of_year(numeric_system ns)
Definition: chrono.h:1276
auto ptr(T p) -> const void *
Definition: format.h:2680
void on_datetime(numeric_system)
Definition: chrono.h:855
Definition: format.h:1188
void unsupported()
Definition: chrono.h:829
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale &loc) -> OutputIt
Definition: chrono.h:342
void on_short_year(numeric_system)
Definition: chrono.h:833
constexpr auto begin() const -> iterator
Definition: core.h:651
std::locale locale_
Definition: chrono.h:1553
void on_day_of_month(numeric_system)
Definition: chrono.h:849
uint16_t len
Definition: eth_common.h:62
void on_loc_date(numeric_system ns)
Definition: chrono.h:1193
void format_tz_name_impl(const T &)
Definition: chrono.h:1119
void on_12_hour_time()
Definition: chrono.h:860
void on_tz_name()
Definition: chrono.h:867
#define FMT_END_NAMESPACE
Definition: core.h:240
void on_dec1_weekday(numeric_system)
Definition: chrono.h:841
j template void())
Definition: json.hpp:4744
void on_dec0_weekday(numeric_system ns)
Definition: chrono.h:1152
void on_iso_week_based_year()
Definition: chrono.h:1292
CodeUnit buf[max_size]
Definition: chrono.h:315
void on_us_date()
Definition: chrono.h:858
Plot Rx waveform for u
Definition: inspect_single_frame.m:108
constexpr auto end() const -> iterator
Definition: core.h:498
constexpr auto const_check(T value) -> T
Definition: core.h:365
void format_tz_name_impl(const T &tm)
Definition: chrono.h:1112
void on_year(numeric_system)
Definition: chrono.h:832
void format_localized(char format, char modifier=0)
Definition: chrono.h:1123
void on_abbr_month()
Definition: chrono.h:1165
To fmt_safe_duration_cast(std::chrono::duration< FromRep, FromPeriod > from)
Definition: chrono.h:1442
void on_abbr_weekday()
Definition: chrono.h:1140
const char * tm_mon_short_name(int mon)
Definition: chrono.h:929
constexpr auto begin() const -> iterator
Definition: core.h:497
void on_iso_week_of_year(numeric_system)
Definition: chrono.h:847
void on_loc_time(numeric_system)
Definition: chrono.h:857
null gmtime_r(...)
Definition: chrono.h:305
const char * tm_wday_full_name(int wday)
Definition: chrono.h:911
void on_iso_time()
Definition: chrono.h:862
type
Definition: core.h:2021
void on_abbr_month()
Definition: chrono.h:842
void on_dec1_week_of_year(numeric_system)
Definition: chrono.h:846
void on_12_hour(numeric_system)
Definition: chrono.h:852
constexpr int count_fractional_digits(long long num, long long den, int n=0)
Definition: chrono.h:1476
void on_utc_offset()
Definition: chrono.h:1229
void on_day_of_year()
Definition: chrono.h:848
To safe_duration_cast(std::chrono::duration< FromRep, FromPeriod > from, int &ec)
Definition: chrono.h:171
auto iso_year_weeks(long long curr_year) const noexcept -> int
Definition: chrono.h:1016
Int to_nonnegative_int(T value, Int upper)
Definition: chrono.h:1406
auto tm_hour12() const noexcept -> int
Definition: chrono.h:998
for d
Definition: process_rx_frame.m:53
void on_second(numeric_system ns)
Definition: chrono.h:1330
auto data() -> T *
Definition: core.h:826
T mod(T x, int y)
Definition: chrono.h:1420
constexpr unsigned c_encoding() const noexcept
Definition: chrono.h:1836
void on_full_weekday()
Definition: chrono.h:1146
const char * get_units()
Definition: chrono.h:572
void on_24_hour(numeric_system)
Definition: chrono.h:851
#define FMT_ASSERT(condition, message)
Definition: core.h:378
void on_duration_value()
Definition: chrono.h:1369
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition: core.h:249
void on_iso_date()
Definition: chrono.h:859
auto tm_hour() const noexcept -> int
Definition: chrono.h:976
CodeUnit * end
Definition: chrono.h:316
auto split_year_lower(long long year) const noexcept -> int
Definition: chrono.h:1008
#define FMT_MODULE_EXPORT_END
Definition: core.h:248
#define FMT_MODULE_EXPORT_BEGIN
Definition: core.h:247
auto tm_min() const noexcept -> int
Definition: chrono.h:972
unsigned int count_digits(T n)
Definition: fmt_helper.h:83
void format_utc_offset_impl(const T &tm)
Definition: chrono.h:1088
void on_us_date()
Definition: chrono.h:1205
void on_century(numeric_system)
Definition: chrono.h:835
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:323
Definition: json.hpp:5213
OutputIt out() const
Definition: chrono.h:1134
void on_dec0_week_of_year(numeric_system ns)
Definition: chrono.h:1271
void on_iso_week_based_short_year()
Definition: chrono.h:1293
void on_24_hour_time()
Definition: chrono.h:1347
void on_minute(numeric_system ns)
Definition: chrono.h:1326
const std::locale & get_classic_locale()
Definition: chrono.h:308
auto tm_yday() const noexcept -> int
Definition: chrono.h:993
OutputIterator copy(const RangeT &range, OutputIterator out)
Definition: ranges.h:26
const std::tm & tm_
Definition: chrono.h:966
constexpr weekday(unsigned wd) noexcept
Definition: chrono.h:1834
null localtime_r(...)
Definition: chrono.h:303
#define FMT_BEGIN_NAMESPACE
Definition: core.h:237
void on_dec1_weekday(numeric_system ns)
Definition: chrono.h:1156
std::tm gmtime(std::chrono::time_point< std::chrono::system_clock > time_point)
Definition: chrono.h:531
void on_day_of_year()
Definition: chrono.h:1297
const std::locale & loc_
Definition: chrono.h:963
~get_locale()
Definition: chrono.h:1562
get_locale(bool localized, locale_ref loc)
Definition: chrono.h:1558
To safe_float_conversion(const From from, int &ec)
Definition: chrono.h:137
constexpr long long pow10(std::uint32_t n)
Definition: chrono.h:1482
Definition: chrono.h:1431
void on_offset_year()
Definition: chrono.h:1242
void on_duration_unit()
Definition: chrono.h:865
l
Definition: parse_all_dl.m:71
void write_utc_offset(long offset)
Definition: chrono.h:1076
auto write_tm_str(OutputIt out, string_view sv, const std::locale &loc) -> OutputIt
Definition: chrono.h:397
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_t >::value > is_signed
Definition: format.h:883
auto tm_year() const noexcept -> long long
Definition: chrono.h:988
void write2(int value)
Definition: chrono.h:1048
void on_iso_time()
Definition: chrono.h:1352
null localtime_s(...)
Definition: chrono.h:304
const char * tm_mon_full_name(int mon)
Definition: chrono.h:923
void on_short_year(numeric_system ns)
Definition: chrono.h:1237
#define FMT_END_DETAIL_NAMESPACE
Definition: core.h:250
auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:424
void copy2(Char *dst, const char *src)
Definition: format.h:1088
auto tm_iso_week_year() const noexcept -> long long
Definition: chrono.h:1030
auto tm_sec() const noexcept -> int
Definition: chrono.h:968
void on_day_of_month_space(numeric_system ns)
Definition: chrono.h:1306
#define FMT_CONSTEXPR
Definition: core.h:110
void on_day_of_month(numeric_system ns)
Definition: chrono.h:1302
result
Definition: format-inl.h:640
bool isfinite(T)
Definition: chrono.h:1400
std::string format(const T &value)
Definition: utils.h:15
void on_tz_name()
Definition: chrono.h:1230
type
Definition: core.h:1131
void on_century(numeric_system ns)
Definition: chrono.h:1247
void do_write(buffer< Char > &buf, const std::tm &time, const std::locale &loc, char format, char modifier)
Definition: chrono.h:412
T type
Definition: chrono.h:1432
tm_writer(const std::locale &loc, OutputIt out, const std::tm &tm)
Definition: chrono.h:1128
auto tm_mon() const noexcept -> int
Definition: chrono.h:984
auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition: format.h:448
precision
Definition: inspect_single_frame.m:150