-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FakeRtc datetime and ResetRtcScreen day increments #5695
base: upcoming
Are you sure you want to change the base?
Conversation
@pkmnsnfrn do you think you could review this? |
I intend to review this, but I sent this to cawt and my concern stands:
|
2 Options:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing in testing revealed any issues
I would like to do a future PR that makes more of this data readily accessible via scripts like date and day of week but that's not needed right now!
@@ -32,15 +40,16 @@ void FakeRtc_TickTimeForward(void) | |||
if (FlagGet(OW_FLAG_PAUSE_TIME)) | |||
return; | |||
|
|||
FakeRtc_AdvanceTimeBy(0, 0, FakeRtc_GetSecondsRatio()); | |||
FakeRtc_AdvanceTimeBy(0, 0, 0, FakeRtc_GetSecondsRatio()); | |||
} | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static void FakeRtc_AdvanceSeconds(struct SiiRtcInfo *rtc, u32 *days, u32*hours, u32 *minutes, u32 *seconds) | |
{ | |
*seconds += rtc->second; | |
*minutes += rtc->minute; | |
*hours += rtc->hour; | |
while (*seconds >= SECONDS_PER_MINUTE) | |
{ | |
*minutes++; | |
*seconds -= SECONDS_PER_MINUTE; | |
} | |
while (*minutes >= MINUTES_PER_HOUR) | |
{ | |
*hours++; | |
*minutes -= MINUTES_PER_HOUR; | |
} | |
while (*hours >= HOURS_PER_DAY) | |
{ | |
*days++; | |
*hours -= HOURS_PER_DAY; | |
} | |
rtc->second = *seconds; | |
rtc->minute = *minutes; | |
rtc->hour = *hours; | |
} | |
static void FakeRtc_SetDayOfWeek(struct SiiRtcInfo *rtc, u32 daysToAdd) | |
{ | |
rtc->dayOfWeek = (rtc->dayOfWeek + daysToAdd) % WEEKDAY_COUNT; | |
} | |
static void FakeRtc_AdvanceDays(struct SiiRtcInfo *rtc, u32 *days) | |
{ | |
u32 remainingDaysInMonth = (sNumDaysInMonths[rtc->month - 1] + (rtc->month == MONTH_FEB && IsLeapYear(rtc->year)) - rtc->day); | |
if (*days > remainingDaysInMonth) | |
{ | |
rtc->day = 1; | |
rtc->month++; | |
if (rtc->month > MONTH_DEC) | |
{ | |
rtc->month = MONTH_JAN; | |
rtc->year++; | |
} | |
*days -= (remainingDaysInMonth + 1); | |
FakeRtc_SetDayOfWeek(rtc, remainingDaysInMonth + 1); | |
} | |
else | |
{ | |
rtc->day += *days; | |
FakeRtc_SetDayOfWeek(rtc, *days); | |
*days = 0; | |
} | |
} |
rtc->dayOfWeek = (rtc->dayOfWeek + days) % WEEKDAY_COUNT; | ||
days = 0; | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Github is being stupid but I'm trying to leave a suggestion to replace this function with
void FakeRtc_AdvanceTimeBy(u32 days, u32 hours, u32 minutes, u32 seconds)
{
struct SiiRtcInfo *rtc = FakeRtc_GetCurrentTime();
FakeRtc_AdvanceSeconds(rtc, &days, &hours, &minutes, &seconds);
while (days > 0)
FakeRtc_AdvanceDays(rtc, &days);
}
Description
Adds date extraction to FakeRtc_GetRawInfo. FakeRtc currently discards any date information.
Also added different day increments to ResetRtcScreen.
Discord contact info
.cawt