From 16272f49750699a06937defea5d7ee140eed1ac1 Mon Sep 17 00:00:00 2001 From: "Admiral H. Curtiss" Date: Sun, 12 Jul 2015 01:49:12 +0200 Subject: SaveState/DolphinWX: Display time and date of savestate when a slot is selected, or Empty if no savestate exists in the slot. --- Source/Core/Common/Timer.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'Source/Core/Common/Timer.cpp') diff --git a/Source/Core/Common/Timer.cpp b/Source/Core/Common/Timer.cpp index 451e6a0725..4ad69fdc23 100644 --- a/Source/Core/Common/Timer.cpp +++ b/Source/Core/Common/Timer.cpp @@ -225,7 +225,6 @@ std::string Timer::GetTimeFormatted() } // Returns a timestamp with decimals for precise time comparisons -// ---------------- double Timer::GetDoubleTime() { #ifdef _WIN32 @@ -245,7 +244,7 @@ double Timer::GetDoubleTime() // sure that we are detecting actual actions, perhaps 60 seconds is // enough really, but I leave a year of seconds anyway, in case the // user's clock is incorrect or something like that. - TmpSeconds = TmpSeconds - (38 * 365 * 24 * 60 * 60); + TmpSeconds = TmpSeconds - DOUBLE_TIME_OFFSET; // Make a smaller integer that fits in the double u32 Seconds = (u32)TmpSeconds; @@ -261,4 +260,16 @@ double Timer::GetDoubleTime() return TmpTime; } +// Formats a timestamp from GetDoubleTime() into a date and time string +std::string Timer::GetDateTimeFormatted(double time) +{ + // revert adjustments from GetDoubleTime() to get a normal Unix timestamp again + time_t seconds = (time_t)time + DOUBLE_TIME_OFFSET; + tm* localTime = localtime(&seconds); + + char tmp[32] = {}; + strftime(tmp, sizeof(tmp), "%x %X", localTime); + return tmp; +} + } // Namespace Common -- cgit v1.2.3