8#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) || defined(__WIN32__) || defined(WIN64) || defined(_WIN64) || defined(__WIN64) || defined(__WIN64__)
12#elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__GNUC__) || defined(__GNUG__) || defined(unix) || defined(__unix) || defined(__unix__)
17#error OS not supported
21#define localtime_s(pTm,pT) (*(pTm))=*localtime(pT)
22#define sprintf_s(buf, len, ...) snprintf((buf), (len), __VA_ARGS__)
56 time_t t = time(NULL);
110 int getData(
char* str,
size_t len,
bool update =
true) {
return sprintf_s(str, len,
"%d-%02d-%02d %02d:%02d:%02d",
getYear(update),
getMonth(update),
getDay(update),
getHour(update),
getMin(update),
getSec(update)); }
121 return (std::string)str;
#define sprintf_s(buf, len,...)
Definition: Serial.h:27
A class to get system time.
Definition: Timepp.h:37
int getYear(bool update=true)
Get the current year.
Definition: Timepp.h:65
int getData(char *str, size_t len, bool update=true)
Get the current date-time.
Definition: Timepp.h:110
Time()
Constructor.
Definition: Timepp.h:48
int getSec(bool update=true)
Get the current second.
Definition: Timepp.h:100
static constexpr int STR_LEN
String length to use as buffer.
Definition: Timepp.h:40
int getDay(bool update=true)
Get the current month day.
Definition: Timepp.h:79
void update_time()
Update the time.
Definition: Timepp.h:55
int getMonth(bool update=true)
Get the current month.
Definition: Timepp.h:72
int getHour(bool update=true)
Get the current hour.
Definition: Timepp.h:86
struct tm tm
Variable to store the current time.
Definition: Timepp.h:39
std::string getData(bool update=true)
Get the current data-time.
Definition: Timepp.h:118
int getMin(bool update=true)
Get the current minute.
Definition: Timepp.h:93