feat: add system time offset setting (#6139)

* Add setting for system time offset

Add a setting to displace citra system time by days, hours, minutes
or seconds
Add UI for the setting which is only visible when clock is set to
system time
Change core/settings.h to include the setting

* Add system time offset to kernel

Actually makes use of the time offset.

* Fix time offset calculatioon in core/movie.cpp

* Replace C++20 chrono::days with seconds

Hopefully fixes the build.
This commit is contained in:
DaemonTsun 2022-11-20 16:34:53 +01:00 committed by GitHub
parent 3b6ffd9c27
commit 64062162c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 138 additions and 11 deletions

View file

@ -45,6 +45,16 @@ static std::chrono::seconds GetInitTime() {
std::tm* now_tm = std::localtime(&now_time_t);
if (now_tm && now_tm->tm_isdst > 0)
now = now + std::chrono::hours(1);
// add the offset
s64 init_time_offset = Settings::values.init_time_offset;
long long days_offset = init_time_offset / 86400;
long long days_offset_in_seconds = days_offset * 86400; // h/m/s truncated
unsigned long long seconds_offset =
std::abs(init_time_offset) - std::abs(days_offset_in_seconds);
now = now + std::chrono::seconds(seconds_offset);
now = now + std::chrono::seconds(days_offset_in_seconds);
return std::chrono::duration_cast<std::chrono::seconds>(now.time_since_epoch());
}
case Settings::InitClock::FixedTime: