From c378cbbc2dbd626e8def2c47f52ea21447dd705e Mon Sep 17 00:00:00 2001 From: lat9nq <22451773+lat9nq@users.noreply.github.com> Date: Sun, 21 May 2023 00:36:58 -0400 Subject: [PATCH] tz_content_manager: Detect system time zone Uses C++20 tzdb to determine the system timezone. The switch uses the 597 posix time zones, so this needs tests if the system time zone isn't posix-compliant. --- .../hle/service/time/time_zone_content_manager.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/core/hle/service/time/time_zone_content_manager.cpp b/src/core/hle/service/time/time_zone_content_manager.cpp index afbfe97153..ae41116b6c 100644 --- a/src/core/hle/service/time/time_zone_content_manager.cpp +++ b/src/core/hle/service/time/time_zone_content_manager.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include #include #include "common/logging/log.h" @@ -12,7 +13,11 @@ #include "core/file_sys/registered_cache.h" #include "core/file_sys/romfs.h" #include "core/file_sys/system_archive/system_archive.h" +#include "core/file_sys/vfs.h" +#include "core/file_sys/vfs_types.h" +#include "core/hle/result.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/time/errors.h" #include "core/hle/service/time/time_manager.h" #include "core/hle/service/time/time_zone_content_manager.h" @@ -73,7 +78,12 @@ TimeZoneContentManager::TimeZoneContentManager(Core::System& system_) void TimeZoneContentManager::Initialize(TimeManager& time_manager) { std::string location_name; const auto timezone_setting = Settings::GetTimeZoneString(); - if (timezone_setting == "auto" || timezone_setting == "default") { + if (timezone_setting == "auto") { + 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 if (timezone_setting == "default") { location_name = Common::TimeZone::GetDefaultTimeZone(); } else { location_name = timezone_setting;