Index: firmware/drivers/rtc/rtc_as3514.c =================================================================== --- firmware/drivers/rtc/rtc_as3514.c (revision 20206) +++ firmware/drivers/rtc/rtc_as3514.c (working copy) @@ -19,11 +19,18 @@ * ****************************************************************************/ #include +#include "config.h" #include "rtc.h" -#include "i2c-pp.h" #include "as3514.h" #include "ascodec.h" +/* Some Sansas start counting from Jan 1st 1970 instead of 1980 */ +#if defined(SANSA_C200V2) || defined(SANSA_E200V2) || defined(SANSA_FUZE) +#define REFERENCE_YEAR 1970 +#else +#define REFERENCE_YEAR 1980 +#endif + #define MINUTE_SECONDS 60 #define HOUR_SECONDS 3600 #define DAY_SECONDS 86400 @@ -62,14 +69,14 @@ } seconds = tmp[0] + (tmp[1]<<8) + (tmp[2]<<16) + (tmp[3]<<24); - /* Convert seconds since Jan-1-1980 to format compatible with + /* Convert seconds since the reference year to format compatible with * get_time() from firmware/common/timefuncs.c */ /* weekday */ buf[3] = ((seconds % WEEK_SECONDS) / DAY_SECONDS + 2) % 7; /* Year */ - year = 1980; + year = REFERENCE_YEAR; while(seconds>=LEAP_YEAR_SECONDS) { if(is_leapyear(year)){ @@ -150,10 +157,10 @@ month_days += days_in_month[i]; } - /* Number of days in years gone by since 1-Jan-1980 */ - year_days = 365*(buf[6]+20) + (buf[6]-1)/4 + 6; + /* Number of days in years gone by since the reference year */ + year_days = 365*(year - REFERENCE_YEAR) + (buf[6]-1)/4 + 6; - /* Convert to seconds since 1-Jan-1980 */ + /* Convert to seconds since the reference year */ seconds = buf[0] + buf[1]*MINUTE_SECONDS + buf[2]*HOUR_SECONDS