From 33005cef6bd2eb65b997423260ee94a987f076c4 Mon Sep 17 00:00:00 2001 From: YamaArashi Date: Wed, 3 Feb 2016 02:11:31 -0800 Subject: preliminary revision 2 support (fixing berry glitch) --- src/rtc_util.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/rtc_util.c') diff --git a/src/rtc_util.c b/src/rtc_util.c index 0149fcdc7..ba69d1d67 100644 --- a/src/rtc_util.c +++ b/src/rtc_util.c @@ -61,6 +61,9 @@ u16 ConvertDateToDayCount(u8 year, u8 month, u8 day) s32 i; u16 dayCount = 0; +#if (REVISION < 2) + // Revisions 0 and 1 don't add days for the year 2000, + // causing the berry glitch. for (i = year - 1; i > 0; i--) { dayCount += 365; @@ -68,6 +71,17 @@ u16 ConvertDateToDayCount(u8 year, u8 month, u8 day) if (IsLeapYear(i) == TRUE) dayCount++; } +#else + // Revision 2 has "i >= 0" as the condition instead of "i > 0", + // which fixes the issue. + for (i = year - 1; i >= 0; i--) + { + dayCount += 365; + + if (IsLeapYear(i) == TRUE) + dayCount++; + } +#endif for (i = 0; i < month - 1; i++) dayCount += gNumDaysInMonths[i]; -- cgit v1.2.3