diff options
| author | 2020-08-17 14:27:02 -0400 | |
|---|---|---|
| committer | 2020-08-17 14:27:02 -0400 | |
| commit | 0c885249df93db3262ae6ed2df18ee1cad336723 (patch) | |
| tree | ae1f6ef67a15f224db53932df70e48faba5fb329 /src/common/time_zone.cpp | |
| parent | Merge pull request #4540 from lioncash/tr3 (diff) | |
| parent | common/time_zone: Simplify GetOsTimeZoneOffset() (diff) | |
| download | yuzu-0c885249df93db3262ae6ed2df18ee1cad336723.tar.gz yuzu-0c885249df93db3262ae6ed2df18ee1cad336723.tar.xz yuzu-0c885249df93db3262ae6ed2df18ee1cad336723.zip | |
Merge pull request #4537 from lioncash/tz
common/time_zone: Simplify GetOsTimeZoneOffset()
Diffstat (limited to 'src/common/time_zone.cpp')
| -rw-r--r-- | src/common/time_zone.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/common/time_zone.cpp b/src/common/time_zone.cpp index ce239eb63..7aa1b59ea 100644 --- a/src/common/time_zone.cpp +++ b/src/common/time_zone.cpp | |||
| @@ -3,8 +3,9 @@ | |||
| 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 <iomanip> | 6 | #include <ctime> |
| 7 | #include <sstream> | 7 | |
| 8 | #include <fmt/chrono.h> | ||
| 8 | 9 | ||
| 9 | #include "common/logging/log.h" | 10 | #include "common/logging/log.h" |
| 10 | #include "common/time_zone.h" | 11 | #include "common/time_zone.h" |
| @@ -16,13 +17,8 @@ std::string GetDefaultTimeZone() { | |||
| 16 | } | 17 | } |
| 17 | 18 | ||
| 18 | static std::string GetOsTimeZoneOffset() { | 19 | static std::string GetOsTimeZoneOffset() { |
| 19 | const std::time_t t{std::time(nullptr)}; | 20 | // Get the current timezone offset, e.g. "-400", as a string |
| 20 | const std::tm tm{*std::localtime(&t)}; | 21 | return fmt::format("%z", fmt::localtime(std::time(nullptr))); |
| 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(); | ||
| 26 | } | 22 | } |
| 27 | 23 | ||
| 28 | static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { | 24 | static int ConvertOsTimeZoneOffsetToInt(const std::string& timezone) { |