ISO8601d: Added ::toISO
This commit is contained in:
@@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
#include <cmake.h>
|
#include <cmake.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <iomanip>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <Lexer.h>
|
#include <Lexer.h>
|
||||||
@@ -854,6 +855,25 @@ std::string ISO8601d::toEpochString ()
|
|||||||
return epoch.str ();
|
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 ()
|
double ISO8601d::toJulian ()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
time_t toEpoch ();
|
time_t toEpoch ();
|
||||||
std::string toEpochString ();
|
std::string toEpochString ();
|
||||||
|
std::string toISO ();
|
||||||
double toJulian ();
|
double toJulian ();
|
||||||
void toMDY (int&, int&, int&);
|
void toMDY (int&, int&, int&);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user