From 5f2e61fdd5eb10695e4535cede6e2631f174d6f8 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Sun, 6 Apr 2025 09:54:47 -0700 Subject: [PATCH] Cleanup chrono detail --- include/fmt/chrono.h | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index c3a697d6..8024ddf5 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -505,26 +505,28 @@ auto to_time_t(sys_time time_point) -> std::time_t { } namespace tz { + +// DEPRECATED! struct time_zone { - template - auto to_sys(T) - -> std::chrono::time_point { + template + auto to_sys(LocalTime) -> sys_time { return {}; } }; -template inline auto current_zone(T...) -> time_zone* { +template auto current_zone(T...) -> time_zone* { return nullptr; } -template inline void _tzset(T...) {} +template void _tzset(T...) {} } // namespace tz -// Workaround a bug in libstdc++ which sets __cpp_lib_chrono to 201907 without -// providing current_zone(): https://github.com/fmtlib/fmt/issues/4160. -template FMT_CONSTEXPR auto has_current_zone() -> bool { - using namespace std::chrono; - using namespace tz; - return !std::is_same::value; +inline void tzset_once() { + static bool init = []() { + using namespace tz; + _tzset(); + return false; + }(); + ignore_unused(init); } } // namespace detail @@ -535,7 +537,7 @@ FMT_BEGIN_EXPORT * expressed in local time. Unlike `std::localtime`, this function is * thread-safe on most platforms. */ -inline auto localtime(std::time_t time) -> std::tm { +FMT_DEPRECATED inline auto localtime(std::time_t time) -> std::tm { struct dispatcher { std::time_t time_; std::tm tm_; @@ -572,9 +574,8 @@ inline auto localtime(std::time_t time) -> std::tm { } #if FMT_USE_LOCAL_TIME -template ())> -FMT_DEPRECATED inline auto localtime(std::chrono::local_time time) +template +FMT_DEPRECATED auto localtime(std::chrono::local_time time) -> std::tm { using namespace std::chrono; using namespace detail::tz; @@ -1003,15 +1004,6 @@ template struct has_member_data_tm_zone> : std::true_type {}; -inline void tzset_once() { - static bool init = []() { - using namespace tz; - _tzset(); - return false; - }(); - ignore_unused(init); -} - // Converts value to Int and checks that it's in the range [0, upper). template ::value)> inline auto to_nonnegative_int(T value, Int upper) -> Int {