diff options
author | Antonius Hellmann <toni@rockbox.org> | 2007-05-04 07:37:19 +0000 |
---|---|---|
committer | Antonius Hellmann <toni@rockbox.org> | 2007-05-04 07:37:19 +0000 |
commit | d68a51680f29afddac040dbebf1eeb5c4612ffa9 (patch) | |
tree | 85450ddf96030a4cc5fb426e11630e3b16503a50 /firmware/drivers/rtc | |
parent | d7e8e3825341b6b8007d7174e4874c1c5d4542d4 (diff) |
date calculation corrected, fixes #7096 and #7097
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13318 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/drivers/rtc')
-rw-r--r-- | firmware/drivers/rtc/rtc_as3514.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/firmware/drivers/rtc/rtc_as3514.c b/firmware/drivers/rtc/rtc_as3514.c index 9b8f9c330c..2190b20a53 100644 --- a/firmware/drivers/rtc/rtc_as3514.c +++ b/firmware/drivers/rtc/rtc_as3514.c @@ -68,13 +68,13 @@ int rtc_read_datetime(unsigned char* buf) year = 1980; while(seconds>=LEAP_YEAR_SECONDS) { - year++; - if(is_leapyear(year)){ seconds -= LEAP_YEAR_SECONDS; } else { seconds -= YEAR_SECONDS; } + + year++; } if(is_leapyear(year)) { @@ -102,6 +102,7 @@ int rtc_read_datetime(unsigned char* buf) /* Month Day */ buf[4] = seconds/DAY_SECONDS; seconds -= buf[4]*DAY_SECONDS; + buf[4]++; /* 1 ... 31 */ /* Hour */ buf[2] = seconds/HOUR_SECONDS; @@ -146,7 +147,7 @@ int rtc_write_datetime(unsigned char* buf) } /* Number of days in years gone by since 1-Jan-1980 */ - year_days = 365*(buf[6]+20) + buf[6]/4 + 6; + year_days = 365*(buf[6]+20) + (buf[6]-1)/4 + 6; /* Convert to seconds since 1-Jan-1980 */ seconds = buf[0] |