mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-31 12:31:45 +01:00
RSX: use localtime_s instead of localtime
This commit is contained in:
parent
f82739afb0
commit
d057c79733
32
Utilities/date_time.h
Normal file
32
Utilities/date_time.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
namespace date_time
|
||||
{
|
||||
static inline tm get_time(time_t* _time)
|
||||
{
|
||||
tm buf;
|
||||
time_t t = time(_time);
|
||||
#ifdef _MSC_VER
|
||||
localtime_s(&buf, &t);
|
||||
#else
|
||||
buf = *localtime(&t);
|
||||
#endif
|
||||
return buf;
|
||||
}
|
||||
|
||||
static inline std::string current_time()
|
||||
{
|
||||
char str[80];
|
||||
tm now = get_time(0);
|
||||
strftime(str, sizeof(str), "%c", &now);
|
||||
return str;
|
||||
}
|
||||
|
||||
static inline std::string current_time_narrow()
|
||||
{
|
||||
char str[80];
|
||||
tm now = get_time(0);
|
||||
strftime(str, sizeof(str), "%Y%m%d%H%M%S", &now);
|
||||
return str;
|
||||
}
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
#include "overlay_controls.h"
|
||||
|
||||
#include "../../../Utilities/date_time.h"
|
||||
#include "../../../Utilities/Thread.h"
|
||||
#include "../../Io/PadHandler.h"
|
||||
#include "Emu/Memory/vm.h"
|
||||
@ -14,8 +15,6 @@
|
||||
#include "Utilities/CPUStats.h"
|
||||
#include "Utilities/Timer.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
extern u64 get_system_time();
|
||||
|
||||
// Definition of user interface implementations
|
||||
@ -542,15 +541,6 @@ namespace rsx
|
||||
std::unique_ptr<label> m_time_thingy;
|
||||
std::unique_ptr<label> m_no_saves_text;
|
||||
|
||||
std::string current_time()
|
||||
{
|
||||
time_t t = time(NULL);
|
||||
char buf[128];
|
||||
strftime(buf, 128, "%c", localtime(&t));
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
bool m_no_saves = false;
|
||||
|
||||
public:
|
||||
@ -571,7 +561,7 @@ namespace rsx
|
||||
|
||||
m_time_thingy->set_font("Arial", 14);
|
||||
m_time_thingy->set_pos(1000, 30);
|
||||
m_time_thingy->text = current_time();
|
||||
m_time_thingy->text = date_time::current_time();
|
||||
|
||||
static_cast<label*>(m_description.get())->auto_resize();
|
||||
static_cast<label*>(m_time_thingy.get())->auto_resize();
|
||||
@ -723,7 +713,7 @@ namespace rsx
|
||||
|
||||
void update() override
|
||||
{
|
||||
m_time_thingy->set_text(current_time());
|
||||
m_time_thingy->set_text(date_time::current_time());
|
||||
static_cast<label*>(m_time_thingy.get())->auto_resize();
|
||||
}
|
||||
};
|
||||
|
@ -1,5 +1,4 @@
|
||||
#include "stdafx.h"
|
||||
#include "date_time.h"
|
||||
#include "rsx_methods.h"
|
||||
#include "RSXThread.h"
|
||||
#include "Emu/Memory/Memory.h"
|
||||
@ -1107,7 +1106,7 @@ namespace rsx
|
||||
rsx->capture_current_frame = false;
|
||||
std::stringstream os;
|
||||
cereal::BinaryOutputArchive archive(os);
|
||||
const std::string& filePath = fs::get_config_dir() + "captures/" + Emu.GetTitleID() + "_" + get_current_date_time() +"_capture.rrc";
|
||||
const std::string& filePath = fs::get_config_dir() + "captures/" + Emu.GetTitleID() + "_" + date_time::current_time_narrow() +"_capture.rrc";
|
||||
archive(frame_capture);
|
||||
{
|
||||
// todo: 'dynamicly' create capture filename, also may want to compress this data?
|
||||
|
@ -1,13 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <stdafx.h>
|
||||
|
||||
const std::string get_current_date_time()
|
||||
{
|
||||
time_t now = time(0);
|
||||
tm* tstruct = localtime(&now);
|
||||
char buf[80];
|
||||
strftime(buf, sizeof(buf), "%Y%m%d%H%M%S", tstruct);
|
||||
delete tstruct;
|
||||
return buf;
|
||||
}
|
@ -358,6 +358,7 @@
|
||||
<ClInclude Include="..\Utilities\cfmt.h" />
|
||||
<ClInclude Include="..\Utilities\cond.h" />
|
||||
<ClInclude Include="..\Utilities\CRC.h" />
|
||||
<ClInclude Include="..\Utilities\date_time.h" />
|
||||
<ClInclude Include="..\Utilities\dynamic_library.h" />
|
||||
<ClInclude Include="..\Utilities\event.h" />
|
||||
<ClInclude Include="..\Utilities\GDBDebugServer.h" />
|
||||
@ -390,7 +391,6 @@
|
||||
<ClInclude Include="Crypto\unpkg.h" />
|
||||
<ClInclude Include="Crypto\unself.h" />
|
||||
<ClInclude Include="Crypto\utils.h" />
|
||||
<ClInclude Include="date_time.h" />
|
||||
<ClInclude Include="define_new_memleakdetect.h" />
|
||||
<ClInclude Include="Emu\Cell\lv2\sys_gpio.h" />
|
||||
<ClInclude Include="Emu\Cell\lv2\sys_net.h" />
|
||||
|
@ -1447,7 +1447,7 @@
|
||||
<ClInclude Include="Emu\RSX\Overlays\overlays.h">
|
||||
<Filter>Emu\GPU\RSX\Overlays</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="date_time.h">
|
||||
<ClInclude Include="..\Utilities\date_time.h">
|
||||
<Filter>Utilities</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user