summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/time/time_zone_content_manager.cpp
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2020-05-11 23:55:25 +0200
committerbunnei <bunneidev@gmail.com>2020-05-11 23:55:25 +0200
commit3c8cd62b0db115a4812d8de81b70af72565bbdd7 (patch)
treee98500d894d696e823613b9b8373ebd866999572 /src/core/hle/service/time/time_zone_content_manager.cpp
parentcommon: Add module to get the current time zone. (diff)
downloadyuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar.gz
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar.bz2
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar.lz
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar.xz
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.tar.zst
yuzu-3c8cd62b0db115a4812d8de81b70af72565bbdd7.zip
Diffstat (limited to 'src/core/hle/service/time/time_zone_content_manager.cpp')
-rw-r--r--src/core/hle/service/time/time_zone_content_manager.cpp24
1 files changed, 22 insertions, 2 deletions
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;