Permalink
Browse files

Merge pull request #10123 from LunaMoo/betterTimestamp

Nicer Timestamp, optional followup for #10122
  • Loading branch information...
hrydgard committed Nov 14, 2017
2 parents ce1bc7f + e78a644 commit 7205699584ca9cf1a7ffa68f6c27191a5578b75d
Showing with 19 additions and 6 deletions.
  1. +1 −1 Core/AVIDump.cpp
  2. +2 −2 Core/HLE/__sceAudio.cpp
  3. +15 −2 Core/HLE/sceKernelTime.cpp
  4. +1 −1 Core/HLE/sceKernelTime.h
View
@@ -92,7 +92,7 @@ bool AVIDump::CreateAVI() {
// Use gameID_EmulatedTimestamp for filename
std::string discID = g_paramSFO.GetDiscID();
std::string video_file_name = StringFromFormat("%s%s_%d.avi", GetSysDirectory(DIRECTORY_VIDEO).c_str(), discID.c_str(), KernelTimeNow()).c_str();
std::string video_file_name = StringFromFormat("%s%s_%s.avi", GetSysDirectory(DIRECTORY_VIDEO).c_str(), discID.c_str(), KernelTimeNowFormatted().c_str()).c_str();
s_format_context = avformat_alloc_context();
std::stringstream s_file_index_str;
View
@@ -387,7 +387,7 @@ void __AudioUpdate(bool resetRecording) {
if (g_Config.bSaveLoadResetsAVdumping && resetRecording) {
__StopLogAudio();
std::string discID = g_paramSFO.GetDiscID();
std::string audio_file_name = StringFromFormat("%s%s_%d.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID.c_str(), KernelTimeNow()).c_str();
std::string audio_file_name = StringFromFormat("%s%s_%s.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID.c_str(), KernelTimeNowFormatted().c_str()).c_str();
INFO_LOG(COMMON, "Restarted audio recording to: %s", audio_file_name.c_str());
if (!File::Exists(GetSysDirectory(DIRECTORY_AUDIO)))
File::CreateDir(GetSysDirectory(DIRECTORY_AUDIO));
@@ -398,7 +398,7 @@ void __AudioUpdate(bool resetRecording) {
if (g_Config.bDumpAudio) {
// Use gameID_EmulatedTimestamp for filename
std::string discID = g_paramSFO.GetDiscID();
std::string audio_file_name = StringFromFormat("%s%s_%d.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID.c_str(), KernelTimeNow()).c_str();
std::string audio_file_name = StringFromFormat("%s%s_%s.wav", GetSysDirectory(DIRECTORY_AUDIO).c_str(), discID.c_str(), KernelTimeNowFormatted().c_str()).c_str();
INFO_LOG(COMMON,"Recording audio to: %s", audio_file_name.c_str());
// Create the path just in case it doesn't exist
if (!File::Exists(GetSysDirectory(DIRECTORY_AUDIO)))
View
@@ -31,6 +31,7 @@
#include "Core/HLE/sceKernelThread.h"
#include "Core/HLE/sceRtc.h"
#include "Core/MemMap.h"
#include "StringUtils.h"
// The time when the game started.
static time_t start_time;
@@ -172,6 +173,18 @@ u32 sceKernelLibcGettimeofday(u32 timeAddr, u32 tzAddr)
return 0;
}
u32 KernelTimeNow() {
return (u32)start_time + (u32)(CoreTiming::GetGlobalTimeUs() / 1000000ULL);
std::string KernelTimeNowFormatted() {
time_t emulatedTime = (time_t)start_time + (u32)(CoreTiming::GetGlobalTimeUs() / 1000000ULL);
tm* timePtr = localtime(&emulatedTime);
bool DST = timePtr->tm_isdst;
u8 seconds = timePtr->tm_sec;
u8 minutes = timePtr->tm_min;
u8 hours = timePtr->tm_hour;
if (DST)
hours = timePtr->tm_hour + 1;
u8 days = timePtr->tm_mday;
u8 months = timePtr->tm_mon + 1;
u16 years = timePtr->tm_year + 1900;
std::string timestamp = StringFromFormat("%04d-%02d-%02d_%02d-%02d-%02d", years, months, days, hours, minutes, seconds);
return timestamp;
}
View
@@ -27,7 +27,7 @@ int sceKernelSysClock2USec(u32 sysclockPtr, u32 highPtr, u32 lowPtr);
int sceKernelSysClock2USecWide(u32 lowClock, u32 highClock, u32 lowPtr, u32 highPtr);
u64 sceKernelUSec2SysClockWide(u32 usec);
u32 sceKernelLibcClock();
u32 KernelTimeNow();
std::string KernelTimeNowFormatted();
void __KernelTimeInit();
void __KernelTimeDoState(PointerWrap &p);

0 comments on commit 7205699

Please sign in to comment.