Fix two critical flaws in TimeZone logic

The first one was the month range being different fron Nintendo one
(0-11 instead of 1-12)

The other flaw was a bad incrementation order during days & months
computation.
This commit is contained in:
Thog 2019-10-01 00:56:58 +02:00
commit 5a2bf60e00
No known key found for this signature in database
GPG key ID: 0CD291558FAFDBC6
2 changed files with 5 additions and 5 deletions

View file

@ -68,7 +68,9 @@ namespace Ryujinx.HLE.HOS.Services.Time
TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>(); TimeSpanType testOffset = context.RequestData.ReadStruct<TimeSpanType>();
bool isRtcResetDetected = context.RequestData.ReadBoolean(); bool isRtcResetDetected = context.RequestData.ReadBoolean();
return _timeManager.SetupStandardSteadyClock(context.Thread, clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected); _timeManager.SetupStandardSteadyClock(context.Thread, clockSourceId, setupValue, internalOffset, testOffset, isRtcResetDetected);
return ResultCode.Success;
} }
[Command(11)] [Command(11)]

View file

@ -1357,10 +1357,8 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
int[] ip = MonthsLengths[IsLeap((int)year)]; int[] ip = MonthsLengths[IsLeap((int)year)];
while (dayOfYear >= ip[calendarTime.Month]) for (calendarTime.Month = 0; dayOfYear >= ip[calendarTime.Month]; ++calendarTime.Month)
{ {
calendarTime.Month += 1;
dayOfYear -= ip[calendarTime.Month]; dayOfYear -= ip[calendarTime.Month];
} }
@ -1709,7 +1707,7 @@ namespace Ryujinx.HLE.HOS.Services.Time.TimeZone
Time = new CalendarTime() Time = new CalendarTime()
{ {
Year = (short)calendarTime.Year, Year = (short)calendarTime.Year,
Month = calendarTime.Month, Month = (sbyte)(calendarTime.Month + 1),
Day = calendarTime.Day, Day = calendarTime.Day,
Hour = calendarTime.Hour, Hour = calendarTime.Hour,
Minute = calendarTime.Minute, Minute = calendarTime.Minute,