Real Time Clock. get time-str, set time.

Dependencies:   StrLib

RealTimeClock.h

Committer:
AkinoriHashimoto
Date:
2015-11-19
Revision:
4:d1c394cd7b63
Parent:
2:32cfa1dac5a2
Child:
5:82e566457502

File content as of revision 4:d1c394cd7b63:

#pragma once

#include "mbed.h"
#include <string>

#include "StrLib.h"

/** Real Time Clock library
 * 
 */
class RealTimeClock
{
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, bool JPN= true);

    /**
     * @param   seconds from 1970/01/01.
     * @rtnval  void
    */
    bool setRealTime(long now, bool JPN= true);

private:
    time_t secRT;               // secondsRealTime.  JST; 9hour
    char buf[14];               // using for strftime()
    string bufTmp;              // return value
    void setSecondsRealTime();  // set secRt;

};