Change KernelTimeNow to KernelTimeNowFormatted and return nice timestamp.

This commit is contained in:
LunaMoo 2017-11-14 07:16:40 +01:00
parent 2ff4104ddf
commit aba4a4dfdb
4 changed files with 19 additions and 6 deletions

View File

@ -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 File

@ -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 File

@ -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 = (u32)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).c_str();
return timestamp;
}

View File

@ -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);