diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 74fc8485..674d2cfc 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -2135,8 +2135,8 @@ struct formatter, auto format(std::chrono::time_point val, FormatContext& ctx) const -> decltype(ctx.out()) { using period = typename Duration::period; - if (period::num != 1 || period::den != 1 || - std::is_floating_point::value) { + if constexpr (period::num != 1 || period::den != 1 || + std::is_floating_point::value) { const auto epoch = val.time_since_epoch(); auto subsecs = std::chrono::duration_cast( epoch - std::chrono::duration_cast(epoch)); @@ -2153,10 +2153,10 @@ struct formatter, return formatter::do_format( gmtime(std::chrono::time_point_cast(val)), ctx, &subsecs); + } else { + return formatter::format( + gmtime(std::chrono::time_point_cast(val)), ctx); } - - return formatter::format( - gmtime(std::chrono::time_point_cast(val)), ctx); } };