diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/common/settings.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp index 66dffc9bf..a1df69140 100644 --- a/src/common/settings.cpp +++ b/src/common/settings.cpp | |||
| @@ -1,6 +1,8 @@ | |||
| 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 <exception> | ||
| 5 | #include <stdexcept> | ||
| 4 | #if __cpp_lib_chrono >= 201907L | 6 | #if __cpp_lib_chrono >= 201907L |
| 5 | #include <chrono> | 7 | #include <chrono> |
| 6 | #endif | 8 | #endif |
| @@ -25,9 +27,19 @@ std::string GetTimeZoneString() { | |||
| 25 | if (time_zone_index == 0) { // Auto | 27 | if (time_zone_index == 0) { // Auto |
| 26 | #if __cpp_lib_chrono >= 201907L | 28 | #if __cpp_lib_chrono >= 201907L |
| 27 | const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb(); | 29 | 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(); | 30 | try { |
| 29 | std::string_view current_zone_name = current_zone->name(); | 31 | const std::chrono::time_zone* current_zone = time_zone_data.current_zone(); |
| 30 | location_name = current_zone_name; | 32 | std::string_view current_zone_name = current_zone->name(); |
| 33 | location_name = current_zone_name; | ||
| 34 | } catch (std::runtime_error& runtime_error) { | ||
| 35 | // VCRUNTIME will throw a runtime_error if the operating system's selected time zone | ||
| 36 | // cannot be found | ||
| 37 | location_name = Common::TimeZone::FindSystemTimeZone(); | ||
| 38 | LOG_WARNING(Common, | ||
| 39 | "Error occurred when trying to determine system time zone:\n{}\nFalling " | ||
| 40 | "back to hour offset \"{}\"", | ||
| 41 | runtime_error.what(), location_name); | ||
| 42 | } | ||
| 31 | #else | 43 | #else |
| 32 | location_name = Common::TimeZone::FindSystemTimeZone(); | 44 | location_name = Common::TimeZone::FindSystemTimeZone(); |
| 33 | #endif | 45 | #endif |