Merge branch 'development' into LTS_development
# Conflicts: # lib/timing.cpp # lib/timing.h
This commit is contained in:
commit
eadd3863fc
2 changed files with 7 additions and 10 deletions
|
@ -100,15 +100,12 @@ long long int Util::epoch() {
|
||||||
return time(0);
|
return time(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Util::getUTCString(){
|
std::string Util::getUTCString(long long int epoch){
|
||||||
time_t rawtime;
|
if (!epoch){epoch = time(0);}
|
||||||
|
time_t rawtime = epoch;
|
||||||
struct tm * ptm;
|
struct tm * ptm;
|
||||||
|
|
||||||
time ( &rawtime );
|
|
||||||
|
|
||||||
ptm = gmtime(&rawtime);
|
ptm = gmtime(&rawtime);
|
||||||
|
|
||||||
char result[20];
|
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);
|
return std::string(result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
/// \file timing.h
|
/// \file timing.h
|
||||||
/// Utilities for handling time and timestamps.
|
/// Utilities for handling time and timestamps.
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace Util {
|
namespace Util {
|
||||||
void wait(int ms); ///< Sleeps for the indicated amount of milliseconds or longer.
|
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);///<Gets the time difference in microseconds.
|
long long unsigned int getMicros(long long unsigned int previous);///<Gets the time difference in microseconds.
|
||||||
long long int getNTP();
|
long long int getNTP();
|
||||||
long long int epoch(); ///< Gets the amount of seconds since 01/01/1970.
|
long long int epoch(); ///< Gets the amount of seconds since 01/01/1970.
|
||||||
std::string getUTCString();
|
std::string getUTCString(long long int epoch = 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue