summaryrefslogtreecommitdiff
path: root/firmware/common/timefuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'firmware/common/timefuncs.c')
-rw-r--r--firmware/common/timefuncs.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c
index 5cf1a35a77..fb16f0c253 100644
--- a/firmware/common/timefuncs.c
+++ b/firmware/common/timefuncs.c
@@ -62,7 +62,15 @@ struct tm *get_time(void)
62 tm.tm_wday = rtcbuf[3] & 0x07; 62 tm.tm_wday = rtcbuf[3] & 0x07;
63 tm.tm_mday = ((rtcbuf[4] & 0x30) >> 4) * 10 + (rtcbuf[4] & 0x0f); 63 tm.tm_mday = ((rtcbuf[4] & 0x30) >> 4) * 10 + (rtcbuf[4] & 0x0f);
64 tm.tm_mon = ((rtcbuf[5] & 0x10) >> 4) * 10 + (rtcbuf[5] & 0x0f) - 1; 64 tm.tm_mon = ((rtcbuf[5] & 0x10) >> 4) * 10 + (rtcbuf[5] & 0x0f) - 1;
65#ifdef IRIVER_H300_SERIES
66 /* Special kludge to coexist with the iriver firmware. The iriver firmware
67 stores the date as 1965+nn, and allows a range of 1980..2064. We use
68 1964+nn here to make leap years work correctly, so the date will be one
69 year off in the iriver firmware but at least won't be reset anymore. */
70 tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 64;
71#else
65 tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100; 72 tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100;
73#endif
66 74
67 tm.tm_yday = 0; /* Not implemented for now */ 75 tm.tm_yday = 0; /* Not implemented for now */
68 tm.tm_isdst = -1; /* Not implemented for now */ 76 tm.tm_isdst = -1; /* Not implemented for now */
@@ -99,7 +107,12 @@ int set_time(const struct tm *tm)
99 rtcbuf[3]=tm->tm_wday; 107 rtcbuf[3]=tm->tm_wday;
100 rtcbuf[4]=((tm->tm_mday/10) << 4) | (tm->tm_mday%10); 108 rtcbuf[4]=((tm->tm_mday/10) << 4) | (tm->tm_mday%10);
101 rtcbuf[5]=(((tm->tm_mon+1)/10) << 4) | ((tm->tm_mon+1)%10); 109 rtcbuf[5]=(((tm->tm_mon+1)/10) << 4) | ((tm->tm_mon+1)%10);
110#ifdef IRIVER_H300_SERIES
111 /* Iriver firmware compatibility kludge, see get_time(). */
112 rtcbuf[6]=(((tm->tm_year-64)/10) << 4) | ((tm->tm_year-64)%10);
113#else
102 rtcbuf[6]=(((tm->tm_year-100)/10) << 4) | ((tm->tm_year-100)%10); 114 rtcbuf[6]=(((tm->tm_year-100)/10) << 4) | ((tm->tm_year-100)%10);
115#endif
103 116
104 rc = rtc_write_datetime(rtcbuf); 117 rc = rtc_write_datetime(rtcbuf);
105 118