A time interface class. This class replicates the normal time functions, but goes a couple of steps further. mbed library 82 and prior has a defective gmtime function. Also, this class enables access to setting the time, and adjusting the accuracy of the RTC.

Dependencies:   CalendarPage

Dependents:   CI-data-logger-server WattEye X10Svr SSDP_Server

Revision:
18:dcd46f9e98fa
Parent:
17:45dae5a72679
Child:
19:ccdf8b6f6aa1
--- a/TimeInterface.cpp	Wed Apr 12 02:25:22 2017 +0000
+++ b/TimeInterface.cpp	Wed Apr 12 13:44:41 2017 +0000
@@ -463,7 +463,8 @@
 {
     char c, *ptr;
     int i, len;
-
+    bool fSet_wday = false;     // so we can notice if the wday was set
+    
     ptr = fmt;
     while (*ptr != 0) {
         if (*buf == 0)
@@ -639,7 +640,7 @@
                 }
                 if (i == asizeof(En_US.weekday_names))
                     return 0;
-
+                fSet_wday = true;
                 tm->tm_wday = i;
                 buf += len;
                 break;
@@ -742,7 +743,9 @@
                 break;
         }
     }
-    if (mktime(tm) == (time_t)-1)
-        tm->tm_wday = 7;
+    if (!fSet_wday) {
+        if (mktime(tm) == (time_t)-1)
+            tm->tm_wday = 7;
+    }
     return buf;
 }