Real Time Clock. get time-str, set time.
RealTimeClock.h@4:d1c394cd7b63, 2015-11-19 (annotated)
- Committer:
- AkinoriHashimoto
- Date:
- Thu Nov 19 07:56:35 2015 +0000
- Revision:
- 4:d1c394cd7b63
- Parent:
- 2:32cfa1dac5a2
- Child:
- 5:82e566457502
Include JPN (+09:00) in setTime.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
AkinoriHashimoto | 0:006ab0d7b90f | 1 | #pragma once |
AkinoriHashimoto | 0:006ab0d7b90f | 2 | |
AkinoriHashimoto | 0:006ab0d7b90f | 3 | #include "mbed.h" |
AkinoriHashimoto | 0:006ab0d7b90f | 4 | #include <string> |
AkinoriHashimoto | 0:006ab0d7b90f | 5 | |
AkinoriHashimoto | 0:006ab0d7b90f | 6 | #include "StrLib.h" |
AkinoriHashimoto | 0:006ab0d7b90f | 7 | |
AkinoriHashimoto | 0:006ab0d7b90f | 8 | /** Real Time Clock library |
AkinoriHashimoto | 0:006ab0d7b90f | 9 | * |
AkinoriHashimoto | 0:006ab0d7b90f | 10 | */ |
AkinoriHashimoto | 0:006ab0d7b90f | 11 | class RealTimeClock |
AkinoriHashimoto | 0:006ab0d7b90f | 12 | { |
AkinoriHashimoto | 0:006ab0d7b90f | 13 | public: |
AkinoriHashimoto | 0:006ab0d7b90f | 14 | /** @rtnval YY/MM/DD */ |
AkinoriHashimoto | 0:006ab0d7b90f | 15 | string getYMD8(); |
AkinoriHashimoto | 0:006ab0d7b90f | 16 | |
AkinoriHashimoto | 0:006ab0d7b90f | 17 | /** @rtnval YYMMDD */ |
AkinoriHashimoto | 0:006ab0d7b90f | 18 | string getYMD6(); |
AkinoriHashimoto | 0:006ab0d7b90f | 19 | |
AkinoriHashimoto | 0:006ab0d7b90f | 20 | /** @rtnval HH:MM:SS */ |
AkinoriHashimoto | 0:006ab0d7b90f | 21 | string getHMS8(); |
AkinoriHashimoto | 0:006ab0d7b90f | 22 | |
AkinoriHashimoto | 0:006ab0d7b90f | 23 | /** @rtnval HHMMSS */ |
AkinoriHashimoto | 0:006ab0d7b90f | 24 | string getHMS6(); |
AkinoriHashimoto | 0:006ab0d7b90f | 25 | |
AkinoriHashimoto | 0:006ab0d7b90f | 26 | /** |
AkinoriHashimoto | 4:d1c394cd7b63 | 27 | * @param 'seconds' from 1970/01/01. |
AkinoriHashimoto | 0:006ab0d7b90f | 28 | * @rtnval success(true), failure(false) |
AkinoriHashimoto | 0:006ab0d7b90f | 29 | */ |
AkinoriHashimoto | 4:d1c394cd7b63 | 30 | bool setRealTime(string str, bool JPN= true); |
AkinoriHashimoto | 0:006ab0d7b90f | 31 | |
AkinoriHashimoto | 0:006ab0d7b90f | 32 | /** |
AkinoriHashimoto | 0:006ab0d7b90f | 33 | * @param seconds from 1970/01/01. |
AkinoriHashimoto | 0:006ab0d7b90f | 34 | * @rtnval void |
AkinoriHashimoto | 0:006ab0d7b90f | 35 | */ |
AkinoriHashimoto | 4:d1c394cd7b63 | 36 | bool setRealTime(long now, bool JPN= true); |
AkinoriHashimoto | 4:d1c394cd7b63 | 37 | |
AkinoriHashimoto | 4:d1c394cd7b63 | 38 | private: |
AkinoriHashimoto | 4:d1c394cd7b63 | 39 | time_t secRT; // secondsRealTime. JST; 9hour |
AkinoriHashimoto | 4:d1c394cd7b63 | 40 | char buf[14]; // using for strftime() |
AkinoriHashimoto | 4:d1c394cd7b63 | 41 | string bufTmp; // return value |
AkinoriHashimoto | 4:d1c394cd7b63 | 42 | void setSecondsRealTime(); // set secRt; |
AkinoriHashimoto | 0:006ab0d7b90f | 43 | |
AkinoriHashimoto | 0:006ab0d7b90f | 44 | }; |