diff --git a/include/fmt/chrono.h b/include/fmt/chrono.h index 1c798df9..c3a697d6 100644 --- a/include/fmt/chrono.h +++ b/include/fmt/chrono.h @@ -22,21 +22,6 @@ #include "format.h" -namespace fmt_detail { -struct time_zone { - template - auto to_sys(T) - -> std::chrono::time_point { - return {}; - } -}; -template inline auto current_zone(T...) -> time_zone* { - return nullptr; -} - -template inline void _tzset(T...) {} -} // namespace fmt_detail - FMT_BEGIN_NAMESPACE // Enable safe chrono durations, unless explicitly disabled. @@ -519,12 +504,27 @@ auto to_time_t(sys_time time_point) -> std::time_t { .count(); } +namespace tz { +struct time_zone { + template + auto to_sys(T) + -> std::chrono::time_point { + return {}; + } +}; +template inline auto current_zone(T...) -> time_zone* { + return nullptr; +} + +template inline 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 fmt_detail; - return !std::is_same::value; + using namespace tz; + return !std::is_same::value; } } // namespace detail @@ -577,7 +577,7 @@ template time) -> std::tm { using namespace std::chrono; - using namespace fmt_detail; + using namespace detail::tz; return localtime(detail::to_time_t(current_zone()->to_sys(time))); } #endif @@ -1005,7 +1005,7 @@ struct has_member_data_tm_zone> inline void tzset_once() { static bool init = []() { - using namespace fmt_detail; + using namespace tz; _tzset(); return false; }();