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 PinDetect
Diff: HistoryCache.h
- Revision:
- 0:0ca943ce4014
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/HistoryCache.h Mon Apr 27 23:18:38 2020 +0000 @@ -0,0 +1,26 @@ +#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); + } +};