This library takes the current time (which must be set to UTC, e.g. via an NTP call), and applies a timezone definition (loaded at startup) to calculate the local time. This includes the handling of daylight saving. See http://mbed.org/users/hlipka/notebook/time-zone-handling/ for more information (esp. how to get a time zone definition file).

Dependents:   CubiScan 000-FIN_youcef 005_ESSAI_youcef

Revision:
3:2ad51ec5ef6e
Parent:
2:7946f902f2d4
Child:
4:c84afcfbac84
--- a/Time.h	Wed Dec 22 23:20:43 2010 +0000
+++ b/Time.h	Tue Jan 04 23:19:50 2011 +0000
@@ -22,35 +22,35 @@
     };
 
     /**
-        @returns the month of the time stamp
+        @returns the month of the time stamp (January is 1)
     */
     int getMonth() {
-        return _tm.tm_mon;
+        return _tm.tm_mon+1;
     };
 
     int getDay() {
     /**
-        @returns the day-of-the-month of the time stamp
+        @returns the day-of-the-month of the time stamp (starting with 1)
     */
         return _tm.tm_mday;
     };
 
     /**
-        @returns the hour of the time stamp
+        @returns the hour of the time stamp (0-23)
     */
     int getHour() {
         return _tm.tm_hour;
     };
 
     /**
-        @returns the minute of the time stamp
+        @returns the minute of the time stamp (0-59)
     */
     int getMinute() {
         return _tm.tm_min;
     };
 
     /**
-        @returns the second of the time stamp
+        @returns the second of the time stamp (0-59)
     */
     int getSecond() {
         return _tm.tm_sec;
@@ -110,12 +110,17 @@
     TimeStamp(int year, int mon, int day, int hour, int min, int sec)
     {
         _tm.tm_year=year-1900;
-        _tm.tm_mon=mon;
+        _tm.tm_mon=mon-1;
         _tm.tm_mday=day;
         _tm.tm_hour=hour;
         _tm.tm_min=min;
         _tm.tm_sec=sec;
     }
+    
+    void print()
+    {
+        printf("ts=%i.%i.%i %i:%i.%i\n",_tm.tm_mday,_tm.tm_mon+1,_tm.tm_year+1900,_tm.tm_hour,_tm.tm_min,_tm.tm_sec);
+    }
 
     struct tm _tm;
 };