diff options
| author | 2023-06-27 20:50:06 -0400 | |
|---|---|---|
| committer | 2023-06-27 20:50:06 -0400 | |
| commit | 0b2798be276941fb5ee9df346b5a566c29cea4ed (patch) | |
| tree | 370eb6fd83bf86a050e2cbc9d28abc7ccf3cc8f9 /src | |
| parent | Merge pull request #10931 from german77/clang (diff) | |
| parent | settings: Clean up includes (diff) | |
| download | yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.gz yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.xz yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.zip | |
Merge pull request #10930 from lat9nq/msvc-inconsistent-time-zones
settings: Catch runtime_error, fallback time zone
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 66dffc9bf..6cbbea1b2 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include <version> | ||
| 4 | #if __cpp_lib_chrono >= 201907L | 5 | #if __cpp_lib_chrono >= 201907L |
| 5 | #include <chrono> | 6 | #include <chrono> |
| 7 | #include <exception> | ||
| 8 | #include <stdexcept> | ||
| 6 | #endif | 9 | #endif |
| 7 | #include <string_view> | 10 | #include <string_view> |
| 8 | 11 | ||
| @@ -25,9 +28,19 @@ std::string GetTimeZoneString() { | |||
| 25 | if (time_zone_index == 0) { // Auto | 28 | if (time_zone_index == 0) { // Auto |
| 26 | #if __cpp_lib_chrono >= 201907L | 29 | #if __cpp_lib_chrono >= 201907L |
| 27 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); | 30 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); |
| 28 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); | 31 | try { |
| 29 | std::string_view current_zone_name = current_zone->name(); | 32 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); |
| 30 | location_name = current_zone_name; | 33 | std::string_view current_zone_name = current_zone->name(); |
| 34 | location_name = current_zone_name; | ||
| 35 | } catch (std::runtime_error& runtime_error) { | ||
| 36 | // VCRUNTIME will throw a runtime_error if the operating system's selected time zone | ||
| 37 | // cannot be found | ||
| 38 | location_name = Common::TimeZone::FindSystemTimeZone(); | ||
| 39 | LOG_WARNING(Common, | ||
| 40 | "Error occurred when trying to determine system time zone:\n{}\nFalling " | ||
| 41 | "back to hour offset \"{}\"", | ||
| 42 | runtime_error.what(), location_name); | ||
| 43 | } | ||
| 31 | #else | 44 | #else |
| 32 | location_name = Common::TimeZone::FindSystemTimeZone(); | 45 | location_name = Common::TimeZone::FindSystemTimeZone(); |
| 33 | #endif | 46 | #endif |