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:
11:1d880a50da8a
Parent:
10:5734dbc2f5cc
Child:
14:b5c01a52bff4
Child:
15:82bd8fc6f317
--- a/TimeInterface.h	Sun Jan 22 04:06:16 2017 +0000
+++ b/TimeInterface.h	Sun Jan 22 19:31:44 2017 +0000
@@ -4,7 +4,7 @@
 #include "mbed.h"
 #include <ctime>
 
-#include "NTPClient.h"  // ver 7 Wiredhome from ver 5 Donatien Garnier
+#include "NTPClient.h"  // ver 9
 
 // Special Registers and their usage:
 // GPREG0: 32 bits
@@ -32,10 +32,12 @@
     int   tm_tzo_min;   ///<! localtime zone offset in minutes
 };
 
-/// TimeInterface class is much like the normal c-style time.h
-/// interface, but is extended with time-zone support, and
-/// clock-adjustment support (which permits tuning the clock)
-/// for more accuracy.
+/// TimeInterface class is much like the normal c-style time.h interface, but
+/// is extended with time-zone support, and clock-adjustment support (which 
+/// permits tuning the clock) for more accuracy. 
+///
+/// Additionally, strptime was integrated, which can extract the time from
+/// a text string. A formatter is used, so it cannot parse an arbitrary string.
 ///
 /// Within this class are the normal time.h methods, simply
 /// exposed here for one consistent interface.
@@ -48,11 +50,66 @@
 ///     gmtime method in this library actually uses localtime,
 ///     but manages the time-zone offset as it does so.
 ///
+/// @code
+/// // TimeInterface Architecture
+/// //
+/// // +--------+
+/// // | clock  |----> clock_t clock()
+/// // +--------+
+/// // 
+/// // +--------+
+/// // | RTC    |<---- setTime(char*, uint16_t, uint32_t)
+/// // |        |<---- adjust_sec(int32_t)
+/// // |        |<---- set_cal(int32_t)
+/// // |        |----> int32_t get_cal()
+/// // |        |----> bool get_dst()
+/// // |        |<---- set_dst(char *, char *)
+/// // |        |<---- set_time(time_t t, int16_t)
+/// // |        |----> time_t time(time_t *)
+/// // |        |--+-> time_t timelocal(time_t *)
+/// // +--------+  |
+/// //             |
+/// // +--------+  |                   
+/// // | tzo    |--+                          
+/// // |        |<---- set_tzo_min(int16_t)
+/// // |        |----> int16_t get_tzo_min()
+/// // +--------+                                
+/// //                                           
+/// // +--------+                                   +--------------------------+
+/// // | time_t | ---> char * ctime(time_t *) ----> | buffer                   |
+/// // | value  |                                   | Www Mmm dd hh:mm:ss yyyy |
+/// // +--------+     +- char * asctime(tm_ex *) -> +--------------------------+
+/// //      ^  |      |
+/// //      |  |      |                                 +-----------------+   
+/// //      |  |      +-------------------------------> | tm_ex           |   
+/// //      |  |                                        |   .tm_sec       |   
+/// //      |  +- tm_ex * gmtime(const time_t *) -----> |   .tm_min       |   
+/// //      |  |                                        |   .tm_hour      |   
+/// //      |  +- tm_ex * localtime(const time_t *) --> |   .tm_mday      |   
+/// //      |                                           |   .tm_mon       |   
+/// //      +---- time_t mktime(struct tm_ex *) ------- |   .tm_year      |   
+/// //                                                  |   .tm_wday      |   
+/// //                                                  |   .tm_yday      |   
+/// //                                                  |   .tm_isdst     |   
+/// //    +-------------------------------------------- |   .tm_tzo_min   |               
+/// //    |                                             +-----------------+               
+/// //    |                                         +--------------------------+
+/// //    +- strftime(char * ptr, ..., tm_ex *) --> | buffer                   |
+/// //                                              +--------------------------+
+/// //  double difftime(time_t end, time_t)
+///
+/// @endcode
+///
 class TimeInterface
     {
 public:
+    /// Constructor for the TimeInterface class, which does minimal initialization.
+    ///
     TimeInterface();
     
+    /// Destructor, normally not used, because it is typically kept for the life
+    /// of the program.
+    ///
     ~TimeInterface();
     
     /// Gets the system elapsed time in CLOCKS_PER_SEC tics.
@@ -243,7 +300,7 @@
     ///     - %%Y The year, including the century (for example, 1988).
     ///     - %%Z The timezone offset, as a 3-letter sequence. Only a few whole-hour offsets
     ///         have been defined.
-    ///     - %%%% Replaced by %%.
+    ///     - %% Replaced by %.
     ///
     const char * strptime(const char *buf, char *fmt, struct tm_ex *tm);
 
@@ -416,4 +473,4 @@
     struct tm_ex tm_ext;
     };
 
-#endif // TIMEINTERFACE_H
\ No newline at end of file
+#endif // TIMEINTERFACE_H