Lines Matching +full:gcc +full:- +full:specs +full:- +full:uwp
1 // Formatting library for C++ - chrono support
3 // Copyright (c) 2012 - present, Victor Zverovich
45 // UWP doesn't provide _tzset.
76 -> To {
106 -> To {
139 -> To {
144 // clang-format off
149 * ---------------------------------|---------------
155 * -Inf | -Inf
157 // clang-format on
160 FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
182 FMT_CONSTEXPR auto safe_float_conversion(const From from, int& ec) -> To {
195 int& ec) -> To {
247 int& ec) -> To {
257 // +-inf should be preserved.
278 // force conversion of From::rep -> IntermediateRep to be safe,
321 // Prevents expansion of a preceding token as a function-style macro.
327 inline auto localtime_r FMT_NOMACRO(...) -> null<> { return null<>(); }
328 inline auto localtime_s(...) -> null<> { return null<>(); }
329 inline auto gmtime_r(...) -> null<> { return null<>(); }
330 inline auto gmtime_s(...) -> null<> { return null<>(); }
332 inline auto get_classic_locale() -> const std::locale& {
348 # pragma clang diagnostic ignored "-Wdeprecated" in write_codecvt()
364 -> OutputIt {
367 // gcc-4.
370 // The _GLIBCXX_USE_DUAL_ABI macro is always defined in libstdc++ from gcc-5
380 // In UTF-8 is used one to four one-byte code units.
383 if (!u.convert({unit.buf, to_unsigned(unit.end - unit.buf)}))
393 -> OutputIt {
402 -> OutputIt {
420 char format, char modifier = 0) -> OutputIt {
429 char format, char modifier = 0) -> OutputIt {
447 auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
464 auto fmt_duration_cast(std::chrono::duration<FromRep, FromPeriod> from) -> To {
465 // Mixed integer <-> float cast is not supported by safe_duration_cast.
472 -> std::time_t {
487 thread-safe on most platforms.
489 inline auto localtime(std::time_t time) -> std::tm {
496 auto run() -> bool {
501 auto handle(std::tm* tm) -> bool { return tm != nullptr; }
503 auto handle(detail::null<>) -> bool {
508 auto fallback(int res) -> bool { return res == 0; }
511 auto fallback(detail::null<>) -> bool {
527 inline auto localtime(std::chrono::local_time<Duration> time) -> std::tm {
529 detail::to_time_t(std::chrono::current_zone()->to_sys(time)));
536 function is thread-safe on most platforms.
538 inline auto gmtime(std::time_t time) -> std::tm {
545 auto run() -> bool {
550 auto handle(std::tm* tm) -> bool { return tm != nullptr; }
552 auto handle(detail::null<>) -> bool {
557 auto fallback(int res) -> bool { return res == 0; }
560 auto fallback(detail::null<>) -> bool {
576 -> std::tm {
582 // Writes two-digit numbers a, b and c separated by sep to buf.
584 // https://johnnylee-sde.github.io/Fast-unsigned-integer-to-time-string/.
592 // y - x = a * 6 in write_digit2_separated()
617 FMT_CONSTEXPR inline auto get_units() -> const char* {
653 // character uses space-padding by default.
660 auto write_padding(OutputIt out, pad_type pad, int width) -> OutputIt {
666 auto write_padding(OutputIt out, pad_type pad) -> OutputIt {
671 // Parses a put_time-like format string and invokes handler actions.
674 Handler&& handler) -> const Char* {
695 case '-':
708 handler.on_text(ptr - 1, ptr);
924 static_cast<Derived*>(this)->unsupported(); in unsupported()
1005 inline auto tm_wday_full_name(int wday) -> const char* {
1011 inline auto tm_wday_short_name(int wday) -> const char* {
1017 inline auto tm_mon_full_name(int mon) -> const char* {
1023 inline auto tm_mon_short_name(int mon) -> const char* {
1045 static bool init = []() -> bool {
1055 inline auto to_nonnegative_int(T value, Int upper) -> Int {
1063 inline auto to_nonnegative_int(T value, Int upper) -> Int {
1069 constexpr auto pow10(std::uint32_t n) -> long long {
1070 return n == 0 ? 1 : 10 * pow10(n - 1);
1093 void write_fractional_seconds(OutputIt& out, Duration d, int precision = -1) {
1103 const auto fractional = d - fmt_duration_cast<std::chrono::seconds>(d);
1112 int leading_zeroes = (std::max)(0, num_fractional_digits - num_digits);
1125 int remaining = precision - leading_zeroes;
1127 n /= to_unsigned(detail::pow10(to_unsigned(num_digits - remaining)));
1132 remaining -= num_digits;
1142 int num_fractional_digits = -1) {
1150 // On some toolchains `std::round` is not available (e.g. GCC 6).
1178 auto tm_sec() const noexcept -> int {
1182 auto tm_min() const noexcept -> int {
1186 auto tm_hour() const noexcept -> int {
1190 auto tm_mday() const noexcept -> int {
1194 auto tm_mon() const noexcept -> int {
1198 auto tm_year() const noexcept -> long long { return 1900ll + tm_.tm_year; }
1199 auto tm_wday() const noexcept -> int {
1203 auto tm_yday() const noexcept -> int {
1208 auto tm_hour12() const noexcept -> int {
1210 const auto z = h < 12 ? h : h - 12;
1218 auto split_year_lower(long long year) const noexcept -> int {
1220 if (l < 0) l = -l; // l in [0, 99]
1225 auto iso_year_weeks(long long curr_year) const noexcept -> int {
1226 const auto prev_year = curr_year - 1;
1228 (curr_year + curr_year / 4 - curr_year / 100 + curr_year / 400) %
1231 (prev_year + prev_year / 4 - prev_year / 100 + prev_year / 400) %
1235 auto iso_week_num(int tm_yday, int tm_wday) const noexcept -> int {
1236 return (tm_yday + 11 - (tm_wday == 0 ? days_per_week : tm_wday)) /
1239 auto tm_iso_week_year() const noexcept -> long long {
1242 if (w < 1) return year - 1;
1246 auto tm_iso_week_of_year() const noexcept -> int {
1249 if (w < 1) return iso_year_weeks(year - 1);
1278 *out_++ = '-';
1279 year = 0 - year;
1280 --width;
1284 if (width > num_digits) out_ = std::fill_n(out_, width - num_digits, '0');
1298 *out_++ = '-';
1299 offset = -offset;
1325 write_utc_offset(-offset, ns);
1334 long offset = gt - lt;
1364 auto out() const -> OutputIt { return out_; }
1455 '-');
1481 if (year >= -99 && year < 0) {
1483 *out_++ = '-';
1503 return write2((tm_yday() + days_per_week - tm_wday()) / days_per_week);
1509 write2((tm_yday() + days_per_week -
1510 (wday == 0 ? (days_per_week - 1) : (wday - 1))) /
1647 inline auto isfinite(T) -> bool {
1652 inline auto mod(T x, int y) -> T {
1656 inline auto mod(T x, int y) -> T {
1674 -> std::chrono::duration<Rep, std::milli> {
1684 const auto diff = d_as_common - d_as_whole_seconds;
1690 return fmt_duration_cast<std::chrono::milliseconds>(d - s);
1696 auto format_duration_value(OutputIt out, Rep val, int) -> OutputIt {
1702 auto format_duration_value(OutputIt out, Rep val, int precision) -> OutputIt {
1703 auto specs = format_specs<Char>();
1704 specs.precision = precision;
1705 specs.type = precision >= 0 ? presentation_type::fixed_lower
1707 return write<Char>(out, val, specs);
1711 auto copy_unit(string_view unit, OutputIt out, Char) -> OutputIt {
1716 auto copy_unit(string_view unit, OutputIt out, wchar_t) -> OutputIt {
1717 // This works when wchar_t is UTF-32 because units only contain characters
1718 // that have the same representation in UTF-16 and UTF-32.
1724 auto format_duration_unit(OutputIt out) -> OutputIt {
1785 val = 0 - val;
1796 auto handle_nan_inf() -> bool {
1804 // must be +-inf
1813 auto days() const -> Rep { return static_cast<Rep>(s.count() / 86400); }
1814 auto hour() const -> Rep {
1818 auto hour12() const -> Rep {
1823 auto minute() const -> Rep {
1826 auto second() const -> Rep { return static_cast<Rep>(mod(s.count(), 60)); }
1828 auto time() const -> std::tm {
1838 *out++ = '-';
1850 out = detail::write_padding(out, pad, width - num_digits);
1857 void write_ninf() { std::copy_n("-inf", 4, out); }
1939 if (negative) *out++ = '-';
2010 constexpr auto c_encoding() const noexcept -> unsigned { return value; }
2023 -> decltype(ctx.begin()) {
2033 auto format(weekday wd, FormatContext& ctx) const -> decltype(ctx.out()) {
2054 -> decltype(ctx.begin()) {
2075 format_str_ = {it, detail::to_unsigned(end - it)};
2081 -> decltype(ctx.out()) {
2082 auto specs = specs_;
2083 auto precision = specs.precision;
2084 specs.precision = -1;
2090 detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
2106 ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
2114 this->format_str_ = detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
2119 FormatContext& ctx) const -> decltype(ctx.out()) {
2126 epoch - detail::fmt_duration_cast<std::chrono::seconds>(epoch));
2134 val -= second;
2149 this->format_str_ = detail::string_literal<Char, '%', 'F', ' ', '%', 'T'>{};
2154 -> decltype(ctx.out()) {
2160 epoch - detail::fmt_duration_cast<std::chrono::seconds>(epoch));
2178 FormatContext& ctx) const -> decltype(ctx.out()) {
2196 const Duration* subsecs) const -> decltype(ctx.out()) {
2197 auto specs = specs_;
2200 detail::handle_dynamic_spec<detail::width_checker>(specs.width, width_ref_,
2209 ctx.out(), basic_string_view<Char>(buf.data(), buf.size()), specs);
2214 -> decltype(ctx.begin()) {
2226 if (end != it) format_str_ = {it, detail::to_unsigned(end - it)};
2232 -> decltype(ctx.out()) {