diff options
-rw-r--r-- | include/global.h | 4 | ||||
-rw-r--r-- | src/rtc_util.c | 14 |
2 files changed, 18 insertions, 0 deletions
diff --git a/include/global.h b/include/global.h index 1747446f3..8987fdf6a 100644 --- a/include/global.h +++ b/include/global.h @@ -3,6 +3,10 @@ #include "gba/gba.h" +#ifndef REVISION +#define REVISION 0 +#endif + extern u8 gStringVar1[]; extern u8 gStringVar2[]; extern u8 gStringVar3[]; 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]; |