diff --git a/gc_clock.hh b/gc_clock.hh index 1605c27e76..1d356d370e 100644 --- a/gc_clock.hh +++ b/gc_clock.hh @@ -58,8 +58,6 @@ using ttl_opt = std::optional; // 20 years in seconds static constexpr gc_clock::duration max_ttl = gc_clock::duration{20 * 365 * 24 * 60 * 60}; -std::ostream& operator<<(std::ostream& os, gc_clock::time_point tp); - template<> struct appending_hash { template @@ -107,3 +105,9 @@ struct serializer { }; } + +template<> +struct fmt::formatter { + constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } + auto format(gc_clock::time_point, fmt::format_context& ctx) const -> decltype(ctx.out()); +}; diff --git a/replica/database.cc b/replica/database.cc index d8efb1114e..6753da91be 100644 --- a/replica/database.cc +++ b/replica/database.cc @@ -2980,11 +2980,10 @@ flat_mutation_reader_v2 make_multishard_streaming_reader(distributed::format(gc_clock::time_point tp, fmt::format_context& ctx) const + -> decltype(ctx.out()) { auto sec = std::chrono::duration_cast(tp.time_since_epoch()).count(); - std::ostream tmp(os.rdbuf()); - tmp << std::setw(12) << sec; - return os; + return fmt::format_to(ctx.out(), "{:>12}", sec); } const timeout_config infinite_timeout_config = {