summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2015-07-12 01:49:12 +0200
committerAdmiral H. Curtiss <pikachu025@gmail.com>2015-10-10 22:14:22 +0200
commit16272f49750699a06937defea5d7ee140eed1ac1 (patch)
treedf4b6ced57717c32b3b6305280e276241abd0c69 /Source/Core/Common/Timer.cpp
parentdf20326d45e2f82dac77a633cf7a326149b0d8d7 (diff)
SaveState/DolphinWX: Display time and date of savestate when a slot is selected, or Empty if no savestate exists in the slot.
Diffstat (limited to 'Source/Core/Common/Timer.cpp')
-rw-r--r--Source/Core/Common/Timer.cpp15
1 files changed, 13 insertions, 2 deletions
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