These are the relevant function:
https://github.com/pret/pokeemerald/blob/master/src/field_specials.c#L1555
u16 GetDaysUntilPacifidlogTMAvailable(void)
{
u16 tmReceivedDay = VarGet(VAR_PACIFIDLOG_TM_RECEIVED_DAY);
if (gLocalTime.days - tmReceivedDay >= 7)
return 0;
else if (gLocalTime.days < 0)
return 8;
return 7 - (gLocalTime.days - tmReceivedDay);
}
u16 SetPacifidlogTMReceivedDay(void)
{
VarSet(VAR_PACIFIDLOG_TM_RECEIVED_DAY, gLocalTime.days);
return gLocalTime.days;
}
gLocalTime.days returns the current days from the RTC. In the Get function the last line "gLocalTime.days - tmReceivedDay" can result in a negative value if tmReceivedDay is greater gLocalTime.days, which can then result in high numbers. But it shouldn't be as high as 65,227.