diff options
| author | 2020-08-19 18:27:31 -0400 | |
|---|---|---|
| committer | 2020-08-19 18:27:31 -0400 | |
| commit | acbae572d32b80fd90c9a3465cc88fd72a51f36a (patch) | |
| tree | b182420db4cff61cc83d6e05a7783b0800d434e4 /src | |
| parent | Merge pull request #4539 from lioncash/disc (diff) | |
| download | yuzu-acbae572d32b80fd90c9a3465cc88fd72a51f36a.tar.gz yuzu-acbae572d32b80fd90c9a3465cc88fd72a51f36a.tar.xz yuzu-acbae572d32b80fd90c9a3465cc88fd72a51f36a.zip | |
Revert "common/time_zone: Simplify GetOsTimeZoneOffset()"
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/time_zone.cpp | 14 |
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 | ||
| 19 | static std::string GetOsTimeZoneOffset() { | 18 | static 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 | ||
| 24 | static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { | 28 | static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { |