summaryrefslogtreecommitdiff
path: root/src/common/time_zone.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-08-19 18:27:49 -0400
committerGravatar GitHub2020-08-19 18:27:49 -0400
commit354811e5562568ef61f62e3da8e1398ec83faac0 (patch)
treeb182420db4cff61cc83d6e05a7783b0800d434e4 /src/common/time_zone.cpp
parentMerge pull request #4539 from lioncash/disc (diff)
parentRevert "common/time_zone: Simplify GetOsTimeZoneOffset()" (diff)
downloadyuzu-354811e5562568ef61f62e3da8e1398ec83faac0.tar.gz
yuzu-354811e5562568ef61f62e3da8e1398ec83faac0.tar.xz
yuzu-354811e5562568ef61f62e3da8e1398ec83faac0.zip
Merge pull request #4552 from yuzu-emu/revert-4537-tz
Revert "common/time_zone: Simplify GetOsTimeZoneOffset()"
Diffstat (limited to 'src/common/time_zone.cpp')
-rw-r--r--src/common/time_zone.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/common/time_zone.cpp b/src/common/time_zone.cpp
index 7aa1b59ea..ce239eb63 100644
--- a/src/common/time_zone.cpp
+++ b/src/common/time_zone.cpp
@@ -3,9 +3,8 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include <chrono> 5#include <chrono>
6#include <ctime> 6#include <iomanip>
7 7#include <sstream>
8#include <fmt/chrono.h>
9 8
10#include "common/logging/log.h" 9#include "common/logging/log.h"
11#include "common/time_zone.h" 10#include "common/time_zone.h"
@@ -17,8 +16,13 @@ std::string GetDefaultTimeZone() {
17} 16}
18 17
19static std::string GetOsTimeZoneOffset() { 18static std::string GetOsTimeZoneOffset() {
20 // Get the current timezone offset, e.g. "-400", as a string 19 const std::time_t t{std::time(nullptr)};
21 return fmt::format("%z", fmt::localtime(std::time(nullptr))); 20 const std::tm tm{*std::localtime(&t)};
21
22 std::stringstream ss;
23 ss << std::put_time(&tm, "%z"); // Get the current timezone offset, e.g. "-400", as a string
24
25 return ss.str();
22} 26}
23 27
24static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { 28static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) {