From 083b8172e0e5e4e55a20fbc85213604e8f377f75 Mon Sep 17 00:00:00 2001 From: vabold Date: Sat, 12 Nov 2022 04:03:38 -0500 Subject: [PATCH] Replace `std::time` with `std::chrono::system_clock` --- Source/Core/Core/IOS/DolphinDevice.cpp | 5 ++++- Source/Core/UICommon/DiscordPresence.cpp | 4 +++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/IOS/DolphinDevice.cpp b/Source/Core/Core/IOS/DolphinDevice.cpp index 558ef58809..85a71a83c2 100644 --- a/Source/Core/Core/IOS/DolphinDevice.cpp +++ b/Source/Core/Core/IOS/DolphinDevice.cpp @@ -241,7 +241,10 @@ IPCReply DolphinDevice::GetSystemTime(const IOCtlVRequest& request) const return IPCReply(IPC_EINVAL); } - const u64 milliseconds = std::time(nullptr); + // Write Unix timestamp in milliseconds to memory address + const u64 milliseconds = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); Memory::Write_U64(milliseconds, request.io_vectors[0].address); return IPCReply(IPC_SUCCESS); } diff --git a/Source/Core/UICommon/DiscordPresence.cpp b/Source/Core/UICommon/DiscordPresence.cpp index f269c27c0a..ff0afb5d25 100644 --- a/Source/Core/UICommon/DiscordPresence.cpp +++ b/Source/Core/UICommon/DiscordPresence.cpp @@ -290,7 +290,9 @@ void UpdateDiscordPresence(int party_size, SecretType type, const std::string& s discord_presence.smallImageText = "Dolphin is an emulator for the GameCube and the Wii."; } discord_presence.details = title.empty() ? "Not in-game" : title.c_str(); - discord_presence.startTimestamp = std::time(nullptr); + discord_presence.startTimestamp = std::chrono::duration_cast( + std::chrono::system_clock::now().time_since_epoch()) + .count(); if (party_size > 0) {