From 79576819c390dff69030ca28bd94c0b454e9212b Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Thu, 29 May 2014 18:06:52 -0400 Subject: [PATCH] Date - Added the ability to suppres ISO (fixed) and epoch date parsing. --- src/Date.cpp | 10 +++++++--- src/Date.h | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Date.cpp b/src/Date.cpp index f6e5eabe9..07ccef926 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -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? if (isRelativeDate (input)) @@ -139,11 +143,11 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */) #endif // Parse an ISO date. - if (n.getDateISO (_t) && n.depleted ()) + if (iso && n.getDateISO (_t) && n.depleted ()) return; // Perhaps it is an epoch date, in string form? - if (isEpoch (input)) + if (epoch && isEpoch (input)) return; throw ::format (STRING_DATE_INVALID_FORMAT, input, format); diff --git a/src/Date.h b/src/Date.h index 95e6b57dc..320139ab0 100644 --- a/src/Date.h +++ b/src/Date.h @@ -40,7 +40,7 @@ public: Date (time_t); Date (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&); virtual ~Date ();