Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
RealTimeClock.cpp
- Committer:
- AkinoriHashimoto
- Date:
- 2015-10-16
- Revision:
- 3:3f5628269a53
- Parent:
- 2:32cfa1dac5a2
- Child:
- 4:d1c394cd7b63
File content as of revision 3:3f5628269a53:
#include "RealTimeClock.h" void RealTimeClock::setSecondsRealTime() { secRT = time(NULL); return; } string RealTimeClock::getHMS8() { setSecondsRealTime(); strftime(buf, 10, "%H:%M:%S", localtime(&secRT)); bufTmp= buf; return bufTmp; } string RealTimeClock::getHMS6() { setSecondsRealTime(); strftime(buf, 8, "%H%M%S", localtime(&secRT)); bufTmp= buf; return bufTmp; } string RealTimeClock::getYMD8() { setSecondsRealTime(); strftime(buf, 10, "%y/%m/%d", localtime(&secRT)); bufTmp= buf; return bufTmp; } string RealTimeClock::getYMD6() { setSecondsRealTime(); strftime(buf, 8, "%y%m%d", localtime(&secRT)); bufTmp= buf; return bufTmp; } bool RealTimeClock::setRealTime(string str) { // now is in range of appropriate time. return setRealTime(A2I(str, 10)); } bool RealTimeClock::setRealTime(long now) { now += 3600* 9; // + JST 9hour. // 1,427,597,183(ISO 8601形式: 2015/03/29 02:46:23Z) // 2,147,483,647秒を経過した (2038/01/19 03:14:07) if(!(1427597183<now && now<2147483600)) return false; if(now == -1) return false; set_time(now); return true; } // End of File