ISO8601d: Added ::toISO

This commit is contained in:
Paul Beckingham 2015-09-26 18:42:32 -04:00
parent cc8a305b37
commit 2414f6b3d4
2 changed files with 21 additions and 0 deletions

View file

@ -26,6 +26,7 @@
#include <cmake.h>
#include <sstream>
#include <iomanip>
#include <stdlib.h>
#include <assert.h>
#include <Lexer.h>
@ -854,6 +855,25 @@ std::string ISO8601d::toEpochString ()
return epoch.str ();
}
////////////////////////////////////////////////////////////////////////////////
// 19980119T070000Z = YYYYMMDDThhmmssZ
std::string ISO8601d::toISO ()
{
struct tm* t = gmtime (&_date);
std::stringstream iso;
iso << std::setw (4) << std::setfill ('0') << t->tm_year + 1900
<< std::setw (2) << std::setfill ('0') << t->tm_mon + 1
<< std::setw (2) << std::setfill ('0') << t->tm_mday
<< "T"
<< std::setw (2) << std::setfill ('0') << t->tm_hour
<< std::setw (2) << std::setfill ('0') << t->tm_min
<< std::setw (2) << std::setfill ('0') << t->tm_sec
<< "Z";
return iso.str ();
}
////////////////////////////////////////////////////////////////////////////////
double ISO8601d::toJulian ()
{

View file

@ -48,6 +48,7 @@ public:
time_t toEpoch ();
std::string toEpochString ();
std::string toISO ();
double toJulian ();
void toMDY (int&, int&, int&);