Ruth Pavoor / Mbed 2 deprecated project1

Dependencies:   mbed mbed-rtos PinDetect

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);
+   }
+};