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:
- 1:81f7dd124217
- Parent:
- 0:ab93db24fcc8
- Child:
- 2:7946f902f2d4
--- a/Time.h Wed Dec 22 23:02:21 2010 +0000 +++ b/Time.h Wed Dec 22 23:08:57 2010 +0000 @@ -8,33 +8,58 @@ class Time; +/** + This class encapsulates a point in time - which means it will not change after it has been created. +*/ class TimeStamp { friend class Time; public: + /** + @returns the year of the time stamp + */ int getYear() { return _tm.tm_year+1900; }; + /** + @returns the month of the time stamp + */ int getMonth() { return _tm.tm_mon; }; int getDay() { + /** + @returns the day-of-the-month of the time stamp + */ return _tm.tm_mday; }; + /** + @returns the hour of the time stamp + */ int getHour() { return _tm.tm_hour; }; + /** + @returns the minute of the time stamp + */ int getMinute() { return _tm.tm_min; }; + /** + @returns the second of the time stamp + */ int getSecond() { return _tm.tm_sec; }; + /** + get the day of the week - monday is 0 + @returns the day-of-the-week of the time stamp + */ int getDayOfWeek() { int dow=_tm.tm_wday; dow--; @@ -43,18 +68,38 @@ return dow; }; + /** + @returns the day-of-the-year of the time stamp + */ int getDayOfYear() { return _tm.tm_yday; }; + /** + creates a new time stamp based on the UNIX time stamp (seconds since 1970) + */ TimeStamp(time_t unixTime) { updateTime(unixTime); }; ~TimeStamp() { }; + + /** + @param ts the time stamp to compare to + @returns true when both timestamp are the same point in time + */ bool isSame(TimeStamp* ts); + + /** + @param ts the time stamp to compare to + @return true when the current time stamp is before the given time stamp + */ bool isBefore(TimeStamp* ts); + /** + @param ts the time stamp to compare to + @return true when the current time stamp is after the given time stamp + */ bool isAfter(TimeStamp* ts); private: void updateTime(time_t unixTime) {