From 15ecddc5132a87073e663245864188f3028fd221 Mon Sep 17 00:00:00 2001 From: Tinson Lai Date: Mon, 21 Aug 2023 16:42:16 +0800 Subject: [PATCH] Add back legacy time_point interface --- include/fmt/chrono.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index ff3e1445..e5c734db 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -477,11 +477,14 @@ inline std::tm localtime(std::time_t time) { return lt.tm_; } +inline std::tm localtime(std::chrono::system_clock::time_point time_point) { + return localtime(std::chrono::system_clock::to_time_t(time_point)); +} + #if FMT_USE_LOCAL_TIME template inline auto localtime(std::chrono::local_time time) -> std::tm { - return localtime(std::chrono::system_clock::to_time_t( - std::chrono::current_zone()->to_sys(time))); + return localtime(std::chrono::current_zone()->to_sys(time)); } #endif