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.
Dependencies: mbed mbed-rtos SDFileSystem PinDetect ESP8266NodeMCUInterface
HistoryCache.h
- Committer:
- kimberlylie99
- Date:
- 2020-04-30
- Revision:
- 0:b97c07227845
File content as of revision 0:b97c07227845:
#include <iostream>
#include <string>
#include <cstring>
#include <ctime>
class HistoryCache
{
public:
static char *strptime(const char * __restrict, const char * __restrict, struct tm * __restrict);
static std::string getTimeStamp(time_t epochTime, const char* format = "%Y-%m-%d %H:%M:%S")
{
char timestamp[64] = {0};
strftime(timestamp, sizeof(timestamp), format, localtime(&epochTime));
return timestamp;
}
static time_t convertTimeToEpoch(const char* theTime, const char* format = "%Y-%m-%d %H:%M:%S")
{
std::tm tmTime;
memset(&tmTime, 0, sizeof(tmTime));
HistoryCache::strptime(theTime, format, &tmTime);
return mktime(&tmTime);
}
};