diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 98eac2efde905..03fb446445981 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -769,7 +769,13 @@ template ::value)> OutputIt format_duration_value(OutputIt out, Rep val, int) { static FMT_CONSTEXPR_DECL const Char format[] = {'{', '}', 0}; + +#if defined(FMT_MSC_VER) && FMT_MSC_VER < 1928 + return vformat_to(out, to_string_view(format), + make_format_args>(val)); +#else return format_to(out, FMT_STRING(format), val); +#endif } template = 0) return format_to(out, FMT_STRING(pr_f), val, precision); + if (precision >= 0) { +#if defined(FMT_MSC_VER) && FMT_MSC_VER < 1928 + return vformat_to(out, to_string_view(pr_f), + make_format_args>(val, precision)); +#else + return format_to(out, FMT_STRING(pr_f), val, precision); +#endif + } static FMT_CONSTEXPR_DECL const Char fp_f[] = {'{', ':', 'g', '}', 0}; + +#if defined(FMT_MSC_VER) && FMT_MSC_VER < 1928 + return vformat_to(out, to_string_view(fp_f), + make_format_args>(val)); +#else return format_to(out, FMT_STRING(fp_f), val); +#endif } template @@ -800,11 +819,23 @@ OutputIt format_duration_unit(OutputIt out) { if (const char* unit = get_units()) return copy_unit(string_view(unit), out, Char()); static FMT_CONSTEXPR_DECL const Char num_f[] = {'[', '{', '}', ']', 's', 0}; - if (const_check(Period::den == 1)) + if (const_check(Period::den == 1)) { +#if defined(FMT_MSC_VER) && FMT_MSC_VER < 1928 + return vformat_to(out, to_string_view(num_f), + make_format_args>(Period::num)); +#else return format_to(out, FMT_STRING(num_f), Period::num); +#endif + } static FMT_CONSTEXPR_DECL const Char num_def_f[] = {'[', '{', '}', '/', '{', '}', ']', 's', 0}; +#if defined(FMT_MSC_VER) && FMT_MSC_VER < 1928 + return vformat_to( + out, to_string_view(num_def_f), + make_format_args>(Period::num, Period::den)); +#else return format_to(out, FMT_STRING(num_def_f), Period::num, Period::den); +#endif } template