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
Diff: Time.h
- Revision:
- 6:f4693f2d03e6
- Parent:
- 5:fde01b92a384
- Child:
- 7:0c7207d674d3
--- a/Time.h Mon Jan 24 22:01:44 2011 +0000 +++ b/Time.h Tue Feb 01 21:16:05 2011 +0000 @@ -83,6 +83,16 @@ updateTime(unixTime); }; + TimeStamp(int year, int mon, int day, int hour, int min, int sec, int wday) + { + _year=(char)(year-1900); + _mon=(char)(mon-1); + _mday=(char)day; + _hour=(char)hour; + _min=(char)min; + _sec=(char)sec; + _wday=(char)wday; + } ~TimeStamp() { }; @@ -108,6 +118,14 @@ @return true when the current time stamp is after the given time stamp */ bool isAfter(TimeStamp* ts); + int getStartOfDay() + { + tm* t=getTm(); + t->tm_hour=0; + t->tm_min=0; + t->tm_sec=0; + return mktime(t); + } private: tm *getTm() { @@ -134,17 +152,6 @@ _sec=time->tm_sec; _wday=time->tm_wday; } - TimeStamp(int year, int mon, int day, int hour, int min, int sec, int wday) - { - _year=(char)(year-1900); - _mon=(char)(mon-1); - _mday=(char)day; - _hour=(char)hour; - _min=(char)min; - _sec=(char)sec; - _wday=(char)wday; - } - void print() { printf("ts=%i.%i.%i %i:%i.%i\n",_mday,_mon+1,_year+1900,_hour,_min,_sec);