summaryrefslogtreecommitdiffstats
path: root/src/common/settings.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2023-06-13 22:28:45 +0200
committerGitHub <noreply@github.com>2023-06-13 22:28:45 +0200
commit698a3eda508ca0d3220452854b3ec977d7be5ea2 (patch)
treefc71df2feda7bfed6f686e3f7aa0fa8629aebc5d /src/common/settings.cpp
parentMerge pull request #10760 from FearlessTobi/translations (diff)
parenttz_manager: Fix comparison to wrong integer (diff)
downloadyuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar.gz
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar.bz2
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar.lz
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar.xz
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.tar.zst
yuzu-698a3eda508ca0d3220452854b3ec977d7be5ea2.zip
Diffstat (limited to 'src/common/settings.cpp')
-rw-r--r--src/common/settings.cpp31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 9ff3edabb..66dffc9bf 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -1,12 +1,16 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#if __cpp_lib_chrono >= 201907L
+#include <chrono>
+#endif
#include <string_view>
#include "common/assert.h"
#include "common/fs/path_util.h"
#include "common/logging/log.h"
#include "common/settings.h"
+#include "common/time_zone.h"
namespace Settings {
@@ -14,18 +18,23 @@ Values values;
static bool configuring_global = true;
std::string GetTimeZoneString() {
- static constexpr std::array timezones{
- "auto", "default", "CET", "CST6CDT", "Cuba", "EET", "Egypt", "Eire",
- "EST", "EST5EDT", "GB", "GB-Eire", "GMT", "GMT+0", "GMT-0", "GMT0",
- "Greenwich", "Hongkong", "HST", "Iceland", "Iran", "Israel", "Jamaica", "Japan",
- "Kwajalein", "Libya", "MET", "MST", "MST7MDT", "Navajo", "NZ", "NZ-CHAT",
- "Poland", "Portugal", "PRC", "PST8PDT", "ROC", "ROK", "Singapore", "Turkey",
- "UCT", "Universal", "UTC", "W-SU", "WET", "Zulu",
- };
-
const auto time_zone_index = static_cast<std::size_t>(values.time_zone_index.GetValue());
- ASSERT(time_zone_index < timezones.size());
- return timezones[time_zone_index];
+ ASSERT(time_zone_index < Common::TimeZone::GetTimeZoneStrings().size());
+
+ std::string location_name;
+ if (time_zone_index == 0) { // Auto
+#if __cpp_lib_chrono >= 201907L
+ const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb();
+ const std::chrono::time_zone* current_zone = time_zone_data.current_zone();
+ std::string_view current_zone_name = current_zone->name();
+ location_name = current_zone_name;
+#else
+ location_name = Common::TimeZone::FindSystemTimeZone();
+#endif
+ } else {
+ location_name = Common::TimeZone::GetTimeZoneStrings()[time_zone_index];
+ }
+ return location_name;
}
void LogSettings() {