- Added the ability to suppres ISO (fixed) and epoch date parsing.
This commit is contained in:
Paul Beckingham 2014-05-29 18:06:52 -04:00
parent 52eaf3f9c2
commit 79576819c3
2 changed files with 8 additions and 4 deletions

View file

@ -125,7 +125,11 @@ Date::Date (const int m, const int d, const int y,
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */) Date::Date (
const std::string& input,
const std::string& format /* = "m/d/Y" */,
const bool iso /* = true */,
const bool epoch /* = true */)
{ {
// Before parsing according to "format", perhaps this is a relative date? // Before parsing according to "format", perhaps this is a relative date?
if (isRelativeDate (input)) if (isRelativeDate (input))
@ -139,11 +143,11 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */)
#endif #endif
// Parse an ISO date. // Parse an ISO date.
if (n.getDateISO (_t) && n.depleted ()) if (iso && n.getDateISO (_t) && n.depleted ())
return; return;
// Perhaps it is an epoch date, in string form? // Perhaps it is an epoch date, in string form?
if (isEpoch (input)) if (epoch && isEpoch (input))
return; return;
throw ::format (STRING_DATE_INVALID_FORMAT, input, format); throw ::format (STRING_DATE_INVALID_FORMAT, input, format);

View file

@ -40,7 +40,7 @@ public:
Date (time_t); Date (time_t);
Date (const int, const int, const int); Date (const int, const int, const int);
Date (const int, const int, const int, const int, const int, const int); Date (const int, const int, const int, const int, const int, const int);
Date (const std::string&, const std::string& format = "m/d/Y"); Date (const std::string&, const std::string& format = "m/d/Y", const bool iso = true, const bool epoch = true);
Date (const Date&); Date (const Date&);
virtual ~Date (); virtual ~Date ();