summaryrefslogtreecommitdiff
path: root/Source/Core/Common/Timer.cpp
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2015-11-08 02:20:56 +1300
committerScott Mansell <phiren@gmail.com>2015-11-08 02:20:56 +1300
commit973118511aab5e4a0724aaeae065048e8357e9e6 (patch)
tree448324267d5d376bcaa347cdc6acf5905bf0f145 /Source/Core/Common/Timer.cpp
parentbdbe8e3691527b37338649c7992b6c15d71386df (diff)
parent1772eeb32f2594e57895c4655638638c4e6ab11f (diff)
Merge pull request #2742 from AdmiralCurtiss/display-savestate-stats
Display Savestate information in Overlay and Menu.
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