forked from ShuriZma/suyu
1
0
Fork 0

Merge pull request #4552 from yuzu-emu/revert-4537-tz

Revert "common/time_zone: Simplify GetOsTimeZoneOffset()"
This commit is contained in:
bunnei 2020-08-19 18:27:49 -04:00 committed by GitHub
commit 354811e556
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 5 deletions

View File

@ -3,9 +3,8 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <chrono> #include <chrono>
#include <ctime> #include <iomanip>
#include <sstream>
#include <fmt/chrono.h>
#include "common/logging/log.h" #include "common/logging/log.h"
#include "common/time_zone.h" #include "common/time_zone.h"
@ -17,8 +16,13 @@ std::string GetDefaultTimeZone() {
} }
static std::string GetOsTimeZoneOffset() { static std::string GetOsTimeZoneOffset() {
// Get the current timezone offset, e.g. "-400", as a string const std::time_t t{std::time(nullptr)};
return fmt::format("%z", fmt::localtime(std::time(nullptr))); const std::tm tm{*std::localtime(&t)};
std::stringstream ss;
ss << std::put_time(&tm, "%z"); // Get the current timezone offset, e.g. "-400", as a string
return ss.str();
} }
static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) {