From 43fd63e28ce2c8b070703a56ef91dcd323dfcbaa Mon Sep 17 00:00:00 2001 From: Kefu Chai Date: Tue, 21 Nov 2023 21:37:11 +0800 Subject: [PATCH] clocks-impl: format time_point using fmt instead of relying on the operator<<() of an opaque type, use fmtlib to print a timepoint for better support of new fmtlib which dropped the default-generated formatter for types with operator<<(). Refs #13245 Signed-off-by: Kefu Chai Closes scylladb/scylladb#16116 --- clocks-impl.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/clocks-impl.cc b/clocks-impl.cc index 24053bd4f1..2848a22c44 100644 --- a/clocks-impl.cc +++ b/clocks-impl.cc @@ -6,9 +6,8 @@ * SPDX-License-Identifier: AGPL-3.0-or-later */ -#include +#include -#include "db_clock.hh" #include "timestamp.hh" #include "clocks-impl.hh" @@ -16,7 +15,6 @@ std::atomic clocks_offset; std::string format_timestamp(api::timestamp_type ts) { - auto t = std::time_t(std::chrono::duration_cast(api::timestamp_clock::duration(ts)).count()); - ::tm t_buf; - return format("{}", std::put_time(::gmtime_r(&t, &t_buf), "%Y/%m/%d %T")); + std::chrono::system_clock::time_point when{api::timestamp_clock::duration(ts)}; + return fmt::format("{:%Y/%m/%d %T}", when); }