From 4b9c9b97fba7e7bb38286ef8dab07fac9157bb18 Mon Sep 17 00:00:00 2001 From: Filip Brcic Date: Tue, 18 May 2021 22:22:36 +0200 Subject: [PATCH] Do not compute localtime twice --- include/fmt/chrono.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 85d152f0..2d69db0c 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -411,7 +411,7 @@ struct formatter auto format(std::chrono::time_point val, FormatContext& ctx) -> decltype(ctx.out()) { - std::tm time = localtime(val); + std::tm time; auto epoch = val.time_since_epoch(); auto seconds = std::chrono::duration_cast(epoch); auto subseconds = std::chrono::duration_cast>(epoch - seconds); @@ -419,6 +419,8 @@ struct formatter 0) {