|
|
@@ -8,7 +8,9 @@ |
|
|
|
#include "snfLOGmgr.hpp" |
|
|
|
#include "../CodeDweller/threading.hpp" |
|
|
|
#include "../CodeDweller/timing.hpp" |
|
|
|
#include <unistd.h> |
|
|
|
#include <unistd.h>
|
|
|
|
#include <sstream>
|
|
|
|
#include <iomanip> |
|
|
|
|
|
|
|
using namespace std; |
|
|
|
|
|
|
@@ -1734,18 +1736,24 @@ time_t snfLOGmgr::Timestamp() { |
|
|
|
} |
|
|
|
|
|
|
|
string snfLOGmgr::Timestamp(time_t t) { // Convert time_t to a timestamp s. |
|
|
|
char TimestampBfr[20]; // Create a small buffer. |
|
|
|
stringstream TimestampBfr;
|
|
|
|
const string EmptyTimestamp = "00000000000000";
|
|
|
|
string theTimeStamp = EmptyTimestamp; |
|
|
|
tm* gmt; // Get a ptr to a tm structure. |
|
|
|
gmt = gmtime(&t); // Fill it with UTC. |
|
|
|
sprintf(TimestampBfr,"%04d%02d%02d%02d%02d%02d", // Format yyyymmddhhmmss |
|
|
|
gmt->tm_year+1900, |
|
|
|
gmt->tm_mon+1, |
|
|
|
gmt->tm_mday, |
|
|
|
gmt->tm_hour, |
|
|
|
gmt->tm_min, |
|
|
|
gmt->tm_sec |
|
|
|
); |
|
|
|
return string(TimestampBfr); // Return a string. |
|
|
|
gmt = gmtime(&t); // Fill it with UTC.
|
|
|
|
bool isValidGMT = (0 != gmt);
|
|
|
|
if(isValidGMT) {
|
|
|
|
TimestampBfr
|
|
|
|
<< setw(4) << (gmt->tm_year+1900)
|
|
|
|
<< setw(2) << setfill('0')
|
|
|
|
<< (gmt->tm_mon+1)
|
|
|
|
<< (gmt->tm_mday)
|
|
|
|
<< (gmt->tm_hour)
|
|
|
|
<< (gmt->tm_min)
|
|
|
|
<< (gmt->tm_sec);
|
|
|
|
theTimeStamp = TimestampBfr.str();
|
|
|
|
}
|
|
|
|
return theTimeStamp; // Return a string. |
|
|
|
} |
|
|
|
|
|
|
|
|