mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-21 07:43:08 +02:00
ISO8601d: Added ::toISO
This commit is contained in:
parent
cc8a305b37
commit
2414f6b3d4
2 changed files with 21 additions and 0 deletions
|
@ -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&);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue