From cff0d4ec71d2a5287ebf50992673284d03e4c827 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Mat=C4=9Bj?= Date: Mon, 20 Nov 2023 12:37:50 +0100 Subject: [PATCH] Epoch formatting: set whole seconds precision There was a change in fmt-10.0.0 which adds support for subsecond precision printing. Given that we want only whole seconds on the output round the time point to `std::chrono::seconds`. Closes: https://github.com/rpm-software-management/dnf5/issues/1020 --- common/utils/string.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/common/utils/string.hpp b/common/utils/string.hpp index 079aa6715..d2250484f 100644 --- a/common/utils/string.hpp +++ b/common/utils/string.hpp @@ -114,7 +114,8 @@ template inline std::string format_epoch(T epoch_num) { if (std::in_range(epoch_num)) { const auto epoch = static_cast(epoch_num); - return fmt::format("{:%F %X}", std::chrono::system_clock::from_time_t(epoch)); + return fmt::format( + "{:%F %X}", std::chrono::round(std::chrono::system_clock::from_time_t(epoch))); } return fmt::format("{} seconds since Unix epoch", epoch_num); }