From 6fe89ff22b651af9e0ed65969e71278c310cf54b Mon Sep 17 00:00:00 2001 From: Project579 Date: Sat, 24 Sep 2022 21:14:07 +0200 Subject: [PATCH] Fix dumb regression, initialize "std::filesystem::file_time_type" with "clock::now()". --- apps/openmw/mwstate/character.cpp | 4 ++-- components/fx/technique.cpp | 2 +- components/misc/timeconvert.hpp | 12 ++++++++---- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwstate/character.cpp b/apps/openmw/mwstate/character.cpp index 847f82942d..85f5087fe6 100644 --- a/apps/openmw/mwstate/character.cpp +++ b/apps/openmw/mwstate/character.cpp @@ -79,7 +79,7 @@ void MWState::Character::addSlot(const ESM::SavedGame& profile) } slot.mProfile = profile; - slot.mTimeStamp = std::filesystem::file_time_type(); + slot.mTimeStamp = std::filesystem::file_time_type::clock::now(); mSlots.push_back(slot); } @@ -157,7 +157,7 @@ const MWState::Slot* MWState::Character::updateSlot(const Slot* slot, const ESM: Slot newSlot = *slot; newSlot.mProfile = profile; - newSlot.mTimeStamp = std::filesystem::file_time_type(); + newSlot.mTimeStamp = std::filesystem::file_time_type::clock::now(); mSlots.erase(mSlots.begin() + index); diff --git a/components/fx/technique.cpp b/components/fx/technique.cpp index e76a6d2551..2319eb4563 100644 --- a/components/fx/technique.cpp +++ b/components/fx/technique.cpp @@ -44,7 +44,7 @@ namespace fx : mName(std::move(name)) , mFileName(Files::pathToUnicodeString( (Files::pathFromUnicodeString(Technique::sSubdir) / (mName + Technique::sExt)))) - , mLastModificationTime(std::filesystem::file_time_type()) + , mLastModificationTime(std::filesystem::file_time_type::clock::now()) , mWidth(width) , mHeight(height) , mVFS(vfs) diff --git a/components/misc/timeconvert.hpp b/components/misc/timeconvert.hpp index 3c1459d91d..38fed712be 100644 --- a/components/misc/timeconvert.hpp +++ b/components/misc/timeconvert.hpp @@ -5,12 +5,16 @@ namespace Misc { - template - inline std::time_t toTimeT(TP tp) + inline std::time_t toTimeT(std::filesystem::file_time_type tp) { using namespace std::chrono; - auto sctp = time_point_cast(tp - TP::clock::now() + system_clock::now()); - return system_clock::to_time_t(sctp); +#if __cpp_lib_chrono >= 201907 + const auto systemTime = clock_cast(tp); +#else + auto systemTime = time_point_cast( + tp - std::filesystem::file_time_type::clock::now() + system_clock::now()); +#endif + return system_clock::to_time_t(systemTime); } inline std::string timeTToString(const std::time_t tp, const char* fmt)