summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/time/time_manager.cpp11
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.cpp24
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 @@
5#include <chrono> 5#include <chrono>
6#include <ctime> 6#include <ctime>
7 7
8#include "common/time_zone.h"
8#include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h" 9#include "core/hle/service/time/ephemeral_network_system_clock_context_writer.h"
9#include "core/hle/service/time/local_system_clock_context_writer.h" 10#include "core/hle/service/time/local_system_clock_context_writer.h"
10#include "core/hle/service/time/network_system_clock_context_writer.h" 11#include "core/hle/service/time/network_system_clock_context_writer.h"
@@ -21,8 +22,16 @@ static std::chrono::seconds GetSecondsSinceEpoch() {
21 Settings::values.custom_rtc_differential; 22 Settings::values.custom_rtc_differential;
22} 23}
23 24
25static s64 GetExternalTimeZoneOffset() {
26 // With "auto" timezone setting, we use the external system's timezone offset
27 if (Settings::GetTimeZoneString() == "auto") {
28 return Common::TimeZone::GetCurrentOffsetSeconds();
29 }
30 return 0;
31}
32
24static s64 GetExternalRtcValue() { 33static s64 GetExternalRtcValue() {
25 return GetSecondsSinceEpoch().count(); 34 return GetSecondsSinceEpoch().count() + GetExternalTimeZoneOffset();
26} 35}
27 36
28TimeManager::TimeManager(Core::System& system) 37TimeManager::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 @@
5#include <sstream> 5#include <sstream>
6 6
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "common/time_zone.h"
8#include "core/core.h" 9#include "core/core.h"
9#include "core/file_sys/content_archive.h" 10#include "core/file_sys/content_archive.h"
10#include "core/file_sys/nca_metadata.h" 11#include "core/file_sys/nca_metadata.h"
@@ -14,6 +15,7 @@
14#include "core/hle/service/filesystem/filesystem.h" 15#include "core/hle/service/filesystem/filesystem.h"
15#include "core/hle/service/time/time_manager.h" 16#include "core/hle/service/time/time_manager.h"
16#include "core/hle/service/time/time_zone_content_manager.h" 17#include "core/hle/service/time/time_zone_content_manager.h"
18#include "core/settings.h"
17 19
18namespace Service::Time::TimeZone { 20namespace Service::Time::TimeZone {
19 21
@@ -68,10 +70,22 @@ static std::vector<std::string> BuildLocationNameCache(Core::System& system) {
68 70
69TimeZoneContentManager::TimeZoneContentManager(TimeManager& time_manager, Core::System& system) 71TimeZoneContentManager::TimeZoneContentManager(TimeManager& time_manager, Core::System& system)
70 : system{system}, location_name_cache{BuildLocationNameCache(system)} { 72 : system{system}, location_name_cache{BuildLocationNameCache(system)} {
71 if (FileSys::VirtualFile vfs_file; GetTimeZoneInfoFile("GMT", vfs_file) == RESULT_SUCCESS) { 73
74 std::string location_name;
75 const auto timezone_setting = Settings::GetTimeZoneString();
76 if (timezone_setting == "auto") {
77 location_name = Common::TimeZone::GetDefaultTimeZone();
78 } else if (timezone_setting == "default") {
79 location_name = location_name;
80 } else {
81 location_name = timezone_setting;
82 }
83
84 if (FileSys::VirtualFile vfs_file;
85 GetTimeZoneInfoFile(location_name, vfs_file) == RESULT_SUCCESS) {
72 const auto time_point{ 86 const auto time_point{
73 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)}; 87 time_manager.GetStandardSteadyClockCore().GetCurrentTimePoint(system)};
74 time_manager.SetupTimeZoneManager("GMT", time_point, location_name_cache.size(), {}, 88 time_manager.SetupTimeZoneManager(location_name, time_point, location_name_cache.size(), {},
75 vfs_file); 89 vfs_file);
76 } else { 90 } else {
77 time_zone_manager.MarkAsInitialized(); 91 time_zone_manager.MarkAsInitialized();
@@ -114,6 +128,12 @@ ResultCode TimeZoneContentManager::GetTimeZoneInfoFile(const std::string& locati
114 128
115 vfs_file = zoneinfo_dir->GetFile(location_name); 129 vfs_file = zoneinfo_dir->GetFile(location_name);
116 if (!vfs_file) { 130 if (!vfs_file) {
131 LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"! Using default timezone.",
132 time_zone_binary_titleid, location_name);
133 vfs_file = zoneinfo_dir->GetFile(Common::TimeZone::GetDefaultTimeZone());
134 }
135
136 if (!vfs_file) {
117 LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"!", time_zone_binary_titleid, 137 LOG_ERROR(Service_Time, "{:016X} has no file \"{}\"!", time_zone_binary_titleid,
118 location_name); 138 location_name);
119 return ERROR_TIME_NOT_FOUND; 139 return ERROR_TIME_NOT_FOUND;