diff --git a/lib/timing.cpp b/lib/timing.cpp index b4a7974f..1d760ab1 100644 --- a/lib/timing.cpp +++ b/lib/timing.cpp @@ -100,15 +100,12 @@ long long int Util::epoch() { return time(0); } -std::string Util::getUTCString(){ - time_t rawtime; +std::string Util::getUTCString(long long int epoch){ + if (!epoch){epoch = time(0);} + time_t rawtime = epoch; struct tm * ptm; - - time ( &rawtime ); - - ptm = gmtime ( &rawtime ); - + ptm = gmtime(&rawtime); char result[20]; - snprintf(result, 20, "%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d", ptm->tm_year, ptm->tm_mon, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); + snprintf(result, 20, "%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d", ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday, ptm->tm_hour, ptm->tm_min, ptm->tm_sec); return std::string(result); } diff --git a/lib/timing.h b/lib/timing.h index 9e8a40f6..e7486806 100644 --- a/lib/timing.h +++ b/lib/timing.h @@ -1,8 +1,8 @@ /// \file timing.h /// Utilities for handling time and timestamps. -#include #pragma once +#include namespace Util { void wait(int ms); ///< Sleeps for the indicated amount of milliseconds or longer. @@ -13,5 +13,5 @@ namespace Util { long long unsigned int getMicros(long long unsigned int previous);///