diff -rupN rockbox-18563.orig/firmware/common/timefuncs.c rockbox-18563.patch/firmware/common/timefuncs.c --- rockbox-18563.orig/firmware/common/timefuncs.c 2008-09-22 11:36:59.000000000 +1000 +++ rockbox-18563.patch/firmware/common/timefuncs.c 2008-09-25 12:39:23.000000000 +1000 @@ -31,6 +31,7 @@ static struct tm tm; #endif + bool valid_time(const struct tm *tm) { if (tm->tm_hour < 0 || tm->tm_hour > 23 || @@ -50,6 +51,8 @@ struct tm *get_time(void) #ifndef SIMULATOR #if CONFIG_RTC static long timeout = 0; + static int m_to_d[12] = + {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334}; /* Don't read the RTC more than once per second */ if (current_tick > timeout) @@ -76,7 +79,12 @@ struct tm *get_time(void) tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100; #endif - tm.tm_yday = 0; /* Not implemented for now */ + tm.tm_yday = 0; + tm.tm_yday = m_to_d[tm.tm_mon] + tm.tm_mday; + if(tm.tm_mon > 1) /* check to see if its a leap year */ + if((!((tm.tm_year + 1900) % 4) && ((tm.tm_year + 1900) % 100)) || !((tm.tm_year + 1900) % 400)) + tm.tm_yday += 1; + tm.tm_isdst = -1; /* Not implemented for now */ #else rtc_read_datetime((unsigned char*)&tm);