added: method Date::SerializeISO(Stream & out)
outputs to the given stream: YYYY-MM-DDTHH:MM:SSZ, eg: 1990-02-12T13:05:39Z added: parsing date in a format: YYYY-MM-DDTHH:MM:SS ('T' letter given) git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1089 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
parent
dc0cd13178
commit
38355a2830
30
date/date.h
30
date/date.h
|
@ -5,7 +5,7 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2012, Tomasz Sowa
|
||||
* Copyright (c) 2012-2018, Tomasz Sowa
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -288,6 +288,14 @@ public:
|
|||
void Serialize(Stream & out) const;
|
||||
|
||||
|
||||
/*
|
||||
this method outputs to the given stream: YYYY-MM-DDTHH:MM:SSZ, eg: 1990-02-12T13:05:39Z
|
||||
ISO 8601 format
|
||||
*/
|
||||
template<class Stream>
|
||||
void SerializeISO(Stream & out) const;
|
||||
|
||||
|
||||
/*
|
||||
parsing day month and year
|
||||
the input string can be as follows:
|
||||
|
@ -567,6 +575,14 @@ void Date::Serialize(Stream & out) const
|
|||
SerializeHourMinSec(out);
|
||||
}
|
||||
|
||||
template<class Stream>
|
||||
void Date::SerializeISO(Stream & out) const
|
||||
{
|
||||
SerializeYearMonthDay(out);
|
||||
out << 'T';
|
||||
SerializeHourMinSec(out);
|
||||
out << 'Z';
|
||||
}
|
||||
|
||||
|
||||
template<class CStringType>
|
||||
|
@ -771,8 +787,20 @@ const CStringType * after;
|
|||
bool result = false;
|
||||
|
||||
if( ParseYearMonthDay(str, &after) )
|
||||
{
|
||||
SkipWhite(after);
|
||||
|
||||
if( *after == 'T' )
|
||||
{
|
||||
// ISO 8601 format
|
||||
// https://en.wikipedia.org/wiki/ISO_8601
|
||||
// at the moment skip the 'T' character only
|
||||
after += 1;
|
||||
}
|
||||
|
||||
if( ParseHourMinSec(after, &after) )
|
||||
result = true;
|
||||
}
|
||||
|
||||
SetAfter(after, str_after);
|
||||
|
||||
|
|
Loading…
Reference in New Issue