diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/hle/service/time/time_manager.cpp | 11 | ||||
-rw-r--r-- | src/core/hle/service/time/time_zone_content_manager.cpp | 24 |
2 files changed, 32 insertions, 3 deletions
diff --git a/src/core/hle/service/time/time_manager.cpp b/src/core/hle/service/time/time_manager.cpp index 9d6c55865..54f4a3f04 100644 --- a/src/core/hle/service/time/time_manager.cpp +++ b/src/core/hle/service/time/time_manager.cpp @@ -5,6 +5,7 @@ #include <chrono> #include <ctime> +#include "common/time_zone.h" #include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h" #include "core/hle/service/time/local_system_clock_context_writer.h" #include "core/hle/service/time/network_system_clock_context_writer.h" @@ -21,8 +22,16 @@ static std::chrono::seconds GetSecondsSinceEpoch() { Settings::values.custom_rtc_differential; } +static s64 GetExternalTimeZoneOffset() { + // With "auto" timezone setting, we use the external system's timezone offset + if (Settings::GetTimeZoneString() == "auto") { + return Common::TimeZone::GetCurrentOffsetSeconds(); + } + return 0; +} + static s64 GetExternalRtcValue() { - return GetSecondsSinceEpoch().count(); + return GetSecondsSinceEpoch().count() + GetExternalTimeZoneOffset(); } TimeManager::TimeManager(Core::System& system) 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 78d4acd95..c070d6e97 100644 --- a/src/core/hle/service/time/time_zone_content_manager.cpp +++ b/src/core/hle/service/time/time_zone_content_manager.cpp @@ -5,6 +5,7 @@ #include <sstream> #include "common/logging/log.h" +#include "common/time_zone.h" #include "core/core.h" #include "core/file_sys/content_archive.h" #include "core/file_sys/nca_metadata.h" @@ -14,6 +15,7 @@ #include "core/hle/service/filesystem/filesystem.h" #include "core/hle/service/time/time_manager.h" #include "core/hle/service/time/time_zone_content_manager.h" +#include "core/settings.h" namespace Service::Time::TimeZone { @@ -68,10 +70,22 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) { TimeZoneContentManager::TimeZoneContentManager(TimeManager& time_manager, Core::System& system) : system{system}, location_name_cache{BuildLocationNameCache(system)} { - if (FileSys::VirtualFile vfs_file; GetTimeZoneInfoFile("GMT", vfs_file) == RESULT_SUCCESS) { + + std::string location_name; + const auto timezone_setting = Settings::GetTimeZoneString(); + if (timezone_setting == "auto") { + location_name = Common::TimeZone::GetDefaultTimeZone(); + } else if (timezone_setting == "default") { + location_name = location_name; + } else { + location_name = timezone_setting; + } + + if (FileSys::VirtualFile vfs_file; + GetTimeZoneInfoFile(location_name, vfs_file) == RESULT_SUCCESS) { const auto time_point{ time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)}; - time_manager.SetupTimeZoneManager("GMT", time_point, location_name_cache.size(), {}, + time_manager.SetupTimeZoneManager(location_name, time_point, location_name_cache.size(), {}, vfs_file); } else { time_zone_manager.MarkAsInitialized(); @@ -114,6 +128,12 @@ ResultCode TimeZoneContentManager::GetTimeZoneInfoFile(const std::string& locati vfs_file = zoneinfo_dir->GetFile(location_name); if (!vfs_file) { + LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"! Using default timezone.", + time_zone_binary_titleid, location_name); + vfs_file = zoneinfo_dir->GetFile(Common::TimeZone::GetDefaultTimeZone()); + } + + if (!vfs_file) { LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"!", time_zone_binary_titleid, location_name); return ERROR_TIME_NOT_FOUND; |