summaryrefslogtreecommitdiff
path: root/src/rtc_util.c
diff options
context:
space:
mode:
authorYamaArashi <shadow962@live.com>2016-02-03 02:11:31 -0800
committerYamaArashi <shadow962@live.com>2016-02-03 02:14:14 -0800
commit33005cef6bd2eb65b997423260ee94a987f076c4 (patch)
treec6d786512fa9efc1a558526b2f0af6c26837e52c /src/rtc_util.c
parentd7894a90f4c355a9dd15d5fd7a3e739075103bba (diff)
preliminary revision 2 support (fixing berry glitch)
Diffstat (limited to 'src/rtc_util.c')
-rw-r--r--src/rtc_util.c14
1 files changed, 14 insertions, 0 deletions
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];