From 15d6b095f730bfd6df91ad801c6a19b02bb16c3e Mon Sep 17 00:00:00 2001 From: squidbus <175574877+squidbus@users.noreply.github.com> Date: Fri, 22 Nov 2024 08:29:41 -0800 Subject: [PATCH] savedatadialog_ui: Use fmt::localtime instead of formatting std::chrono::local_time (#1574) --- .../save_data/dialog/savedatadialog_ui.cpp | 36 ++----------------- 1 file changed, 3 insertions(+), 33 deletions(-) diff --git a/src/core/libraries/save_data/dialog/savedatadialog_ui.cpp b/src/core/libraries/save_data/dialog/savedatadialog_ui.cpp index 52abe91014..4e0d801a6f 100644 --- a/src/core/libraries/save_data/dialog/savedatadialog_ui.cpp +++ b/src/core/libraries/save_data/dialog/savedatadialog_ui.cpp @@ -13,33 +13,6 @@ #include "imgui/imgui_std.h" #include "savedatadialog_ui.h" -#ifdef __APPLE__ -#include - -// Need to make a copy of the formatter for std::chrono::local_time for use with date::local_time -template -struct fmt::formatter, Char> : formatter { - FMT_CONSTEXPR formatter() { - this->format_str_ = fmt::detail::string_literal(); - } - - template - auto format(date::local_time val, FormatContext& ctx) const -> decltype(ctx.out()) { - using period = typename Duration::period; - if (period::num == 1 && period::den == 1 && - !std::is_floating_point::value) { - return formatter::format( - localtime(fmt::detail::to_time_t(date::current_zone()->to_sys(val))), ctx); - } - auto epoch = val.time_since_epoch(); - auto subsecs = fmt::detail::duration_cast( - epoch - fmt::detail::duration_cast(epoch)); - return formatter::do_format( - localtime(fmt::detail::to_time_t(date::current_zone()->to_sys(val))), ctx, &subsecs); - } -}; -#endif - using namespace ImGui; using namespace Libraries::CommonDialog; using Common::ElfInfo; @@ -125,12 +98,9 @@ SaveDialogState::SaveDialogState(const OrbisSaveDataDialogParam& param) { param_sfo.Open(param_sfo_path); auto last_write = param_sfo.GetLastWrite(); -#ifdef __APPLE__ - auto t = date::zoned_time{date::current_zone(), last_write}; -#else - auto t = std::chrono::zoned_time{std::chrono::current_zone(), last_write}; -#endif - std::string date_str = fmt::format("{:%d %b, %Y %R}", t.get_local_time()); + std::string date_str = + fmt::format("{:%d %b, %Y %R}", + fmt::localtime(std::chrono::system_clock::to_time_t(last_write))); size_t size = Common::FS::GetDirectorySize(dir_path); std::string size_str = SpaceSizeToString(size);