diff options
| author | Jens Arnold <amiconn@rockbox.org> | 2006-03-10 19:17:01 +0000 |
|---|---|---|
| committer | Jens Arnold <amiconn@rockbox.org> | 2006-03-10 19:17:01 +0000 |
| commit | a738c3be31637872c622953fe749e10e295a9cd4 (patch) | |
| tree | bc751aa73868fee79f742a992d5556cc325da9be | |
| parent | 63ba93c9ca33094b61cdd4c14d8794fc78ddd1a2 (diff) | |
| download | rockbox-a738c3be31637872c622953fe749e10e295a9cd4.zip rockbox-a738c3be31637872c622953fe749e10e295a9cd4.tar.gz rockbox-a738c3be31637872c622953fe749e10e295a9cd4.tar.bz2 rockbox-a738c3be31637872c622953fe749e10e295a9cd4.tar.xz | |
Iriver firmware compatibility kludge: RTC year offset. The offset is chosen in a way to make leap years work correctly in rockbox; the original firmware will still be one year off but doesn't reset the date anymore. [We don't want to wait until 2016 ;-) ]
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8991 a1c6a512-1295-4272-9138-f99709370657
| -rw-r--r-- | firmware/common/timefuncs.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/firmware/common/timefuncs.c b/firmware/common/timefuncs.c index 5cf1a35..fb16f0c 100644 --- a/firmware/common/timefuncs.c +++ b/firmware/common/timefuncs.c @@ -62,7 +62,15 @@ struct tm *get_time(void) tm.tm_wday = rtcbuf[3] & 0x07; tm.tm_mday = ((rtcbuf[4] & 0x30) >> 4) * 10 + (rtcbuf[4] & 0x0f); tm.tm_mon = ((rtcbuf[5] & 0x10) >> 4) * 10 + (rtcbuf[5] & 0x0f) - 1; +#ifdef IRIVER_H300_SERIES + /* Special kludge to coexist with the iriver firmware. The iriver firmware + stores the date as 1965+nn, and allows a range of 1980..2064. We use + 1964+nn here to make leap years work correctly, so the date will be one + year off in the iriver firmware but at least won't be reset anymore. */ + tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 64; +#else tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100; +#endif tm.tm_yday = 0; /* Not implemented for now */ tm.tm_isdst = -1; /* Not implemented for now */ @@ -99,7 +107,12 @@ int set_time(const struct tm *tm) rtcbuf[3]=tm->tm_wday; rtcbuf[4]=((tm->tm_mday/10) << 4) | (tm->tm_mday%10); rtcbuf[5]=(((tm->tm_mon+1)/10) << 4) | ((tm->tm_mon+1)%10); +#ifdef IRIVER_H300_SERIES + /* Iriver firmware compatibility kludge, see get_time(). */ + rtcbuf[6]=(((tm->tm_year-64)/10) << 4) | ((tm->tm_year-64)%10); +#else rtcbuf[6]=(((tm->tm_year-100)/10) << 4) | ((tm->tm_year-100)%10); +#endif rc = rtc_write_datetime(rtcbuf); |