Real Time Clock. get time-str, set time.
Diff: RealTimeClock.h
- Revision:
- 0:006ab0d7b90f
- Child:
- 2:32cfa1dac5a2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RealTimeClock.h Thu Jun 11 01:55:55 2015 +0000 @@ -0,0 +1,44 @@ +#pragma once + +#include "mbed.h" +#include <string> + +#include "StrLib.h" + +/** Real Time Clock library + * + */ +class RealTimeClock +{ +private: + time_t secRT; // secondsRealTime. JST; 9hour + char buf[14]; // using for strftime() + string bufTmp; // return value + void setSecondsRealTime(); // set secRt; + +public: + /** @rtnval YY/MM/DD */ + string getYMD8(); + + /** @rtnval YYMMDD */ + string getYMD6(); + + /** @rtnval HH:MM:SS */ + string getHMS8(); + + /** @rtnval HHMMSS */ + string getHMS6(); + + /** + * @param seconds from 1970/01/01. + * @rtnval success(true), failure(false) + */ + bool setRealTime(string str); + + /** + * @param seconds from 1970/01/01. + * @rtnval void + */ + void setRealTime(long now); + +}; \ No newline at end of file