Agora  1.2.0
Agora project
chrono.h
Go to the documentation of this file.
1 // Formatting library for C++ - chrono support
2 //
3 // Copyright (c) 2012 - present, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7 
8 #ifndef FMT_CHRONO_H_
9 #define FMT_CHRONO_H_
10 
11 #include <algorithm>
12 #include <chrono>
13 #include <ctime>
14 #include <iterator>
15 #include <locale>
16 #include <ostream>
17 #include <type_traits>
18 
19 #include "format.h"
20 
22 
23 // Enable tzset.
24 #ifndef FMT_USE_TZSET
25 // UWP doesn't provide _tzset.
26 # if FMT_HAS_INCLUDE("winapifamily.h")
27 # include <winapifamily.h>
28 # endif
29 # if defined(_WIN32) && (!defined(WINAPI_FAMILY) || \
30  (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
31 # define FMT_USE_TZSET 1
32 # else
33 # define FMT_USE_TZSET 0
34 # endif
35 #endif
36 
37 // Enable safe chrono durations, unless explicitly disabled.
38 #ifndef FMT_SAFE_DURATION_CAST
39 # define FMT_SAFE_DURATION_CAST 1
40 #endif
41 #if FMT_SAFE_DURATION_CAST
42 
43 // For conversion between std::chrono::durations without undefined
44 // behaviour or erroneous results.
45 // This is a stripped down version of duration_cast, for inclusion in fmt.
46 // See https://github.com/pauldreik/safe_duration_cast
47 //
48 // Copyright Paul Dreik 2019
49 namespace safe_duration_cast {
50 
51 template <typename To, typename From,
55 FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
56  ec = 0;
57  using F = std::numeric_limits<From>;
58  using T = std::numeric_limits<To>;
59  static_assert(F::is_integer, "From must be integral");
60  static_assert(T::is_integer, "To must be integral");
61 
62  // A and B are both signed, or both unsigned.
63  if (detail::const_check(F::digits <= T::digits)) {
64  // From fits in To without any problem.
65  } else {
66  // From does not always fit in To, resort to a dynamic check.
67  if (from < (T::min)() || from > (T::max)()) {
68  // outside range.
69  ec = 1;
70  return {};
71  }
72  }
73  return static_cast<To>(from);
74 }
75 
80 template <typename To, typename From,
84 FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
85  ec = 0;
86  using F = std::numeric_limits<From>;
87  using T = std::numeric_limits<To>;
88  static_assert(F::is_integer, "From must be integral");
89  static_assert(T::is_integer, "To must be integral");
90 
92  // From may be negative, not allowed!
93  if (fmt::detail::is_negative(from)) {
94  ec = 1;
95  return {};
96  }
97  // From is positive. Can it always fit in To?
98  if (detail::const_check(F::digits > T::digits) &&
99  from > static_cast<From>(detail::max_value<To>())) {
100  ec = 1;
101  return {};
102  }
103  }
104 
106  F::digits >= T::digits) &&
107  from > static_cast<From>(detail::max_value<To>())) {
108  ec = 1;
109  return {};
110  }
111  return static_cast<To>(from); // Lossless conversion.
112 }
113 
114 template <typename To, typename From,
116 FMT_CONSTEXPR To lossless_integral_conversion(const From from, int& ec) {
117  ec = 0;
118  return from;
119 } // function
120 
121 // clang-format off
134 // clang-format on
135 template <typename To, typename From,
137 FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
138  ec = 0;
139  using T = std::numeric_limits<To>;
140  static_assert(std::is_floating_point<From>::value, "From must be floating");
141  static_assert(std::is_floating_point<To>::value, "To must be floating");
142 
143  // catch the only happy case
144  if (std::isfinite(from)) {
145  if (from >= T::lowest() && from <= (T::max)()) {
146  return static_cast<To>(from);
147  }
148  // not within range.
149  ec = 1;
150  return {};
151  }
152 
153  // nan and inf will be preserved
154  return static_cast<To>(from);
155 } // function
156 
157 template <typename To, typename From,
159 FMT_CONSTEXPR To safe_float_conversion(const From from, int& ec) {
160  ec = 0;
161  static_assert(std::is_floating_point<From>::value, "From must be floating");
162  return from;
163 }
164 
168 template <typename To, typename FromRep, typename FromPeriod,
171 To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
172  int& ec) {
173  using From = std::chrono::duration<FromRep, FromPeriod>;
174  ec = 0;
175  // the basic idea is that we need to convert from count() in the from type
176  // to count() in the To type, by multiplying it with this:
177  struct Factor
178  : std::ratio_divide<typename From::period, typename To::period> {};
179 
180  static_assert(Factor::num > 0, "num must be positive");
181  static_assert(Factor::den > 0, "den must be positive");
182 
183  // the conversion is like this: multiply from.count() with Factor::num
184  // /Factor::den and convert it to To::rep, all this without
185  // overflow/underflow. let's start by finding a suitable type that can hold
186  // both To, From and Factor::num
187  using IntermediateRep =
188  typename std::common_type<typename From::rep, typename To::rep,
189  decltype(Factor::num)>::type;
190 
191  // safe conversion to IntermediateRep
192  IntermediateRep count =
193  lossless_integral_conversion<IntermediateRep>(from.count(), ec);
194  if (ec) return {};
195  // multiply with Factor::num without overflow or underflow
196  if (detail::const_check(Factor::num != 1)) {
197  const auto max1 = detail::max_value<IntermediateRep>() / Factor::num;
198  if (count > max1) {
199  ec = 1;
200  return {};
201  }
202  const auto min1 =
203  (std::numeric_limits<IntermediateRep>::min)() / Factor::num;
204  if (count < min1) {
205  ec = 1;
206  return {};
207  }
208  count *= Factor::num;
209  }
210 
211  if (detail::const_check(Factor::den != 1)) count /= Factor::den;
212  auto tocount = lossless_integral_conversion<typename To::rep>(count, ec);
213  return ec ? To() : To(tocount);
214 }
215 
219 template <typename To, typename FromRep, typename FromPeriod,
222 To safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from,
223  int& ec) {
224  using From = std::chrono::duration<FromRep, FromPeriod>;
225  ec = 0;
226  if (std::isnan(from.count())) {
227  // nan in, gives nan out. easy.
228  return To{std::numeric_limits<typename To::rep>::quiet_NaN()};
229  }
230  // maybe we should also check if from is denormal, and decide what to do about
231  // it.
232 
233  // +-inf should be preserved.
234  if (std::isinf(from.count())) {
235  return To{from.count()};
236  }
237 
238  // the basic idea is that we need to convert from count() in the from type
239  // to count() in the To type, by multiplying it with this:
240  struct Factor
241  : std::ratio_divide<typename From::period, typename To::period> {};
242 
243  static_assert(Factor::num > 0, "num must be positive");
244  static_assert(Factor::den > 0, "den must be positive");
245 
246  // the conversion is like this: multiply from.count() with Factor::num
247  // /Factor::den and convert it to To::rep, all this without
248  // overflow/underflow. let's start by finding a suitable type that can hold
249  // both To, From and Factor::num
250  using IntermediateRep =
251  typename std::common_type<typename From::rep, typename To::rep,
252  decltype(Factor::num)>::type;
253 
254  // force conversion of From::rep -> IntermediateRep to be safe,
255  // even if it will never happen be narrowing in this context.
256  IntermediateRep count =
257  safe_float_conversion<IntermediateRep>(from.count(), ec);
258  if (ec) {
259  return {};
260  }
261 
262  // multiply with Factor::num without overflow or underflow
263  if (detail::const_check(Factor::num != 1)) {
264  constexpr auto max1 = detail::max_value<IntermediateRep>() /
265  static_cast<IntermediateRep>(Factor::num);
266  if (count > max1) {
267  ec = 1;
268  return {};
269  }
270  constexpr auto min1 = std::numeric_limits<IntermediateRep>::lowest() /
271  static_cast<IntermediateRep>(Factor::num);
272  if (count < min1) {
273  ec = 1;
274  return {};
275  }
276  count *= static_cast<IntermediateRep>(Factor::num);
277  }
278 
279  // this can't go wrong, right? den>0 is checked earlier.
280  if (detail::const_check(Factor::den != 1)) {
281  using common_t = typename std::common_type<IntermediateRep, intmax_t>::type;
282  count /= static_cast<common_t>(Factor::den);
283  }
284 
285  // convert to the to type, safely
286  using ToRep = typename To::rep;
287 
288  const ToRep tocount = safe_float_conversion<ToRep>(count, ec);
289  if (ec) {
290  return {};
291  }
292  return To{tocount};
293 }
294 } // namespace safe_duration_cast
295 #endif
296 
297 // Prevents expansion of a preceding token as a function-style macro.
298 // Usage: f FMT_NOMACRO()
299 #define FMT_NOMACRO
300 
301 namespace detail {
302 template <typename T = void> struct null {};
303 inline null<> localtime_r FMT_NOMACRO(...) { return null<>(); }
304 inline null<> localtime_s(...) { return null<>(); }
305 inline null<> gmtime_r(...) { return null<>(); }
306 inline null<> gmtime_s(...) { return null<>(); }
307 
308 inline const std::locale& get_classic_locale() {
309  static const auto& locale = std::locale::classic();
310  return locale;
311 }
312 
313 template <typename CodeUnit> struct codecvt_result {
314  static constexpr const size_t max_size = 32;
315  CodeUnit buf[max_size];
316  CodeUnit* end;
317 };
318 template <typename CodeUnit>
319 constexpr const size_t codecvt_result<CodeUnit>::max_size;
320 
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
330 #else
331  auto& f = std::use_facet<codecvt>(loc);
332 #endif
333  auto mb = std::mbstate_t();
334  const char* from_next = nullptr;
335  auto result = f.in(mb, in_buf.begin(), in_buf.end(), from_next,
336  std::begin(out.buf), std::end(out.buf), out.end);
337  if (result != std::codecvt_base::ok)
338  FMT_THROW(format_error("failed to format time"));
339 }
340 
341 template <typename OutputIt>
342 auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale& loc)
343  -> OutputIt {
344  if (detail::is_utf8() && loc != get_classic_locale()) {
345  // char16_t and char32_t codecvts are broken in MSVC (linkage errors) and
346  // gcc-4.
347 #if FMT_MSC_VER != 0 || \
348  (defined(__GLIBCXX__) && !defined(_GLIBCXX_USE_DUAL_ABI))
349  // The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5
350  // and newer.
351  using code_unit = wchar_t;
352 #else
353  using code_unit = char32_t;
354 #endif
355 
356  using unit_t = codecvt_result<code_unit>;
357  unit_t unit;
358  write_codecvt(unit, in, loc);
359  // In UTF-8 is used one to four one-byte code units.
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) {
364  // surrogate pair
365  ++p;
366  if (p == unit.end || (c & 0xfc00) != 0xd800 ||
367  (*p & 0xfc00) != 0xdc00) {
368  FMT_THROW(format_error("failed to format time"));
369  }
370  c = (c << 10) + static_cast<uint32_t>(*p) - 0x35fdc00;
371  }
372  if (c < 0x80) {
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)));
386  } else {
387  FMT_THROW(format_error("failed to format time"));
388  }
389  }
390  return copy_str<char>(buf.data(), buf.data() + buf.size(), out);
391  }
392  return copy_str<char>(in.data(), in.data() + in.size(), out);
393 }
394 
395 template <typename Char, typename OutputIt,
397 auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
398  -> OutputIt {
400  write_codecvt(unit, sv, loc);
401  return copy_str<Char>(unit.buf, unit.end, out);
402 }
403 
404 template <typename Char, typename OutputIt,
406 auto write_tm_str(OutputIt out, string_view sv, const std::locale& loc)
407  -> OutputIt {
408  return write_encoded_tm_str(out, sv, loc);
409 }
410 
411 template <typename Char>
412 inline void do_write(buffer<Char>& buf, const std::tm& time,
413  const std::locale& loc, char format, char modifier) {
414  auto&& format_buf = formatbuf<std::basic_streambuf<Char>>(buf);
415  auto&& os = std::basic_ostream<Char>(&format_buf);
416  os.imbue(loc);
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);
420  if (end.failed()) FMT_THROW(format_error("failed to format time"));
421 }
422 
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);
429  return buf.out();
430 }
431 
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 {
436  auto&& buf = basic_memory_buffer<Char>();
437  do_write<char>(buf, time, loc, format, modifier);
438  return write_encoded_tm_str(out, string_view(buf.data(), buf.size()), loc);
439 }
440 
441 } // namespace detail
442 
444 
450 inline std::tm localtime(std::time_t time) {
451  struct dispatcher {
452  std::time_t time_;
453  std::tm tm_;
454 
455  dispatcher(std::time_t t) : time_(t) {}
456 
457  bool run() {
458  using namespace fmt::detail;
459  return handle(localtime_r(&time_, &tm_));
460  }
461 
462  bool handle(std::tm* tm) { return tm != nullptr; }
463 
464  bool handle(detail::null<>) {
465  using namespace fmt::detail;
466  return fallback(localtime_s(&tm_, &time_));
467  }
468 
469  bool fallback(int res) { return res == 0; }
470 
471 #if !FMT_MSC_VER
472  bool fallback(detail::null<>) {
473  using namespace fmt::detail;
474  std::tm* tm = std::localtime(&time_);
475  if (tm) tm_ = *tm;
476  return tm != nullptr;
477  }
478 #endif
479  };
480  dispatcher lt(time);
481  // Too big time values may be unsupported.
482  if (!lt.run()) FMT_THROW(format_error("time_t value out of range"));
483  return lt.tm_;
484 }
485 
486 inline std::tm localtime(
487  std::chrono::time_point<std::chrono::system_clock> time_point) {
488  return localtime(std::chrono::system_clock::to_time_t(time_point));
489 }
490 
496 inline std::tm gmtime(std::time_t time) {
497  struct dispatcher {
498  std::time_t time_;
499  std::tm tm_;
500 
501  dispatcher(std::time_t t) : time_(t) {}
502 
503  bool run() {
504  using namespace fmt::detail;
505  return handle(gmtime_r(&time_, &tm_));
506  }
507 
508  bool handle(std::tm* tm) { return tm != nullptr; }
509 
510  bool handle(detail::null<>) {
511  using namespace fmt::detail;
512  return fallback(gmtime_s(&tm_, &time_));
513  }
514 
515  bool fallback(int res) { return res == 0; }
516 
517 #if !FMT_MSC_VER
518  bool fallback(detail::null<>) {
519  std::tm* tm = std::gmtime(&time_);
520  if (tm) tm_ = *tm;
521  return tm != nullptr;
522  }
523 #endif
524  };
525  dispatcher gt(time);
526  // Too big time values may be unsupported.
527  if (!gt.run()) FMT_THROW(format_error("time_t value out of range"));
528  return gt.tm_;
529 }
530 
531 inline std::tm gmtime(
532  std::chrono::time_point<std::chrono::system_clock> time_point) {
533  return gmtime(std::chrono::system_clock::to_time_t(time_point));
534 }
535 
537 
538 // Writes two-digit numbers a, b and c separated by sep to buf.
539 // The method by Pavel Novikov based on
540 // https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.
541 inline void write_digit2_separated(char* buf, unsigned a, unsigned b,
542  unsigned c, char sep) {
543  unsigned long long digits =
544  a | (b << 24) | (static_cast<unsigned long long>(c) << 48);
545  // Convert each value to BCD.
546  // We have x = a * 10 + b and we want to convert it to BCD y = a * 16 + b.
547  // The difference is
548  // y - x = a * 6
549  // a can be found from x:
550  // a = floor(x / 10)
551  // then
552  // y = x + a * 6 = x + floor(x / 10) * 6
553  // floor(x / 10) is (x * 205) >> 11 (needs 16 bits).
554  digits += (((digits * 205) >> 11) & 0x000f00000f00000f) * 6;
555  // Put low nibbles to high bytes and high nibbles to low bytes.
556  digits = ((digits & 0x00f00000f00000f0) >> 4) |
557  ((digits & 0x000f00000f00000f) << 8);
558  auto usep = static_cast<unsigned long long>(sep);
559  // Add ASCII '0' to each digit byte and insert separators.
560  digits |= 0x3030003030003030 | (usep << 16) | (usep << 40);
561 
562  constexpr const size_t len = 8;
563  if (const_check(is_big_endian())) {
564  char tmp[len];
565  memcpy(tmp, &digits, len);
566  std::reverse_copy(tmp, tmp + len, buf);
567  } else {
568  memcpy(buf, &digits, len);
569  }
570 }
571 
572 template <typename Period> FMT_CONSTEXPR inline const char* get_units() {
577  if (std::is_same<Period, std::micro>::value) return "µs";
581  if (std::is_same<Period, std::ratio<1>>::value) return "s";
582  if (std::is_same<Period, std::deca>::value) return "das";
589  if (std::is_same<Period, std::exa>::value) return "Es";
590  if (std::is_same<Period, std::ratio<60>>::value) return "m";
591  if (std::is_same<Period, std::ratio<3600>>::value) return "h";
592  return nullptr;
593 }
594 
595 enum class numeric_system {
596  standard,
597  // Alternative numeric system, e.g. 十二 instead of 12 in ja_JP locale.
599 };
600 
601 // Parses a put_time-like format string and invokes handler actions.
602 template <typename Char, typename Handler>
603 FMT_CONSTEXPR const Char* parse_chrono_format(const Char* begin,
604  const Char* end,
605  Handler&& handler) {
606  auto ptr = begin;
607  while (ptr != end) {
608  auto c = *ptr;
609  if (c == '}') break;
610  if (c != '%') {
611  ++ptr;
612  continue;
613  }
614  if (begin != ptr) handler.on_text(begin, ptr);
615  ++ptr; // consume '%'
616  if (ptr == end) FMT_THROW(format_error("invalid format"));
617  c = *ptr++;
618  switch (c) {
619  case '%':
620  handler.on_text(ptr - 1, ptr);
621  break;
622  case 'n': {
623  const Char newline[] = {'\n'};
624  handler.on_text(newline, newline + 1);
625  break;
626  }
627  case 't': {
628  const Char tab[] = {'\t'};
629  handler.on_text(tab, tab + 1);
630  break;
631  }
632  // Year:
633  case 'Y':
634  handler.on_year(numeric_system::standard);
635  break;
636  case 'y':
637  handler.on_short_year(numeric_system::standard);
638  break;
639  case 'C':
640  handler.on_century(numeric_system::standard);
641  break;
642  case 'G':
643  handler.on_iso_week_based_year();
644  break;
645  case 'g':
646  handler.on_iso_week_based_short_year();
647  break;
648  // Day of the week:
649  case 'a':
650  handler.on_abbr_weekday();
651  break;
652  case 'A':
653  handler.on_full_weekday();
654  break;
655  case 'w':
656  handler.on_dec0_weekday(numeric_system::standard);
657  break;
658  case 'u':
659  handler.on_dec1_weekday(numeric_system::standard);
660  break;
661  // Month:
662  case 'b':
663  case 'h':
664  handler.on_abbr_month();
665  break;
666  case 'B':
667  handler.on_full_month();
668  break;
669  case 'm':
670  handler.on_dec_month(numeric_system::standard);
671  break;
672  // Day of the year/month:
673  case 'U':
674  handler.on_dec0_week_of_year(numeric_system::standard);
675  break;
676  case 'W':
677  handler.on_dec1_week_of_year(numeric_system::standard);
678  break;
679  case 'V':
680  handler.on_iso_week_of_year(numeric_system::standard);
681  break;
682  case 'j':
683  handler.on_day_of_year();
684  break;
685  case 'd':
686  handler.on_day_of_month(numeric_system::standard);
687  break;
688  case 'e':
689  handler.on_day_of_month_space(numeric_system::standard);
690  break;
691  // Hour, minute, second:
692  case 'H':
693  handler.on_24_hour(numeric_system::standard);
694  break;
695  case 'I':
696  handler.on_12_hour(numeric_system::standard);
697  break;
698  case 'M':
699  handler.on_minute(numeric_system::standard);
700  break;
701  case 'S':
702  handler.on_second(numeric_system::standard);
703  break;
704  // Other:
705  case 'c':
706  handler.on_datetime(numeric_system::standard);
707  break;
708  case 'x':
709  handler.on_loc_date(numeric_system::standard);
710  break;
711  case 'X':
712  handler.on_loc_time(numeric_system::standard);
713  break;
714  case 'D':
715  handler.on_us_date();
716  break;
717  case 'F':
718  handler.on_iso_date();
719  break;
720  case 'r':
721  handler.on_12_hour_time();
722  break;
723  case 'R':
724  handler.on_24_hour_time();
725  break;
726  case 'T':
727  handler.on_iso_time();
728  break;
729  case 'p':
730  handler.on_am_pm();
731  break;
732  case 'Q':
733  handler.on_duration_value();
734  break;
735  case 'q':
736  handler.on_duration_unit();
737  break;
738  case 'z':
739  handler.on_utc_offset();
740  break;
741  case 'Z':
742  handler.on_tz_name();
743  break;
744  // Alternative representation:
745  case 'E': {
746  if (ptr == end) FMT_THROW(format_error("invalid format"));
747  c = *ptr++;
748  switch (c) {
749  case 'Y':
750  handler.on_year(numeric_system::alternative);
751  break;
752  case 'y':
753  handler.on_offset_year();
754  break;
755  case 'C':
756  handler.on_century(numeric_system::alternative);
757  break;
758  case 'c':
759  handler.on_datetime(numeric_system::alternative);
760  break;
761  case 'x':
762  handler.on_loc_date(numeric_system::alternative);
763  break;
764  case 'X':
765  handler.on_loc_time(numeric_system::alternative);
766  break;
767  default:
768  FMT_THROW(format_error("invalid format"));
769  }
770  break;
771  }
772  case 'O':
773  if (ptr == end) FMT_THROW(format_error("invalid format"));
774  c = *ptr++;
775  switch (c) {
776  case 'y':
777  handler.on_short_year(numeric_system::alternative);
778  break;
779  case 'm':
780  handler.on_dec_month(numeric_system::alternative);
781  break;
782  case 'U':
783  handler.on_dec0_week_of_year(numeric_system::alternative);
784  break;
785  case 'W':
786  handler.on_dec1_week_of_year(numeric_system::alternative);
787  break;
788  case 'V':
789  handler.on_iso_week_of_year(numeric_system::alternative);
790  break;
791  case 'd':
792  handler.on_day_of_month(numeric_system::alternative);
793  break;
794  case 'e':
795  handler.on_day_of_month_space(numeric_system::alternative);
796  break;
797  case 'w':
798  handler.on_dec0_weekday(numeric_system::alternative);
799  break;
800  case 'u':
801  handler.on_dec1_weekday(numeric_system::alternative);
802  break;
803  case 'H':
804  handler.on_24_hour(numeric_system::alternative);
805  break;
806  case 'I':
807  handler.on_12_hour(numeric_system::alternative);
808  break;
809  case 'M':
810  handler.on_minute(numeric_system::alternative);
811  break;
812  case 'S':
813  handler.on_second(numeric_system::alternative);
814  break;
815  default:
816  FMT_THROW(format_error("invalid format"));
817  }
818  break;
819  default:
820  FMT_THROW(format_error("invalid format"));
821  }
822  begin = ptr;
823  }
824  if (begin != ptr) handler.on_text(begin, ptr);
825  return ptr;
826 }
827 
828 template <typename Derived> struct null_chrono_spec_handler {
830  static_cast<Derived*>(this)->unsupported();
831  }
832  FMT_CONSTEXPR void on_year(numeric_system) { unsupported(); }
833  FMT_CONSTEXPR void on_short_year(numeric_system) { unsupported(); }
834  FMT_CONSTEXPR void on_offset_year() { unsupported(); }
835  FMT_CONSTEXPR void on_century(numeric_system) { unsupported(); }
836  FMT_CONSTEXPR void on_iso_week_based_year() { unsupported(); }
837  FMT_CONSTEXPR void on_iso_week_based_short_year() { unsupported(); }
838  FMT_CONSTEXPR void on_abbr_weekday() { unsupported(); }
839  FMT_CONSTEXPR void on_full_weekday() { unsupported(); }
842  FMT_CONSTEXPR void on_abbr_month() { unsupported(); }
843  FMT_CONSTEXPR void on_full_month() { unsupported(); }
844  FMT_CONSTEXPR void on_dec_month(numeric_system) { unsupported(); }
848  FMT_CONSTEXPR void on_day_of_year() { unsupported(); }
851  FMT_CONSTEXPR void on_24_hour(numeric_system) { unsupported(); }
852  FMT_CONSTEXPR void on_12_hour(numeric_system) { unsupported(); }
853  FMT_CONSTEXPR void on_minute(numeric_system) { unsupported(); }
854  FMT_CONSTEXPR void on_second(numeric_system) { unsupported(); }
855  FMT_CONSTEXPR void on_datetime(numeric_system) { unsupported(); }
856  FMT_CONSTEXPR void on_loc_date(numeric_system) { unsupported(); }
857  FMT_CONSTEXPR void on_loc_time(numeric_system) { unsupported(); }
858  FMT_CONSTEXPR void on_us_date() { unsupported(); }
859  FMT_CONSTEXPR void on_iso_date() { unsupported(); }
860  FMT_CONSTEXPR void on_12_hour_time() { unsupported(); }
861  FMT_CONSTEXPR void on_24_hour_time() { unsupported(); }
862  FMT_CONSTEXPR void on_iso_time() { unsupported(); }
863  FMT_CONSTEXPR void on_am_pm() { unsupported(); }
864  FMT_CONSTEXPR void on_duration_value() { unsupported(); }
865  FMT_CONSTEXPR void on_duration_unit() { unsupported(); }
866  FMT_CONSTEXPR void on_utc_offset() { unsupported(); }
867  FMT_CONSTEXPR void on_tz_name() { unsupported(); }
868 };
869 
870 struct tm_format_checker : null_chrono_spec_handler<tm_format_checker> {
871  FMT_NORETURN void unsupported() { FMT_THROW(format_error("no format")); }
872 
873  template <typename Char>
874  FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
909 };
910 
911 inline const char* tm_wday_full_name(int wday) {
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] : "?";
916 }
917 inline const char* tm_wday_short_name(int 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] : "???";
921 }
922 
923 inline const char* tm_mon_full_name(int mon) {
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] : "?";
928 }
929 inline const char* tm_mon_short_name(int mon) {
930  static constexpr const char* short_name_list[] = {
931  "Jan", "Feb", "Mar", "Apr", "May", "Jun",
932  "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
933  };
934  return mon >= 0 && mon <= 11 ? short_name_list[mon] : "???";
935 }
936 
937 template <typename T, typename = void>
938 struct has_member_data_tm_gmtoff : std::false_type {};
939 template <typename T>
940 struct has_member_data_tm_gmtoff<T, void_t<decltype(T::tm_gmtoff)>>
941  : std::true_type {};
942 
943 template <typename T, typename = void>
944 struct has_member_data_tm_zone : std::false_type {};
945 template <typename T>
946 struct has_member_data_tm_zone<T, void_t<decltype(T::tm_zone)>>
947  : std::true_type {};
948 
949 #if FMT_USE_TZSET
950 inline void tzset_once() {
951  static bool init = []() -> bool {
952  _tzset();
953  return true;
954  }();
955  ignore_unused(init);
956 }
957 #endif
958 
959 template <typename OutputIt, typename Char> class tm_writer {
960  private:
961  static constexpr int days_per_week = 7;
962 
963  const std::locale& loc_;
964  const bool is_classic_;
965  OutputIt out_;
966  const std::tm& tm_;
967 
968  auto tm_sec() const noexcept -> int {
969  FMT_ASSERT(tm_.tm_sec >= 0 && tm_.tm_sec <= 61, "");
970  return tm_.tm_sec;
971  }
972  auto tm_min() const noexcept -> int {
973  FMT_ASSERT(tm_.tm_min >= 0 && tm_.tm_min <= 59, "");
974  return tm_.tm_min;
975  }
976  auto tm_hour() const noexcept -> int {
977  FMT_ASSERT(tm_.tm_hour >= 0 && tm_.tm_hour <= 23, "");
978  return tm_.tm_hour;
979  }
980  auto tm_mday() const noexcept -> int {
981  FMT_ASSERT(tm_.tm_mday >= 1 && tm_.tm_mday <= 31, "");
982  return tm_.tm_mday;
983  }
984  auto tm_mon() const noexcept -> int {
985  FMT_ASSERT(tm_.tm_mon >= 0 && tm_.tm_mon <= 11, "");
986  return tm_.tm_mon;
987  }
988  auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }
989  auto tm_wday() const noexcept -> int {
990  FMT_ASSERT(tm_.tm_wday >= 0 && tm_.tm_wday <= 6, "");
991  return tm_.tm_wday;
992  }
993  auto tm_yday() const noexcept -> int {
994  FMT_ASSERT(tm_.tm_yday >= 0 && tm_.tm_yday <= 365, "");
995  return tm_.tm_yday;
996  }
997 
998  auto tm_hour12() const noexcept -> int {
999  const auto h = tm_hour();
1000  const auto z = h < 12 ? h : h - 12;
1001  return z == 0 ? 12 : z;
1002  }
1003 
1004  // POSIX and the C Standard are unclear or inconsistent about what %C and %y
1005  // do if the year is negative or exceeds 9999. Use the convention that %C
1006  // concatenated with %y yields the same output as %Y, and that %Y contains at
1007  // least 4 characters, with more only if necessary.
1008  auto split_year_lower(long long year) const noexcept -> int {
1009  auto l = year % 100;
1010  if (l < 0) l = -l; // l in [0, 99]
1011  return static_cast<int>(l);
1012  }
1013 
1014  // Algorithm:
1015  // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_the_week_number_from_a_month_and_day_of_the_month_or_ordinal_date
1016  auto iso_year_weeks(long long curr_year) const noexcept -> int {
1017  const auto prev_year = curr_year - 1;
1018  const auto curr_p =
1019  (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
1020  days_per_week;
1021  const auto prev_p =
1022  (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
1023  days_per_week;
1024  return 52 + ((curr_p == 4 || prev_p == 3) ? 1 : 0);
1025  }
1026  auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int {
1027  return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /
1028  days_per_week;
1029  }
1030  auto tm_iso_week_year() const noexcept -> long long {
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;
1035  return year;
1036  }
1037  auto tm_iso_week_of_year() const noexcept -> int {
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;
1042  return w;
1043  }
1044 
1045  void write1(int value) {
1046  *out_++ = static_cast<char>('0' + to_unsigned(value) % 10);
1047  }
1048  void write2(int value) {
1049  const char* d = digits2(to_unsigned(value) % 100);
1050  *out_++ = *d++;
1051  *out_++ = *d;
1052  }
1053 
1054  void write_year_extended(long long year) {
1055  // At least 4 characters.
1056  int width = 4;
1057  if (year < 0) {
1058  *out_++ = '-';
1059  year = 0 - year;
1060  --width;
1061  }
1063  const int num_digits = count_digits(n);
1064  if (width > num_digits) out_ = std::fill_n(out_, width - num_digits, '0');
1065  out_ = format_decimal<Char>(out_, n, num_digits).end;
1066  }
1067  void write_year(long long year) {
1068  if (year >= 0 && year < 10000) {
1069  write2(static_cast<int>(year / 100));
1070  write2(static_cast<int>(year % 100));
1071  } else {
1072  write_year_extended(year);
1073  }
1074  }
1075 
1076  void write_utc_offset(long offset) {
1077  if (offset < 0) {
1078  *out_++ = '-';
1079  offset = -offset;
1080  } else {
1081  *out_++ = '+';
1082  }
1083  offset /= 60;
1084  write2(static_cast<int>(offset / 60));
1085  write2(static_cast<int>(offset % 60));
1086  }
1087  template <typename T, FMT_ENABLE_IF(has_member_data_tm_gmtoff<T>::value)>
1088  void format_utc_offset_impl(const T& tm) {
1089  write_utc_offset(tm.tm_gmtoff);
1090  }
1091  template <typename T, FMT_ENABLE_IF(!has_member_data_tm_gmtoff<T>::value)>
1092  void format_utc_offset_impl(const T& tm) {
1093 #if defined(_WIN32) && defined(_UCRT)
1094 # if FMT_USE_TZSET
1095  tzset_once();
1096 # endif
1097  long offset = 0;
1098  _get_timezone(&offset);
1099  if (tm.tm_isdst) {
1100  long dstbias = 0;
1101  _get_dstbias(&dstbias);
1102  offset += dstbias;
1103  }
1104  write_utc_offset(-offset);
1105 #else
1106  ignore_unused(tm);
1107  format_localized('z');
1108 #endif
1109  }
1110 
1111  template <typename T, FMT_ENABLE_IF(has_member_data_tm_zone<T>::value)>
1112  void format_tz_name_impl(const T& tm) {
1113  if (is_classic_)
1114  out_ = write_tm_str<Char>(out_, tm.tm_zone, loc_);
1115  else
1116  format_localized('Z');
1117  }
1118  template <typename T, FMT_ENABLE_IF(!has_member_data_tm_zone<T>::value)>
1119  void format_tz_name_impl(const T&) {
1120  format_localized('Z');
1121  }
1122 
1123  void format_localized(char format, char modifier = 0) {
1124  out_ = write<Char>(out_, tm_, loc_, format, modifier);
1125  }
1126 
1127  public:
1128  tm_writer(const std::locale& loc, OutputIt out, const std::tm& tm)
1129  : loc_(loc),
1130  is_classic_(loc_ == get_classic_locale()),
1131  out_(out),
1132  tm_(tm) {}
1133 
1134  OutputIt out() const { return out_; }
1135 
1136  FMT_CONSTEXPR void on_text(const Char* begin, const Char* end) {
1137  out_ = copy_str<Char>(begin, end, out_);
1138  }
1139 
1141  if (is_classic_)
1142  out_ = write(out_, tm_wday_short_name(tm_wday()));
1143  else
1144  format_localized('a');
1145  }
1147  if (is_classic_)
1148  out_ = write(out_, tm_wday_full_name(tm_wday()));
1149  else
1150  format_localized('A');
1151  }
1153  if (is_classic_ || ns == numeric_system::standard) return write1(tm_wday());
1154  format_localized('w', 'O');
1155  }
1157  if (is_classic_ || ns == numeric_system::standard) {
1158  auto wday = tm_wday();
1159  write1(wday == 0 ? days_per_week : wday);
1160  } else {
1161  format_localized('u', 'O');
1162  }
1163  }
1164 
1165  void on_abbr_month() {
1166  if (is_classic_)
1167  out_ = write(out_, tm_mon_short_name(tm_mon()));
1168  else
1169  format_localized('b');
1170  }
1171  void on_full_month() {
1172  if (is_classic_)
1173  out_ = write(out_, tm_mon_full_name(tm_mon()));
1174  else
1175  format_localized('B');
1176  }
1177 
1179  if (is_classic_) {
1180  on_abbr_weekday();
1181  *out_++ = ' ';
1182  on_abbr_month();
1183  *out_++ = ' ';
1184  on_day_of_month_space(numeric_system::standard);
1185  *out_++ = ' ';
1186  on_iso_time();
1187  *out_++ = ' ';
1188  on_year(numeric_system::standard);
1189  } else {
1190  format_localized('c', ns == numeric_system::standard ? '\0' : 'E');
1191  }
1192  }
1194  if (is_classic_)
1195  on_us_date();
1196  else
1197  format_localized('x', ns == numeric_system::standard ? '\0' : 'E');
1198  }
1200  if (is_classic_)
1201  on_iso_time();
1202  else
1203  format_localized('X', ns == numeric_system::standard ? '\0' : 'E');
1204  }
1205  void on_us_date() {
1206  char buf[8];
1207  write_digit2_separated(buf, to_unsigned(tm_mon() + 1),
1208  to_unsigned(tm_mday()),
1209  to_unsigned(split_year_lower(tm_year())), '/');
1210  out_ = copy_str<Char>(std::begin(buf), std::end(buf), out_);
1211  }
1212  void on_iso_date() {
1213  auto year = tm_year();
1214  char buf[10];
1215  size_t offset = 0;
1216  if (year >= 0 && year < 10000) {
1217  copy2(buf, digits2(to_unsigned(year / 100)));
1218  } else {
1219  offset = 4;
1220  write_year_extended(year);
1221  year = 0;
1222  }
1223  write_digit2_separated(buf + 2, static_cast<unsigned>(year % 100),
1224  to_unsigned(tm_mon() + 1), to_unsigned(tm_mday()),
1225  '-');
1226  out_ = copy_str<Char>(std::begin(buf) + offset, std::end(buf), out_);
1227  }
1228 
1229  void on_utc_offset() { format_utc_offset_impl(tm_); }
1230  void on_tz_name() { format_tz_name_impl(tm_); }
1231 
1233  if (is_classic_ || ns == numeric_system::standard)
1234  return write_year(tm_year());
1235  format_localized('Y', 'E');
1236  }
1238  if (is_classic_ || ns == numeric_system::standard)
1239  return write2(split_year_lower(tm_year()));
1240  format_localized('y', 'O');
1241  }
1243  if (is_classic_) return write2(split_year_lower(tm_year()));
1244  format_localized('y', 'E');
1245  }
1246 
1248  if (is_classic_ || ns == numeric_system::standard) {
1249  auto year = tm_year();
1250  auto upper = year / 100;
1251  if (year >= -99 && year < 0) {
1252  // Zero upper on negative year.
1253  *out_++ = '-';
1254  *out_++ = '0';
1255  } else if (upper >= 0 && upper < 100) {
1256  write2(static_cast<int>(upper));
1257  } else {
1258  out_ = write<Char>(out_, upper);
1259  }
1260  } else {
1261  format_localized('C', 'E');
1262  }
1263  }
1264 
1266  if (is_classic_ || ns == numeric_system::standard)
1267  return write2(tm_mon() + 1);
1268  format_localized('m', 'O');
1269  }
1270 
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');
1275  }
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))) /
1281  days_per_week);
1282  } else {
1283  format_localized('W', 'O');
1284  }
1285  }
1287  if (is_classic_ || ns == numeric_system::standard)
1288  return write2(tm_iso_week_of_year());
1289  format_localized('V', 'O');
1290  }
1291 
1292  void on_iso_week_based_year() { write_year(tm_iso_week_year()); }
1294  write2(split_year_lower(tm_iso_week_year()));
1295  }
1296 
1298  auto yday = tm_yday() + 1;
1299  write1(yday / 100);
1300  write2(yday % 100);
1301  }
1303  if (is_classic_ || ns == numeric_system::standard) return write2(tm_mday());
1304  format_localized('d', 'O');
1305  }
1307  if (is_classic_ || ns == numeric_system::standard) {
1308  auto mday = to_unsigned(tm_mday()) % 100;
1309  const char* d2 = digits2(mday);
1310  *out_++ = mday < 10 ? ' ' : d2[0];
1311  *out_++ = d2[1];
1312  } else {
1313  format_localized('e', 'O');
1314  }
1315  }
1316 
1318  if (is_classic_ || ns == numeric_system::standard) return write2(tm_hour());
1319  format_localized('H', 'O');
1320  }
1322  if (is_classic_ || ns == numeric_system::standard)
1323  return write2(tm_hour12());
1324  format_localized('I', 'O');
1325  }
1327  if (is_classic_ || ns == numeric_system::standard) return write2(tm_min());
1328  format_localized('M', 'O');
1329  }
1331  if (is_classic_ || ns == numeric_system::standard) return write2(tm_sec());
1332  format_localized('S', 'O');
1333  }
1334 
1336  if (is_classic_) {
1337  char buf[8];
1338  write_digit2_separated(buf, to_unsigned(tm_hour12()),
1339  to_unsigned(tm_min()), to_unsigned(tm_sec()), ':');
1340  out_ = copy_str<Char>(std::begin(buf), std::end(buf), out_);
1341  *out_++ = ' ';
1342  on_am_pm();
1343  } else {
1344  format_localized('r');
1345  }
1346  }
1348  write2(tm_hour());
1349  *out_++ = ':';
1350  write2(tm_min());
1351  }
1352  void on_iso_time() {
1353  char buf[8];
1354  write_digit2_separated(buf, to_unsigned(tm_hour()), to_unsigned(tm_min()),
1355  to_unsigned(tm_sec()), ':');
1356  out_ = copy_str<Char>(std::begin(buf), std::end(buf), out_);
1357  }
1358 
1359  void on_am_pm() {
1360  if (is_classic_) {
1361  *out_++ = tm_hour() < 12 ? 'A' : 'P';
1362  *out_++ = 'M';
1363  } else {
1364  format_localized('p');
1365  }
1366  }
1367 
1368  // These apply to chrono durations but not tm.
1371 };
1372 
1373 struct chrono_format_checker : null_chrono_spec_handler<chrono_format_checker> {
1375 
1376  template <typename Char>
1377  FMT_CONSTEXPR void on_text(const Char*, const Char*) {}
1388 };
1389 
1390 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
1391 inline bool isnan(T) {
1392  return false;
1393 }
1394 template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
1395 inline bool isnan(T value) {
1396  return std::isnan(value);
1397 }
1398 
1399 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
1400 inline bool isfinite(T) {
1401  return true;
1402 }
1403 
1404 // Converts value to Int and checks that it's in the range [0, upper).
1405 template <typename T, typename Int, FMT_ENABLE_IF(std::is_integral<T>::value)>
1406 inline Int to_nonnegative_int(T value, Int upper) {
1407  FMT_ASSERT(value >= 0 && to_unsigned(value) <= to_unsigned(upper),
1408  "invalid value");
1409  (void)upper;
1410  return static_cast<Int>(value);
1411 }
1412 template <typename T, typename Int, FMT_ENABLE_IF(!std::is_integral<T>::value)>
1413 inline Int to_nonnegative_int(T value, Int upper) {
1414  if (value < 0 || value > static_cast<T>(upper))
1415  FMT_THROW(format_error("invalid value"));
1416  return static_cast<Int>(value);
1417 }
1418 
1419 template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
1420 inline T mod(T x, int y) {
1421  return x % static_cast<T>(y);
1422 }
1423 template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
1424 inline T mod(T x, int y) {
1425  return std::fmod(x, static_cast<T>(y));
1426 }
1427 
1428 // If T is an integral type, maps T to its unsigned counterpart, otherwise
1429 // leaves it unchanged (unlike std::make_unsigned).
1432  using type = T;
1433 };
1434 
1435 template <typename T> struct make_unsigned_or_unchanged<T, true> {
1437 };
1438 
1439 #if FMT_SAFE_DURATION_CAST
1440 // throwing version of safe_duration_cast
1441 template <typename To, typename FromRep, typename FromPeriod>
1442 To fmt_safe_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) {
1443  int ec;
1444  To to = safe_duration_cast::safe_duration_cast<To>(from, ec);
1445  if (ec) FMT_THROW(format_error("cannot format duration"));
1446  return to;
1447 }
1448 #endif
1449 
1450 template <typename Rep, typename Period,
1452 inline std::chrono::duration<Rep, std::milli> get_milliseconds(
1453  std::chrono::duration<Rep, Period> d) {
1454  // this may overflow and/or the result may not fit in the
1455  // target type.
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);
1462  // this conversion should be nonproblematic
1463  const auto diff = d_as_common - d_as_whole_seconds;
1464  const auto ms =
1465  fmt_safe_duration_cast<std::chrono::duration<Rep, std::milli>>(diff);
1466  return ms;
1467 #else
1468  auto s = std::chrono::duration_cast<std::chrono::seconds>(d);
1469  return std::chrono::duration_cast<std::chrono::milliseconds>(d - s);
1470 #endif
1471 }
1472 
1473 // Returns the number of fractional digits in the range [0, 18] according to the
1474 // C++20 spec. If more than 18 fractional digits are required then returns 6 for
1475 // microseconds precision.
1476 constexpr int count_fractional_digits(long long num, long long den, int n = 0) {
1477  return num % den == 0
1478  ? n
1479  : (n > 18 ? 6 : count_fractional_digits(num * 10, den, n + 1));
1480 }
1481 
1482 constexpr long long pow10(std::uint32_t n) {
1483  return n == 0 ? 1 : 10 * pow10(n - 1);
1484 }
1485 
1486 template <class Rep, class Period,
1488 constexpr std::chrono::duration<Rep, Period> abs(
1489  std::chrono::duration<Rep, Period> d) {
1490  // We need to compare the duration using the count() method directly
1491  // due to a compiler bug in clang-11 regarding the spaceship operator,
1492  // when -Wzero-as-null-pointer-constant is enabled.
1493  // In clang-12 the bug has been fixed. See
1494  // https://bugs.llvm.org/show_bug.cgi?id=46235 and the reproducible example:
1495  // https://www.godbolt.org/z/Knbb5joYx.
1496  return d.count() >= d.zero().count() ? d : -d;
1497 }
1498 
1499 template <class Rep, class Period,
1501 constexpr std::chrono::duration<Rep, Period> abs(
1502  std::chrono::duration<Rep, Period> d) {
1503  return d;
1504 }
1505 
1506 template <typename Char, typename Rep, typename OutputIt,
1508 OutputIt format_duration_value(OutputIt out, Rep val, int) {
1509  return write<Char>(out, val);
1510 }
1511 
1512 template <typename Char, typename Rep, typename OutputIt,
1514 OutputIt format_duration_value(OutputIt out, Rep val, int precision) {
1515  auto specs = basic_format_specs<Char>();
1516  specs.precision = precision;
1517  specs.type = precision >= 0 ? presentation_type::fixed_lower
1518  : presentation_type::general_lower;
1519  return write<Char>(out, val, specs);
1520 }
1521 
1522 template <typename Char, typename OutputIt>
1523 OutputIt copy_unit(string_view unit, OutputIt out, Char) {
1524  return std::copy(unit.begin(), unit.end(), out);
1525 }
1526 
1527 template <typename OutputIt>
1528 OutputIt copy_unit(string_view unit, OutputIt out, wchar_t) {
1529  // This works when wchar_t is UTF-32 because units only contain characters
1530  // that have the same representation in UTF-16 and UTF-32.
1531  utf8_to_utf16 u(unit);
1532  return std::copy(u.c_str(), u.c_str() + u.size(), out);
1533 }
1534 
1535 template <typename Char, typename Period, typename OutputIt>
1536 OutputIt format_duration_unit(OutputIt out) {
1537  if (const char* unit = get_units<Period>())
1538  return copy_unit(string_view(unit), out, Char());
1539  *out++ = '[';
1540  out = write<Char>(out, Period::num);
1541  if (const_check(Period::den != 1)) {
1542  *out++ = '/';
1543  out = write<Char>(out, Period::den);
1544  }
1545  *out++ = ']';
1546  *out++ = 's';
1547  return out;
1548 }
1549 
1550 class get_locale {
1551  private:
1552  union {
1553  std::locale locale_;
1554  };
1555  bool has_locale_ = false;
1556 
1557  public:
1558  get_locale(bool localized, locale_ref loc) : has_locale_(localized) {
1559  if (localized)
1560  ::new (&locale_) std::locale(loc.template get<std::locale>());
1561  }
1563  if (has_locale_) locale_.~locale();
1564  }
1565  operator const std::locale&() const {
1566  return has_locale_ ? locale_ : get_classic_locale();
1567  }
1568 };
1569 
1570 template <typename FormatContext, typename OutputIt, typename Rep,
1571  typename Period>
1573  FormatContext& context;
1574  OutputIt out;
1576  bool localized = false;
1577  // rep is unsigned to avoid overflow.
1578  using rep =
1579  conditional_t<std::is_integral<Rep>::value && sizeof(Rep) < sizeof(int),
1582  using seconds = std::chrono::duration<rep>;
1584  using milliseconds = std::chrono::duration<rep, std::milli>;
1585  bool negative;
1586 
1587  using char_type = typename FormatContext::char_type;
1589 
1590  chrono_formatter(FormatContext& ctx, OutputIt o,
1591  std::chrono::duration<Rep, Period> d)
1592  : context(ctx),
1593  out(o),
1594  val(static_cast<rep>(d.count())),
1595  negative(false) {
1596  if (d.count() < 0) {
1597  val = 0 - val;
1598  negative = true;
1599  }
1600 
1601  // this may overflow and/or the result may not fit in the
1602  // target type.
1603 #if FMT_SAFE_DURATION_CAST
1604  // might need checked conversion (rep!=Rep)
1605  auto tmpval = std::chrono::duration<rep, Period>(val);
1606  s = fmt_safe_duration_cast<seconds>(tmpval);
1607 #else
1608  s = std::chrono::duration_cast<seconds>(
1609  std::chrono::duration<rep, Period>(val));
1610 #endif
1611  }
1612 
1613  // returns true if nan or inf, writes to out.
1615  if (isfinite(val)) {
1616  return false;
1617  }
1618  if (isnan(val)) {
1619  write_nan();
1620  return true;
1621  }
1622  // must be +-inf
1623  if (val > 0) {
1624  write_pinf();
1625  } else {
1626  write_ninf();
1627  }
1628  return true;
1629  }
1630 
1631  Rep hour() const { return static_cast<Rep>(mod((s.count() / 3600), 24)); }
1632 
1633  Rep hour12() const {
1634  Rep hour = static_cast<Rep>(mod((s.count() / 3600), 12));
1635  return hour <= 0 ? 12 : hour;
1636  }
1637 
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)); }
1640 
1641  std::tm time() const {
1642  auto time = std::tm();
1643  time.tm_hour = to_nonnegative_int(hour(), 24);
1644  time.tm_min = to_nonnegative_int(minute(), 60);
1645  time.tm_sec = to_nonnegative_int(second(), 60);
1646  return time;
1647  }
1648 
1649  void write_sign() {
1650  if (negative) {
1651  *out++ = '-';
1652  negative = false;
1653  }
1654  }
1655 
1656  void write(Rep value, int width) {
1657  write_sign();
1658  if (isnan(value)) return write_nan();
1660  to_unsigned(to_nonnegative_int(value, max_value<int>()));
1661  int num_digits = detail::count_digits(n);
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;
1664  }
1665 
1666  template <class Duration> void write_fractional_seconds(Duration d) {
1667  constexpr auto num_fractional_digits =
1668  count_fractional_digits(Duration::period::num, Duration::period::den);
1669 
1670  using subsecond_precision = std::chrono::duration<
1671  typename std::common_type<typename Duration::rep,
1672  std::chrono::seconds::rep>::type,
1673  std::ratio<1, detail::pow10(num_fractional_digits)>>;
1674  if (std::ratio_less<typename subsecond_precision::period,
1675  std::chrono::seconds::period>::value) {
1676  *out++ = '.';
1677  // Don't convert long double to integer seconds to avoid overflow.
1678  using sec = conditional_t<
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)
1687  .count();
1689  to_unsigned(to_nonnegative_int(subseconds, max_value<long long>()));
1690  int num_digits = detail::count_digits(n);
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;
1694  }
1695  }
1696 
1697  void write_nan() { std::copy_n("nan", 3, out); }
1698  void write_pinf() { std::copy_n("inf", 3, out); }
1699  void write_ninf() { std::copy_n("-inf", 4, out); }
1700 
1701  template <typename Callback, typename... Args>
1702  void format_tm(const tm& time, Callback cb, Args... args) {
1703  if (isnan(val)) return write_nan();
1704  get_locale loc(localized, context.locale());
1705  auto w = tm_writer_type(loc, out, time);
1706  (w.*cb)(args...);
1707  out = w.out();
1708  }
1709 
1710  void on_text(const char_type* begin, const char_type* end) {
1711  std::copy(begin, end, out);
1712  }
1713 
1714  // These are not implemented because durations don't have date information.
1719  void on_abbr_month() {}
1720  void on_full_month() {}
1724  void on_us_date() {}
1725  void on_iso_date() {}
1726  void on_utc_offset() {}
1727  void on_tz_name() {}
1730  void on_offset_year() {}
1738  void on_day_of_year() {}
1741 
1743  if (handle_nan_inf()) return;
1744 
1745  if (ns == numeric_system::standard) return write(hour(), 2);
1746  auto time = tm();
1747  time.tm_hour = to_nonnegative_int(hour(), 24);
1748  format_tm(time, &tm_writer_type::on_24_hour, ns);
1749  }
1750 
1752  if (handle_nan_inf()) return;
1753 
1754  if (ns == numeric_system::standard) return write(hour12(), 2);
1755  auto time = tm();
1756  time.tm_hour = to_nonnegative_int(hour12(), 12);
1757  format_tm(time, &tm_writer_type::on_12_hour, ns);
1758  }
1759 
1761  if (handle_nan_inf()) return;
1762 
1763  if (ns == numeric_system::standard) return write(minute(), 2);
1764  auto time = tm();
1765  time.tm_min = to_nonnegative_int(minute(), 60);
1766  format_tm(time, &tm_writer_type::on_minute, ns);
1767  }
1768 
1770  if (handle_nan_inf()) return;
1771 
1772  if (ns == numeric_system::standard) {
1773  write(second(), 2);
1774  write_fractional_seconds(std::chrono::duration<rep, Period>{val});
1775  return;
1776  }
1777  auto time = tm();
1778  time.tm_sec = to_nonnegative_int(second(), 60);
1779  format_tm(time, &tm_writer_type::on_second, ns);
1780  }
1781 
1783  if (handle_nan_inf()) return;
1784  format_tm(time(), &tm_writer_type::on_12_hour_time);
1785  }
1786 
1788  if (handle_nan_inf()) {
1789  *out++ = ':';
1790  handle_nan_inf();
1791  return;
1792  }
1793 
1794  write(hour(), 2);
1795  *out++ = ':';
1796  write(minute(), 2);
1797  }
1798 
1799  void on_iso_time() {
1800  on_24_hour_time();
1801  *out++ = ':';
1802  if (handle_nan_inf()) return;
1803  on_second(numeric_system::standard);
1804  }
1805 
1806  void on_am_pm() {
1807  if (handle_nan_inf()) return;
1808  format_tm(time(), &tm_writer_type::on_am_pm);
1809  }
1810 
1812  if (handle_nan_inf()) return;
1813  write_sign();
1814  out = format_duration_value<char_type>(out, val, precision);
1815  }
1816 
1818  out = format_duration_unit<char_type, Period>(out);
1819  }
1820 };
1821 
1823 
1824 #if defined(__cpp_lib_chrono) && __cpp_lib_chrono >= 201907
1825 using weekday = std::chrono::weekday;
1826 #else
1827 // A fallback version of weekday.
1828 class weekday {
1829  private:
1830  unsigned char value;
1831 
1832  public:
1833  weekday() = default;
1834  explicit constexpr weekday(unsigned wd) noexcept
1835  : value(static_cast<unsigned char>(wd != 7 ? wd : 0)) {}
1836  constexpr unsigned c_encoding() const noexcept { return value; }
1837 };
1838 
1840 #endif
1841 
1842 // A rudimentary weekday formatter.
1843 template <typename Char> struct formatter<weekday, Char> {
1844  private:
1845  bool localized = false;
1846 
1847  public:
1849  -> decltype(ctx.begin()) {
1850  auto begin = ctx.begin(), end = ctx.end();
1851  if (begin != end && *begin == 'L') {
1852  ++begin;
1853  localized = true;
1854  }
1855  return begin;
1856  }
1857 
1858  template <typename FormatContext>
1859  auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {
1860  auto time = std::tm();
1861  time.tm_wday = static_cast<int>(wd.c_encoding());
1862  detail::get_locale loc(localized, ctx.locale());
1863  auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), time);
1864  w.on_abbr_weekday();
1865  return w.out();
1866  }
1867 };
1868 
1869 template <typename Rep, typename Period, typename Char>
1870 struct formatter<std::chrono::duration<Rep, Period>, Char> {
1871  private:
1873  int precision = -1;
1877  bool localized = false;
1879  using duration = std::chrono::duration<Rep, Period>;
1880 
1881  struct spec_handler {
1885 
1886  template <typename Id> FMT_CONSTEXPR arg_ref_type make_arg_ref(Id arg_id) {
1887  context.check_arg_id(arg_id);
1888  return arg_ref_type(arg_id);
1889  }
1890 
1892  context.check_arg_id(arg_id);
1893  return arg_ref_type(arg_id);
1894  }
1895 
1897  return arg_ref_type(context.next_arg_id());
1898  }
1899 
1900  void on_error(const char* msg) { FMT_THROW(format_error(msg)); }
1902  f.specs.fill = fill;
1903  }
1904  FMT_CONSTEXPR void on_align(align_t align) { f.specs.align = align; }
1905  FMT_CONSTEXPR void on_width(int width) { f.specs.width = width; }
1906  FMT_CONSTEXPR void on_precision(int _precision) {
1907  f.precision = _precision;
1908  }
1910 
1911  template <typename Id> FMT_CONSTEXPR void on_dynamic_width(Id arg_id) {
1912  f.width_ref = make_arg_ref(arg_id);
1913  }
1914 
1915  template <typename Id> FMT_CONSTEXPR void on_dynamic_precision(Id arg_id) {
1916  f.precision_ref = make_arg_ref(arg_id);
1917  }
1918  };
1919 
1921  struct parse_range {
1924  };
1925 
1927  auto begin = ctx.begin(), end = ctx.end();
1928  if (begin == end || *begin == '}') return {begin, begin};
1929  spec_handler handler{*this, ctx, format_str};
1930  begin = detail::parse_align(begin, end, handler);
1931  if (begin == end) return {begin, begin};
1932  begin = detail::parse_width(begin, end, handler);
1933  if (begin == end) return {begin, begin};
1934  if (*begin == '.') {
1936  begin = detail::parse_precision(begin, end, handler);
1937  else
1938  handler.on_error("precision not allowed for this argument type");
1939  }
1940  if (begin != end && *begin == 'L') {
1941  ++begin;
1942  localized = true;
1943  }
1946  return {begin, end};
1947  }
1948 
1949  public:
1951  -> decltype(ctx.begin()) {
1952  auto range = do_parse(ctx);
1953  format_str = basic_string_view<Char>(
1954  &*range.begin, detail::to_unsigned(range.end - range.begin));
1955  return range.end;
1956  }
1957 
1958  template <typename FormatContext>
1959  auto format(const duration& d, FormatContext& ctx) const
1960  -> decltype(ctx.out()) {
1961  auto specs_copy = specs;
1962  auto precision_copy = precision;
1963  auto begin = format_str.begin(), end = format_str.end();
1964  // As a possible future optimization, we could avoid extra copying if width
1965  // is not specified.
1967  auto out = std::back_inserter(buf);
1968  detail::handle_dynamic_spec<detail::width_checker>(specs_copy.width,
1969  width_ref, ctx);
1970  detail::handle_dynamic_spec<detail::precision_checker>(precision_copy,
1971  precision_ref, ctx);
1972  if (begin == end || *begin == '}') {
1973  out = detail::format_duration_value<Char>(out, d.count(), precision_copy);
1974  detail::format_duration_unit<Char, Period>(out);
1975  } else {
1976  detail::chrono_formatter<FormatContext, decltype(out), Rep, Period> f(
1977  ctx, out, d);
1978  f.precision = precision_copy;
1979  f.localized = localized;
1981  }
1982  return detail::write(
1983  ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs_copy);
1984  }
1985 };
1986 
1987 template <typename Char, typename Duration>
1988 struct formatter<std::chrono::time_point<std::chrono::system_clock, Duration>,
1989  Char> : formatter<std::tm, Char> {
1991  this->do_parse(default_specs,
1992  default_specs + sizeof(default_specs) / sizeof(Char));
1993  }
1994 
1995  template <typename ParseContext>
1996  FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
1997  return this->do_parse(ctx.begin(), ctx.end(), true);
1998  }
1999 
2000  template <typename FormatContext>
2001  auto format(std::chrono::time_point<std::chrono::system_clock> val,
2002  FormatContext& ctx) const -> decltype(ctx.out()) {
2003  return formatter<std::tm, Char>::format(localtime(val), ctx);
2004  }
2005 
2006  static constexpr const Char default_specs[] = {'%', 'F', ' ', '%', 'T'};
2007 };
2008 
2009 template <typename Char, typename Duration>
2010 constexpr const Char
2012  Char>::default_specs[];
2013 
2014 template <typename Char> struct formatter<std::tm, Char> {
2015  private:
2016  enum class spec {
2017  unknown,
2019  hh_mm_ss,
2020  };
2021  spec spec_ = spec::unknown;
2023 
2024  protected:
2025  template <typename It>
2026  FMT_CONSTEXPR auto do_parse(It begin, It end, bool with_default = false)
2027  -> It {
2028  if (begin != end && *begin == ':') ++begin;
2030  if (!with_default || end != begin)
2031  specs = {begin, detail::to_unsigned(end - begin)};
2032  // basic_string_view<>::compare isn't constexpr before C++17.
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;
2038  }
2039  return end;
2040  }
2041 
2042  public:
2043  template <typename ParseContext>
2044  FMT_CONSTEXPR auto parse(ParseContext& ctx) -> decltype(ctx.begin()) {
2045  return this->do_parse(ctx.begin(), ctx.end());
2046  }
2047 
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();
2052  detail::get_locale loc(static_cast<bool>(loc_ref), loc_ref);
2053  auto w = detail::tm_writer<decltype(ctx.out()), Char>(loc, ctx.out(), tm);
2054  if (spec_ == spec::year_month_day)
2055  w.on_iso_date();
2056  else if (spec_ == spec::hh_mm_ss)
2057  w.on_iso_time();
2058  else
2059  detail::parse_chrono_format(specs.begin(), specs.end(), w);
2060  return w.out();
2061  }
2062 };
2063 
2066 
2067 #endif // FMT_CHRONO_H_
fmt::v8::detail::tm_writer::on_iso_date
void on_iso_date()
Definition: chrono.h:1212
fmt::v8::detail::chrono_formatter::on_iso_week_based_year
void on_iso_week_based_year()
Definition: chrono.h:1732
fmt::v8::detail::chrono_format_checker::unsupported
void unsupported()
Definition: chrono.h:1374
fmt::v8::detail::write_digit2_separated
void write_digit2_separated(char *buf, unsigned a, unsigned b, unsigned c, char sep)
Definition: chrono.h:541
fmt::v8::detail::chrono_formatter::on_full_weekday
void on_full_weekday()
Definition: chrono.h:1716
fmt::v8::detail::tm_format_checker::on_full_weekday
void on_full_weekday()
Definition: chrono.h:882
fmt::v8::detail::null_chrono_spec_handler::on_iso_week_based_short_year
void on_iso_week_based_short_year()
Definition: chrono.h:837
fmt::v8::detail::tm_format_checker::on_loc_date
void on_loc_date(numeric_system)
Definition: chrono.h:899
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::format_str
basic_string_view< Char > format_str
Definition: chrono.h:1884
fmt::v8::detail::tm_writer::tm_mday
auto tm_mday() const noexcept -> int
Definition: chrono.h:980
fmt::v8::detail::chrono_formatter::on_dec1_weekday
void on_dec1_weekday(numeric_system)
Definition: chrono.h:1718
fmt::v8::detail::chrono_formatter::val
rep val
Definition: chrono.h:1581
fmt::v8::detail::isinf
bool isinf(T value)
Definition: format.h:1941
fmt::v8::string_view
basic_string_view< char > string_view
Definition: core.h:540
fmt::v8::detail::chrono_formatter::milliseconds
std::chrono::duration< rep, std::milli > milliseconds
Definition: chrono.h:1584
fmt::v8::detail::chrono_formatter::precision
int precision
Definition: chrono.h:1575
fmt::v8::basic_format_parse_context< Char >
fmt::v8::detail::tm_format_checker::on_iso_week_based_short_year
void on_iso_week_based_short_year()
Definition: chrono.h:880
fmt::v8::detail::tm_writer::on_year
void on_year(numeric_system ns)
Definition: chrono.h:1232
fmt::v8::detail::chrono_formatter::chrono_formatter
chrono_formatter(FormatContext &ctx, OutputIt o, std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1590
fmt::v8::detail::chrono_formatter::on_duration_unit
void on_duration_unit()
Definition: chrono.h:1817
fmt::v8::detail::digits2
constexpr const char * digits2(size_t value)
Definition: format.h:919
fmt::v8::detail::ignore_unused
void ignore_unused(const T &...)
Definition: core.h:352
fmt::v8::detail::null_chrono_spec_handler::on_24_hour_time
void on_24_hour_time()
Definition: chrono.h:861
fmt::v8::detail::null_chrono_spec_handler::on_duration_value
void on_duration_value()
Definition: chrono.h:864
fmt::v8::detail::parse_align
auto parse_align(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2300
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_precision
void on_precision(int _precision)
Definition: chrono.h:1906
fmt::v8::detail::chrono_formatter::minute
Rep minute() const
Definition: chrono.h:1638
fmt::v8::detail::chrono_format_checker::on_duration_unit
void on_duration_unit()
Definition: chrono.h:1387
fmt::v8::detail::isnan
bool isnan(T)
Definition: chrono.h:1391
fmt::v8::detail::get_locale
Definition: chrono.h:1550
fmt::v8::detail::chrono_formatter::negative
bool negative
Definition: chrono.h:1585
fmt::v8::detail::null_chrono_spec_handler::on_iso_week_based_year
void on_iso_week_based_year()
Definition: chrono.h:836
fmt::v8::detail::chrono_formatter::s
seconds s
Definition: chrono.h:1583
fmt::v8::detail::tm_format_checker::on_century
void on_century(numeric_system)
Definition: chrono.h:878
fmt::v8::detail::get_milliseconds
std::chrono::duration< Rep, std::milli > get_milliseconds(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1452
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_error
void on_error(const char *msg)
Definition: chrono.h:1900
fmt::v8::detail::tm_writer::on_datetime
void on_datetime(numeric_system ns)
Definition: chrono.h:1178
fmt::v8::detail::tm_format_checker::on_year
void on_year(numeric_system)
Definition: chrono.h:875
fmt::v8::detail::tm_format_checker::on_dec0_weekday
void on_dec0_weekday(numeric_system)
Definition: chrono.h:883
fmt::v8::detail::parse_chrono_format
const Char * parse_chrono_format(const Char *begin, const Char *end, Handler &&handler)
Definition: chrono.h:603
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_fill
void on_fill(basic_string_view< Char > fill)
Definition: chrono.h:1901
mm_gui.w
w
Definition: mm_gui.py:119
fmt::v8::detail::gmtime_s
null gmtime_s(...)
Definition: chrono.h:306
fmt::v8::detail::tm_writer::out_
OutputIt out_
Definition: chrono.h:965
fmt::v8::basic_format_parse_context::check_arg_id
void check_arg_id(int)
Definition: core.h:683
fmt::v8::detail::tm_writer::on_iso_week_of_year
void on_iso_week_of_year(numeric_system ns)
Definition: chrono.h:1286
fmt::v8::basic_format_parse_context::end
constexpr auto end() const -> iterator
Definition: core.h:658
fmt::v8::detail::tm_writer::on_12_hour
void on_12_hour(numeric_system ns)
Definition: chrono.h:1321
fmt::v8::detail::write_codecvt
void write_codecvt(codecvt_result< CodeUnit > &out, string_view in_buf, const std::locale &loc)
Definition: chrono.h:322
fmt::v8::detail::has_member_data_tm_gmtoff
Definition: chrono.h:938
fmt::v8::detail::tm_writer::tm_iso_week_of_year
auto tm_iso_week_of_year() const noexcept -> int
Definition: chrono.h:1037
fmt::v8::detail::write
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:425
fmt::v8::detail::chrono_formatter
Definition: chrono.h:1572
fmt::v8::detail::void_t
void void_t
Definition: core.h:1641
fmt::v8::detail::tm_writer::on_text
void on_text(const Char *begin, const Char *end)
Definition: chrono.h:1136
fmt::v8::detail::tm_writer::on_duration_unit
void on_duration_unit()
Definition: chrono.h:1370
fmt::v8::detail::copy_unit
OutputIt copy_unit(string_view unit, OutputIt out, wchar_t)
Definition: chrono.h:1528
fmt::v8::detail::tm_format_checker
Definition: chrono.h:870
fmt::v8::detail::chrono_formatter::write_pinf
void write_pinf()
Definition: chrono.h:1698
fmt::v8::detail::chrono_formatter::context
FormatContext & context
Definition: chrono.h:1573
fmt::v8::detail::null_chrono_spec_handler::on_utc_offset
void on_utc_offset()
Definition: chrono.h:866
fmt::v8::detail::tm_writer::iso_week_num
auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int
Definition: chrono.h:1026
fmt::v8::formatter< std::tm, Char >::spec
spec
Definition: chrono.h:2016
fmt::v8::detail::chrono_formatter::on_iso_week_based_short_year
void on_iso_week_based_short_year()
Definition: chrono.h:1733
fmt::v8::localtime
std::tm localtime(std::chrono::time_point< std::chrono::system_clock > time_point)
Definition: chrono.h:486
fmt::v8::detail::chrono_formatter::time
std::tm time() const
Definition: chrono.h:1641
fmt::v8::detail::null_chrono_spec_handler::on_dec0_weekday
void on_dec0_weekday(numeric_system)
Definition: chrono.h:840
fmt::v8::year_month_day
Definition: chrono.h:1839
fmt::v8::detail::chrono_formatter::on_abbr_weekday
void on_abbr_weekday()
Definition: chrono.h:1715
fmt::v8::detail::null_chrono_spec_handler::on_dec_month
void on_dec_month(numeric_system)
Definition: chrono.h:844
fmt::v8::detail::tm_format_checker::on_24_hour
void on_24_hour(numeric_system)
Definition: chrono.h:894
fmt::v8::detail::tm_format_checker::on_day_of_month_space
void on_day_of_month_space(numeric_system)
Definition: chrono.h:893
fmt::v8::detail::uint32_or_64_or_128_t
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
fmt::v8::detail::tm_format_checker::on_text
void on_text(const Char *, const Char *)
Definition: chrono.h:874
Catch::Generators::value
GeneratorWrapper< T > value(T &&value)
Definition: catch.hpp:3999
fmt::v8::detail::tm_writer::is_classic_
const bool is_classic_
Definition: chrono.h:964
fmt::v8::detail::is_utf8
constexpr auto is_utf8() -> bool
Definition: core.h:432
fmt::v8::detail::chrono_formatter::on_day_of_year
void on_day_of_year()
Definition: chrono.h:1738
fmt::v8::detail::tm_writer::tm_wday
auto tm_wday() const noexcept -> int
Definition: chrono.h:989
fmt::v8::detail::numeric_system::alternative
@ alternative
fmt::v8::detail::chrono_formatter::on_datetime
void on_datetime(numeric_system)
Definition: chrono.h:1721
fmt::v8::detail::null_chrono_spec_handler::on_day_of_month_space
void on_day_of_month_space(numeric_system)
Definition: chrono.h:850
fmt::v8::detail::chrono_format_checker::on_am_pm
void on_am_pm()
Definition: chrono.h:1385
fmt::v8::detail::tm_writer::write_year
void write_year(long long year)
Definition: chrono.h:1067
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::do_parse
parse_range do_parse(basic_format_parse_context< Char > &ctx)
Definition: chrono.h:1926
format.h
fmt::v8::detail::chrono_formatter::on_day_of_month
void on_day_of_month(numeric_system)
Definition: chrono.h:1739
fmt::v8::detail::chrono_formatter::write_nan
void write_nan()
Definition: chrono.h:1697
FMT_NOMACRO
#define FMT_NOMACRO
Definition: chrono.h:299
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::parse
auto parse(basic_format_parse_context< Char > &ctx) -> decltype(ctx.begin())
Definition: chrono.h:1950
fmt::v8::detail::buffer::size
constexpr auto size() const -> size_t
Definition: core.h:820
p
for p
Definition: process_rx_frame.m:36
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::format
auto format(const duration &d, FormatContext &ctx) const -> decltype(ctx.out())
Definition: chrono.h:1959
fmt::v8::detail::make_unsigned_or_unchanged< T, true >::type
typename std::make_unsigned< T >::type type
Definition: chrono.h:1436
fmt::v8::detail::locale_ref
Definition: core.h:1669
fmt::v8::detail::tm_format_checker::on_abbr_month
void on_abbr_month()
Definition: chrono.h:885
fmt::v8::detail::null_chrono_spec_handler::on_full_weekday
void on_full_weekday()
Definition: chrono.h:839
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::make_arg_ref
arg_ref_type make_arg_ref(basic_string_view< Char > arg_id)
Definition: chrono.h:1891
fmt::v8::basic_string_view< char >
fmt::v8::detail::format_duration_value
OutputIt format_duration_value(OutputIt out, Rep val, int)
Definition: chrono.h:1508
fmt::v8::detail::null_chrono_spec_handler::on_offset_year
void on_offset_year()
Definition: chrono.h:834
fmt::v8::detail::chrono_formatter::on_offset_year
void on_offset_year()
Definition: chrono.h:1730
fmt::v8::detail::null_chrono_spec_handler::on_full_month
void on_full_month()
Definition: chrono.h:843
fmt::v8::detail::tm_format_checker::on_abbr_weekday
void on_abbr_weekday()
Definition: chrono.h:881
detail
Definition: fmt.cpp:13
fmt::v8::detail::parse_width
auto parse_width(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2383
fmt::v8::detail::formatbuf
Definition: format.h:255
y
y
Definition: simulate_performance.m:74
fmt::v8::detail::parse_precision
auto parse_precision(const Char *begin, const Char *end, Handler &&handler) -> const Char *
Definition: core.h:2417
fmt::v8::basic_string_view::size
constexpr auto size() const -> size_t
Definition: core.h:495
fmt::v8::detail::buffer
Definition: core.h:778
fmt::v8::detail::tm_writer::on_full_month
void on_full_month()
Definition: chrono.h:1171
fmt::v8::detail::chrono_formatter::on_loc_time
void on_loc_time(numeric_system)
Definition: chrono.h:1723
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::width_ref
arg_ref_type width_ref
Definition: chrono.h:1875
fmt::v8::detail::chrono_format_checker::on_duration_value
void on_duration_value()
Definition: chrono.h:1386
fmt::v8::detail::numeric_system
numeric_system
Definition: chrono.h:595
fmt::v8::format_error
Definition: format.h:814
fmt::v8::detail::chrono_formatter::on_year
void on_year(numeric_system)
Definition: chrono.h:1728
fmt::v8::detail::is_integer
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
fmt::v8::detail::value
Definition: core.h:1208
fmt::v8::safe_duration_cast::lossless_integral_conversion
To lossless_integral_conversion(const From from, int &ec)
Definition: chrono.h:55
fmt::v8::formatter< std::chrono::time_point< std::chrono::system_clock, Duration >, Char >::formatter
formatter()
Definition: chrono.h:1990
fmt::v8::detail::tm_format_checker::on_utc_offset
void on_utc_offset()
Definition: chrono.h:907
fmt::v8::detail::is_big_endian
auto is_big_endian() -> bool
Definition: format.h:298
x
x
Definition: simulate_performance.m:69
fmt::v8::detail::null_chrono_spec_handler::on_loc_date
void on_loc_date(numeric_system)
Definition: chrono.h:856
fmt::v8::detail::tm_writer::on_dec_month
void on_dec_month(numeric_system ns)
Definition: chrono.h:1265
count
count
Definition: inspect_agora_results.m:96
fmt::v8::detail::null_chrono_spec_handler::on_second
void on_second(numeric_system)
Definition: chrono.h:854
matplotlibcpp::fill
bool fill(const std::vector< Numeric > &x, const std::vector< Numeric > &y, const std::map< std::string, std::string > &keywords)
Definition: matplotlibcpp.h:790
fmt::v8::detail::chrono_formatter::write_fractional_seconds
void write_fractional_seconds(Duration d)
Definition: chrono.h:1666
fmt::v8::detail::tm_writer::on_12_hour_time
void on_12_hour_time()
Definition: chrono.h:1335
fmt::v8::detail::null
Definition: chrono.h:302
fmt::v8::detail::chrono_formatter::on_day_of_month_space
void on_day_of_month_space(numeric_system)
Definition: chrono.h:1740
fmt::v8::detail::chrono_formatter::on_iso_date
void on_iso_date()
Definition: chrono.h:1725
fmt::v8::detail::tm_writer::on_24_hour
void on_24_hour(numeric_system ns)
Definition: chrono.h:1317
fmt::v8::detail::chrono_format_checker::on_text
void on_text(const Char *, const Char *)
Definition: chrono.h:1377
fmt::v8::basic_format_specs
Definition: core.h:2079
fmt::v8::detail::tm_writer::on_loc_time
void on_loc_time(numeric_system ns)
Definition: chrono.h:1199
fmt::v8::detail::is_negative
auto is_negative(T value) -> bool
Definition: format.h:888
fmt::v8::detail::chrono_format_checker::on_iso_time
void on_iso_time()
Definition: chrono.h:1384
fmt::v8::detail::null_chrono_spec_handler::on_am_pm
void on_am_pm()
Definition: chrono.h:863
Catch::Generators::range
GeneratorWrapper< T > range(T const &start, T const &end, T const &step)
Definition: catch.hpp:4693
fmt::v8::detail::chrono_formatter::on_12_hour_time
void on_12_hour_time()
Definition: chrono.h:1782
fmt::v8::detail::chrono_format_checker::on_24_hour_time
void on_24_hour_time()
Definition: chrono.h:1383
FMT_NORETURN
#define FMT_NORETURN
Definition: core.h:176
fmt::v8::detail::chrono_formatter::write_sign
void write_sign()
Definition: chrono.h:1649
fmt::v8::detail::tm_format_checker::on_am_pm
void on_am_pm()
Definition: chrono.h:906
T
T
Definition: simulate_performance.m:4
fmt::v8::detail::chrono_formatter::on_dec_month
void on_dec_month(numeric_system)
Definition: chrono.h:1734
fmt::v8::detail::tm_format_checker::on_iso_date
void on_iso_date()
Definition: chrono.h:902
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::precision_ref
arg_ref_type precision_ref
Definition: chrono.h:1876
fmt::v8::weekday::value
unsigned char value
Definition: chrono.h:1830
fmt::v8::detail::abs
constexpr std::chrono::duration< Rep, Period > abs(std::chrono::duration< Rep, Period > d)
Definition: chrono.h:1488
fmt::v8::detail::tm_writer::write1
void write1(int value)
Definition: chrono.h:1045
fmt::v8::detail::chrono_formatter::on_us_date
void on_us_date()
Definition: chrono.h:1724
fmt::v8::basic_memory_buffer
Definition: format.h:677
fmt::v8::detail::auto_id
Definition: core.h:2139
fmt::v8::detail::chrono_formatter::on_24_hour
void on_24_hour(numeric_system ns)
Definition: chrono.h:1742
fmt::v8::detail::chrono_formatter::rep
conditional_t< std::is_integral< Rep >::value &&sizeof(Rep)< sizeof(int), unsigned, typename make_unsigned_or_unchanged< Rep >::type > rep
Definition: chrono.h:1580
fmt::v8::detail::chrono_formatter::write
void write(Rep value, int width)
Definition: chrono.h:1656
fmt::v8::detail::null_chrono_spec_handler::on_dec0_week_of_year
void on_dec0_week_of_year(numeric_system)
Definition: chrono.h:845
fmt::v8::detail::tm_format_checker::on_loc_time
void on_loc_time(numeric_system)
Definition: chrono.h:900
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::parse_range::begin
iterator begin
Definition: chrono.h:1922
fmt::v8::detail::chrono_formatter::on_iso_week_of_year
void on_iso_week_of_year(numeric_system)
Definition: chrono.h:1737
fmt::v8::detail::chrono_formatter::on_dec0_week_of_year
void on_dec0_week_of_year(numeric_system)
Definition: chrono.h:1735
fmt::v8::detail::null_chrono_spec_handler::on_abbr_weekday
void on_abbr_weekday()
Definition: chrono.h:838
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_width
void on_width(int width)
Definition: chrono.h:1905
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::format_str
basic_string_view< Char > format_str
Definition: chrono.h:1878
fmt::v8::detail::null_chrono_spec_handler::on_minute
void on_minute(numeric_system)
Definition: chrono.h:853
FMT_ENABLE_IF
#define FMT_ENABLE_IF(...)
Definition: core.h:344
fmt::v8::basic_format_parse_context::next_arg_id
auto next_arg_id() -> int
Definition: core.h:671
fmt::v8::detail::tm_writer::on_am_pm
void on_am_pm()
Definition: chrono.h:1359
fmt::v8::detail::tm_wday_short_name
const char * tm_wday_short_name(int wday)
Definition: chrono.h:917
fmt::v8::weekday
Definition: chrono.h:1828
fmt::v8::detail::chrono_format_checker
Definition: chrono.h:1373
fmt::v8::detail::tm_writer::write_year_extended
void write_year_extended(long long year)
Definition: chrono.h:1054
fmt::v8::detail::chrono_format_checker::on_minute
void on_minute(numeric_system)
Definition: chrono.h:1380
fmt::v8::detail::tm_format_checker::on_iso_time
void on_iso_time()
Definition: chrono.h:905
fmt::v8::detail::format_duration_unit
OutputIt format_duration_unit(OutputIt out)
Definition: chrono.h:1536
fmt::v8::detail::chrono_formatter::second
Rep second() const
Definition: chrono.h:1639
fmt::v8::detail::tm_writer::on_dec1_week_of_year
void on_dec1_week_of_year(numeric_system ns)
Definition: chrono.h:1276
fmt::v8::ptr
auto ptr(T p) -> const void *
Definition: format.h:2680
fmt::v8::detail::null_chrono_spec_handler::on_datetime
void on_datetime(numeric_system)
Definition: chrono.h:855
fmt::v8::detail::utf8_to_utf16
Definition: format.h:1188
fmt::v8::detail::null_chrono_spec_handler
Definition: chrono.h:828
fmt::v8::detail::chrono_formatter::on_second
void on_second(numeric_system ns)
Definition: chrono.h:1769
fmt::v8::detail::null_chrono_spec_handler::unsupported
void unsupported()
Definition: chrono.h:829
fmt::v8::detail::tm_format_checker::on_minute
void on_minute(numeric_system)
Definition: chrono.h:896
fmt::v8::detail::chrono_formatter::format_tm
void format_tm(const tm &time, Callback cb, Args... args)
Definition: chrono.h:1702
fmt::v8::detail::write_encoded_tm_str
auto write_encoded_tm_str(OutputIt out, string_view in, const std::locale &loc) -> OutputIt
Definition: chrono.h:342
fmt::v8::detail::chrono_formatter::hour
Rep hour() const
Definition: chrono.h:1631
fmt::v8::detail::null_chrono_spec_handler::on_short_year
void on_short_year(numeric_system)
Definition: chrono.h:833
fmt::v8::basic_format_parse_context::begin
constexpr auto begin() const -> iterator
Definition: core.h:651
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail2::begin
begin_tag begin(T &&...)
fmt::v8::detail::tm_format_checker::on_24_hour_time
void on_24_hour_time()
Definition: chrono.h:904
fmt::v8::detail::chrono_format_checker::on_24_hour
void on_24_hour(numeric_system)
Definition: chrono.h:1378
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::f
formatter & f
Definition: chrono.h:1882
fmt::v8::detail::get_locale::locale_
std::locale locale_
Definition: chrono.h:1553
fmt::v8::detail::null_chrono_spec_handler::on_day_of_month
void on_day_of_month(numeric_system)
Definition: chrono.h:849
fmt::v8::detail::chrono_formatter::handle_nan_inf
bool handle_nan_inf()
Definition: chrono.h:1614
len
uint16_t len
Definition: eth_common.h:62
fmt::v8::detail::tm_writer::on_loc_date
void on_loc_date(numeric_system ns)
Definition: chrono.h:1193
fmt::v8::detail::tm_writer::format_tz_name_impl
void format_tz_name_impl(const T &)
Definition: chrono.h:1119
fmt::v8::detail::null_chrono_spec_handler::on_12_hour_time
void on_12_hour_time()
Definition: chrono.h:860
fmt::v8::detail::null_chrono_spec_handler::on_tz_name
void on_tz_name()
Definition: chrono.h:867
FMT_END_NAMESPACE
#define FMT_END_NAMESPACE
Definition: core.h:240
fmt::v8::detail::null_chrono_spec_handler::on_dec1_weekday
void on_dec1_weekday(numeric_system)
Definition: chrono.h:841
fmt::v8::formatter< std::tm, Char >::parse
auto parse(ParseContext &ctx) -> decltype(ctx.begin())
Definition: chrono.h:2044
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail::void
j template void())
Definition: json.hpp:4744
fmt::v8::detail::tm_writer::on_dec0_weekday
void on_dec0_weekday(numeric_system ns)
Definition: chrono.h:1152
fmt::v8::detail::chrono_formatter::on_am_pm
void on_am_pm()
Definition: chrono.h:1806
fmt::v8::detail::arg_ref
Definition: core.h:2106
fmt::v8::detail::tm_writer::on_iso_week_based_year
void on_iso_week_based_year()
Definition: chrono.h:1292
fmt::v8::detail::codecvt_result::buf
CodeUnit buf[max_size]
Definition: chrono.h:315
fmt::v8::detail::null_chrono_spec_handler::on_us_date
void on_us_date()
Definition: chrono.h:858
u
Plot Rx waveform for u
Definition: inspect_single_frame.m:108
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_align
void on_align(align_t align)
Definition: chrono.h:1904
fmt::v8::basic_string_view::end
constexpr auto end() const -> iterator
Definition: core.h:498
fmt::v8::detail::tm_writer
Definition: chrono.h:959
fmt::v8::detail::tm_format_checker::on_short_year
void on_short_year(numeric_system)
Definition: chrono.h:876
fmt::v8::detail::chrono_format_checker::on_12_hour
void on_12_hour(numeric_system)
Definition: chrono.h:1379
fmt::v8::detail::const_check
constexpr auto const_check(T value) -> T
Definition: core.h:365
fmt::v8::detail::codecvt_result
Definition: chrono.h:313
fmt::v8::detail::tm_writer::format_tz_name_impl
void format_tz_name_impl(const T &tm)
Definition: chrono.h:1112
fmt::v8::formatter< std::tm, Char >::format
auto format(const std::tm &tm, FormatContext &ctx) const -> decltype(ctx.out())
Definition: chrono.h:2049
fmt::v8::detail::null_chrono_spec_handler::on_year
void on_year(numeric_system)
Definition: chrono.h:832
fmt::v8::detail::tm_writer::format_localized
void format_localized(char format, char modifier=0)
Definition: chrono.h:1123
fmt::v8::detail::tm_writer::on_abbr_month
void on_abbr_month()
Definition: chrono.h:1165
fmt::v8::detail::fmt_safe_duration_cast
To fmt_safe_duration_cast(std::chrono::duration< FromRep, FromPeriod > from)
Definition: chrono.h:1442
fmt::v8::formatter< std::tm, Char >::specs
basic_string_view< Char > specs
Definition: chrono.h:2022
fmt::v8::detail::numeric_system::standard
@ standard
fmt::v8::detail::tm_writer::on_abbr_weekday
void on_abbr_weekday()
Definition: chrono.h:1140
fmt::v8::detail::chrono_formatter::char_type
typename FormatContext::char_type char_type
Definition: chrono.h:1587
fmt::v8::detail::tm_mon_short_name
const char * tm_mon_short_name(int mon)
Definition: chrono.h:929
fmt::v8::detail::tm_format_checker::on_dec_month
void on_dec_month(numeric_system)
Definition: chrono.h:887
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::end_precision
void end_precision()
Definition: chrono.h:1909
fmt::v8::basic_string_view::begin
constexpr auto begin() const -> iterator
Definition: core.h:497
fmt::v8::detail::chrono_formatter::on_text
void on_text(const char_type *begin, const char_type *end)
Definition: chrono.h:1710
fmt::v8::detail::null_chrono_spec_handler::on_iso_week_of_year
void on_iso_week_of_year(numeric_system)
Definition: chrono.h:847
fmt::v8::detail::null_chrono_spec_handler::on_loc_time
void on_loc_time(numeric_system)
Definition: chrono.h:857
fmt::v8::detail::gmtime_r
null gmtime_r(...)
Definition: chrono.h:305
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::context
basic_format_parse_context< Char > & context
Definition: chrono.h:1883
fmt::v8::detail::tm_wday_full_name
const char * tm_wday_full_name(int wday)
Definition: chrono.h:911
fmt::v8::detail::null_chrono_spec_handler::on_iso_time
void on_iso_time()
Definition: chrono.h:862
s
s
Definition: simulate_performance.m:3
fmt::v8::detail::tm_format_checker::on_us_date
void on_us_date()
Definition: chrono.h:901
fmt::v8::align::type
type
Definition: core.h:2021
fmt::v8::detail::null_chrono_spec_handler::on_abbr_month
void on_abbr_month()
Definition: chrono.h:842
fmt::v8::detail::null_chrono_spec_handler::on_dec1_week_of_year
void on_dec1_week_of_year(numeric_system)
Definition: chrono.h:846
fmt::v8::detail::chrono_formatter::on_dec0_weekday
void on_dec0_weekday(numeric_system)
Definition: chrono.h:1717
fmt::v8::detail::tm_format_checker::on_full_month
void on_full_month()
Definition: chrono.h:886
fmt::v8::detail::null_chrono_spec_handler::on_12_hour
void on_12_hour(numeric_system)
Definition: chrono.h:852
fmt::v8::detail::count_fractional_digits
constexpr int count_fractional_digits(long long num, long long den, int n=0)
Definition: chrono.h:1476
fmt::v8::detail::tm_writer::on_utc_offset
void on_utc_offset()
Definition: chrono.h:1229
fmt::v8::detail::null_chrono_spec_handler::on_day_of_year
void on_day_of_year()
Definition: chrono.h:848
fmt::v8::safe_duration_cast::safe_duration_cast
To safe_duration_cast(std::chrono::duration< FromRep, FromPeriod > from, int &ec)
Definition: chrono.h:171
fmt::v8::detail::chrono_formatter::out
OutputIt out
Definition: chrono.h:1574
fmt::v8::detail::tm_writer::iso_year_weeks
auto iso_year_weeks(long long curr_year) const noexcept -> int
Definition: chrono.h:1016
fmt::v8::detail::chrono_formatter::on_century
void on_century(numeric_system)
Definition: chrono.h:1731
fmt::v8::detail::to_nonnegative_int
Int to_nonnegative_int(T value, Int upper)
Definition: chrono.h:1406
fmt::v8::detail::tm_writer::tm_hour12
auto tm_hour12() const noexcept -> int
Definition: chrono.h:998
fmt::v8::formatter< weekday, Char >::parse
auto parse(basic_format_parse_context< Char > &ctx) -> decltype(ctx.begin())
Definition: chrono.h:1848
n
n
Definition: simulate_performance.m:1
fmt::v8::formatter
Definition: core.h:707
d
for d
Definition: process_rx_frame.m:53
fmt::v8::detail::tm_writer::on_second
void on_second(numeric_system ns)
Definition: chrono.h:1330
fmt::v8::detail::buffer::data
auto data() -> T *
Definition: core.h:826
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::make_arg_ref
arg_ref_type make_arg_ref(detail::auto_id)
Definition: chrono.h:1896
fmt::v8::detail::chrono_formatter::on_duration_value
void on_duration_value()
Definition: chrono.h:1811
fmt::v8::detail::mod
T mod(T x, int y)
Definition: chrono.h:1420
fmt::v8::formatter< std::tm, Char >::do_parse
auto do_parse(It begin, It end, bool with_default=false) -> It
Definition: chrono.h:2026
fmt::v8::weekday::c_encoding
constexpr unsigned c_encoding() const noexcept
Definition: chrono.h:1836
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::parse_range::end
iterator end
Definition: chrono.h:1923
fmt::v8::detail::tm_writer::on_full_weekday
void on_full_weekday()
Definition: chrono.h:1146
fmt::v8::detail::get_units
const char * get_units()
Definition: chrono.h:572
fmt::v8::detail::null_chrono_spec_handler::on_24_hour
void on_24_hour(numeric_system)
Definition: chrono.h:851
FMT_ASSERT
#define FMT_ASSERT(condition, message)
Definition: core.h:378
fmt::v8::detail::tm_writer::on_duration_value
void on_duration_value()
Definition: chrono.h:1369
FMT_BEGIN_DETAIL_NAMESPACE
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition: core.h:249
fmt::v8::detail::null_chrono_spec_handler::on_iso_date
void on_iso_date()
Definition: chrono.h:859
fmt::v8::detail::tm_writer::tm_hour
auto tm_hour() const noexcept -> int
Definition: chrono.h:976
fmt::v8::detail::codecvt_result::end
CodeUnit * end
Definition: chrono.h:316
fmt::v8::detail::tm_writer::split_year_lower
auto split_year_lower(long long year) const noexcept -> int
Definition: chrono.h:1008
fmt::v8::detail::tm_format_checker::on_dec0_week_of_year
void on_dec0_week_of_year(numeric_system)
Definition: chrono.h:888
FMT_MODULE_EXPORT_END
#define FMT_MODULE_EXPORT_END
Definition: core.h:248
FMT_MODULE_EXPORT_BEGIN
#define FMT_MODULE_EXPORT_BEGIN
Definition: core.h:247
fmt::v8::detail::chrono_formatter::on_loc_date
void on_loc_date(numeric_system)
Definition: chrono.h:1722
fmt::v8::detail::tm_writer::tm_min
auto tm_min() const noexcept -> int
Definition: chrono.h:972
fmt::v8::detail::tm_format_checker::on_day_of_month
void on_day_of_month(numeric_system)
Definition: chrono.h:892
spdlog::details::fmt_helper::count_digits
unsigned int count_digits(T n)
Definition: fmt_helper.h:83
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::specs
basic_format_specs< Char > specs
Definition: chrono.h:1872
fmt::v8::detail::tm_format_checker::on_iso_week_based_year
void on_iso_week_based_year()
Definition: chrono.h:879
fmt::v8::detail::tm_writer::format_utc_offset_impl
void format_utc_offset_impl(const T &tm)
Definition: chrono.h:1088
fmt::v8::detail::tm_writer::on_us_date
void on_us_date()
Definition: chrono.h:1205
fmt::v8::detail::null_chrono_spec_handler::on_century
void on_century(numeric_system)
Definition: chrono.h:835
fmt::v8::conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:323
fmt::v8::detail::chrono_formatter::on_dec1_week_of_year
void on_dec1_week_of_year(numeric_system)
Definition: chrono.h:1736
std
Definition: json.hpp:5213
fmt::v8::detail::tm_writer::out
OutputIt out() const
Definition: chrono.h:1134
fmt::v8::detail::tm_writer::on_dec0_week_of_year
void on_dec0_week_of_year(numeric_system ns)
Definition: chrono.h:1271
fmt::v8::detail::tm_writer::on_iso_week_based_short_year
void on_iso_week_based_short_year()
Definition: chrono.h:1293
fmt::v8::detail::tm_writer::on_24_hour_time
void on_24_hour_time()
Definition: chrono.h:1347
fmt::v8::detail::tm_writer::on_minute
void on_minute(numeric_system ns)
Definition: chrono.h:1326
fmt::v8::detail::chrono_formatter::hour12
Rep hour12() const
Definition: chrono.h:1633
fmt::v8::detail::chrono_format_checker::on_12_hour_time
void on_12_hour_time()
Definition: chrono.h:1382
fmt::v8::formatter< weekday, Char >::format
auto format(weekday wd, FormatContext &ctx) const -> decltype(ctx.out())
Definition: chrono.h:1859
fmt::v8::detail::get_classic_locale
const std::locale & get_classic_locale()
Definition: chrono.h:308
fmt::v8::detail::tm_format_checker::on_12_hour_time
void on_12_hour_time()
Definition: chrono.h:903
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::duration
std::chrono::duration< Rep, Period > duration
Definition: chrono.h:1879
fmt::v8::detail::tm_writer::tm_yday
auto tm_yday() const noexcept -> int
Definition: chrono.h:993
fmt::v8::detail::copy
OutputIterator copy(const RangeT &range, OutputIterator out)
Definition: ranges.h:26
fmt::v8::detail::tm_writer::tm_
const std::tm & tm_
Definition: chrono.h:966
fmt::v8::detail::chrono_formatter::on_tz_name
void on_tz_name()
Definition: chrono.h:1727
fmt::v8::detail::chrono_formatter::on_full_month
void on_full_month()
Definition: chrono.h:1720
fmt::v8::weekday::weekday
constexpr weekday(unsigned wd) noexcept
Definition: chrono.h:1834
fmt::v8::detail::localtime_r
null localtime_r(...)
Definition: chrono.h:303
FMT_BEGIN_NAMESPACE
#define FMT_BEGIN_NAMESPACE
Definition: core.h:237
fmt::v8::detail::tm_writer::on_dec1_weekday
void on_dec1_weekday(numeric_system ns)
Definition: chrono.h:1156
fmt::v8::gmtime
std::tm gmtime(std::chrono::time_point< std::chrono::system_clock > time_point)
Definition: chrono.h:531
fmt::v8::detail::tm_writer::on_day_of_year
void on_day_of_year()
Definition: chrono.h:1297
fmt::v8::detail::tm_format_checker::on_iso_week_of_year
void on_iso_week_of_year(numeric_system)
Definition: chrono.h:890
fmt::v8::detail::chrono_formatter::on_short_year
void on_short_year(numeric_system)
Definition: chrono.h:1729
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::make_arg_ref
arg_ref_type make_arg_ref(Id arg_id)
Definition: chrono.h:1886
fmt::v8::detail::tm_writer::loc_
const std::locale & loc_
Definition: chrono.h:963
fmt::v8::detail::get_locale::~get_locale
~get_locale()
Definition: chrono.h:1562
fmt::v8::detail::chrono_formatter::on_24_hour_time
void on_24_hour_time()
Definition: chrono.h:1787
fmt::v8::detail::get_locale::get_locale
get_locale(bool localized, locale_ref loc)
Definition: chrono.h:1558
fmt::v8::safe_duration_cast::safe_float_conversion
To safe_float_conversion(const From from, int &ec)
Definition: chrono.h:137
fmt::v8::detail::pow10
constexpr long long pow10(std::uint32_t n)
Definition: chrono.h:1482
fmt::v8::detail::make_unsigned_or_unchanged
Definition: chrono.h:1431
fmt::v8::detail::tm_writer::on_offset_year
void on_offset_year()
Definition: chrono.h:1242
fmt::v8::detail::null_chrono_spec_handler::on_duration_unit
void on_duration_unit()
Definition: chrono.h:865
fmt::v8::detail::chrono_formatter::on_iso_time
void on_iso_time()
Definition: chrono.h:1799
fmt::v8::detail::chrono_formatter::seconds
std::chrono::duration< rep > seconds
Definition: chrono.h:1582
l
l
Definition: parse_all_dl.m:71
fmt::v8::detail::tm_format_checker::on_day_of_year
void on_day_of_year()
Definition: chrono.h:891
fmt::v8::detail::tm_writer::write_utc_offset
void write_utc_offset(long offset)
Definition: chrono.h:1076
fmt::v8::detail::write_tm_str
auto write_tm_str(OutputIt out, string_view sv, const std::locale &loc) -> OutputIt
Definition: chrono.h:397
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_dynamic_precision
void on_dynamic_precision(Id arg_id)
Definition: chrono.h:1915
fmt::v8::detail::is_signed
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_t >::value > is_signed
Definition: format.h:883
fmt::v8::detail::tm_writer::tm_year
auto tm_year() const noexcept -> long long
Definition: chrono.h:988
fmt::v8::detail::tm_writer::write2
void write2(int value)
Definition: chrono.h:1048
fmt::v8::detail::tm_format_checker::on_second
void on_second(numeric_system)
Definition: chrono.h:897
fmt::v8::detail::chrono_formatter::on_minute
void on_minute(numeric_system ns)
Definition: chrono.h:1760
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::iterator
typename basic_format_parse_context< Char >::iterator iterator
Definition: chrono.h:1920
fmt::v8::detail::tm_format_checker::on_12_hour
void on_12_hour(numeric_system)
Definition: chrono.h:895
fmt::v8::detail::tm_writer::on_iso_time
void on_iso_time()
Definition: chrono.h:1352
fmt::v8::detail::has_member_data_tm_zone
Definition: chrono.h:944
fmt::v8::detail::localtime_s
null localtime_s(...)
Definition: chrono.h:304
fmt::v8::detail::tm_mon_full_name
const char * tm_mon_full_name(int mon)
Definition: chrono.h:923
fmt::v8::detail::tm_writer::on_short_year
void on_short_year(numeric_system ns)
Definition: chrono.h:1237
fmt::v8::detail::tm_format_checker::on_offset_year
void on_offset_year()
Definition: chrono.h:877
fmt::v8::detail::chrono_format_checker::on_second
void on_second(numeric_system)
Definition: chrono.h:1381
fmt::v8::detail::chrono_formatter::on_utc_offset
void on_utc_offset()
Definition: chrono.h:1726
FMT_END_DETAIL_NAMESPACE
#define FMT_END_DETAIL_NAMESPACE
Definition: core.h:250
max
max(y1, y1_1)
fmt::v8::detail::chrono_formatter::on_abbr_month
void on_abbr_month()
Definition: chrono.h:1719
fmt::v8::detail::to_unsigned
auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:424
fmt::v8::detail::chrono_formatter::on_12_hour
void on_12_hour(numeric_system ns)
Definition: chrono.h:1751
fmt::v8::detail::copy2
void copy2(Char *dst, const char *src)
Definition: format.h:1088
fmt::v8::formatter< std::chrono::time_point< std::chrono::system_clock, Duration >, Char >::parse
auto parse(ParseContext &ctx) -> decltype(ctx.begin())
Definition: chrono.h:1996
fmt::v8::detail::tm_writer::tm_iso_week_year
auto tm_iso_week_year() const noexcept -> long long
Definition: chrono.h:1030
fmt::v8::detail::tm_writer::tm_sec
auto tm_sec() const noexcept -> int
Definition: chrono.h:968
fmt::v8::formatter< std::chrono::time_point< std::chrono::system_clock, Duration >, Char >::format
auto format(std::chrono::time_point< std::chrono::system_clock > val, FormatContext &ctx) const -> decltype(ctx.out())
Definition: chrono.h:2001
fmt::v8::detail::chrono_formatter::write_ninf
void write_ninf()
Definition: chrono.h:1699
fmt::v8::detail::tm_format_checker::on_datetime
void on_datetime(numeric_system)
Definition: chrono.h:898
fmt::v8::detail::tm_writer::on_day_of_month_space
void on_day_of_month_space(numeric_system ns)
Definition: chrono.h:1306
fmt::v8::formatter< std::chrono::duration< Rep, Period >, Char >::spec_handler::on_dynamic_width
void on_dynamic_width(Id arg_id)
Definition: chrono.h:1911
fmt::v8::detail::tm_format_checker::unsupported
void unsupported()
Definition: chrono.h:871
FMT_CONSTEXPR
#define FMT_CONSTEXPR
Definition: core.h:110
fmt::v8::detail::tm_writer::on_day_of_month
void on_day_of_month(numeric_system ns)
Definition: chrono.h:1302
nlohmann::json_v3_11_1NLOHMANN_JSON_ABI_TAG_LEGACY_DISCARDED_VALUE_COMPARISON::detail2::end
end_tag end(T &&...)
fmt::v8::detail::digits::result
result
Definition: format-inl.h:640
fmt::v8::detail::isfinite
bool isfinite(T)
Definition: chrono.h:1400
utils::format
std::string format(const T &value)
Definition: utils.h:15
fmt::v8::detail::tm_writer::on_tz_name
void on_tz_name()
Definition: chrono.h:1230
fmt::v8::detail::type
type
Definition: core.h:1131
FMT_THROW
#define FMT_THROW(x)
Definition: format.h:95
fmt::v8::detail::tm_writer::on_century
void on_century(numeric_system ns)
Definition: chrono.h:1247
fmt::v8::detail::do_write
void do_write(buffer< Char > &buf, const std::tm &time, const std::locale &loc, char format, char modifier)
Definition: chrono.h:412
fmt::v8::detail::tm_format_checker::on_dec1_weekday
void on_dec1_weekday(numeric_system)
Definition: chrono.h:884
fmt::v8::detail::make_unsigned_or_unchanged::type
T type
Definition: chrono.h:1432
fmt::v8::detail::tm_writer::tm_writer
tm_writer(const std::locale &loc, OutputIt out, const std::tm &tm)
Definition: chrono.h:1128
fmt::v8::detail::tm_writer::tm_mon
auto tm_mon() const noexcept -> int
Definition: chrono.h:984
fmt::v8::detail::fill_n
auto fill_n(OutputIt out, Size count, const T &value) -> OutputIt
Definition: format.h:448
fmt::v8::detail::tm_format_checker::on_dec1_week_of_year
void on_dec1_week_of_year(numeric_system)
Definition: chrono.h:889
fmt::v8::detail::tm_format_checker::on_tz_name
void on_tz_name()
Definition: chrono.h:908
precision
precision
Definition: inspect_single_frame.m:150