diff options
Diffstat (limited to '')
| -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 |