[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rockbox-cvs
Subject:    alle: r21561 - trunk/firmware/common
From:       mailer () svn ! rockbox ! org
Date:       2009-06-29 14:31:47
Message-ID: 200906291431.n5TEVlBM014622 () giant ! haxx ! se
[Download RAW message or body]

Date: 2009-06-29 16:31:46 +0200 (Mon, 29 Jun 2009)
New Revision: 21561

Log Message:
Make the get_time on non-RTC sims behave like target, i.e. always return a constant time (FS#10390)

Modified:
   trunk/firmware/common/timefuncs.c

Modified: trunk/firmware/common/timefuncs.c
===================================================================
--- trunk/firmware/common/timefuncs.c	2009-06-29 14:30:12 UTC (rev 21560)
+++ trunk/firmware/common/timefuncs.c	2009-06-29 14:31:46 UTC (rev 21561)
@@ -27,10 +27,24 @@
 #include "timefuncs.h"
 #include "debug.h"
 
-#ifndef SIMULATOR
+#if !(defined SIMULATOR && CONFIG_RTC)
+
 static struct tm tm;
-#endif
 
+static void fill_default_tm(struct tm *tm)
+{
+    tm->tm_sec = 0;
+    tm->tm_min = 0;
+    tm->tm_hour = 0;
+    tm->tm_mday = 1;
+    tm->tm_mon = 0;
+    tm->tm_year = 70;
+    tm->tm_wday = 1;
+    tm->tm_yday = 0; /* Not implemented for now */
+    tm->tm_isdst = -1; /* Not implemented for now */
+}
+#endif /* !(defined SIMULATOR && CONFIG_RTC)*/
+
 bool valid_time(const struct tm *tm)
 {
     if (tm->tm_hour < 0 || tm->tm_hour > 23 ||
@@ -72,32 +86,30 @@
         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
+#else /* Not IRIVER_H300_SERIES */
         tm.tm_year = ((rtcbuf[6] & 0xf0) >> 4) * 10 + (rtcbuf[6] & 0x0f) + 100;
-#endif
+#endif /* IRIVER_H300_SERIES */
 
         tm.tm_yday = 0; /* Not implemented for now */
         tm.tm_isdst = -1; /* Not implemented for now */
-#else
+#else /* CONFIG_RTC == RTC_JZ47XX */
         rtc_read_datetime((unsigned char*)&tm);
-#endif
+#endif /* CONFIG_RTC */
     }
-#else
-    tm.tm_sec = 0;
-    tm.tm_min = 0;
-    tm.tm_hour = 0;
-    tm.tm_mday = 1;
-    tm.tm_mon = 0;
-    tm.tm_year = 70;
-    tm.tm_wday = 1;
-    tm.tm_yday = 0; /* Not implemented for now */
-    tm.tm_isdst = -1; /* Not implemented for now */
-#endif
+#else /* No RTC */
+    fill_default_tm(&tm);
+#endif /* RTC */
     return &tm;
-#else
+
+#else /* SIMULATOR */
+#if CONFIG_RTC
     time_t now = time(NULL);
     return localtime(&now);
+#else /* Simulator, no RTC */
+    fill_default_tm(&tm);
+    return &tm;
 #endif
+#endif /* SIMULATOR */
 }
 
 int set_time(const struct tm *tm)

_______________________________________________
rockbox-cvs mailing list
rockbox-cvs@cool.haxx.se
http://cool.haxx.se/cgi-bin/mailman/listinfo/rockbox-cvs
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic