From 965e15fe91ad88ed2f6ccf6fbde5708340b36514 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 20 Sep 2011 23:54:53 -0400 Subject: [PATCH] Bug #831 - Fixed bug #831 that imposed an arbitrary and incorrect assumption that caused some date fields from being parsed properly. --- ChangeLog | 1 + src/Date.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ChangeLog b/ChangeLog index 16e2d2fec..81481dc19 100644 --- a/ChangeLog +++ b/ChangeLog @@ -185,6 +185,7 @@ (thanks to Owen Clarke). + Fixed bug #808, which generated compiler warnings on Solarix (thanks to Owen Clarke). + + Fixed bug #831, which prevented some date fields from being properly parsed. # Untracked Bugs, biggest first. + Fixed bug that required the '%YAML' prologue in a YAML import. diff --git a/src/Date.cpp b/src/Date.cpp index 89fb6e178..4644a1823 100644 --- a/src/Date.cpp +++ b/src/Date.cpp @@ -128,10 +128,6 @@ Date::Date (const int m, const int d, const int y, //////////////////////////////////////////////////////////////////////////////// Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */) { - // Perhaps it is an epoch date, in string form? - if (isEpoch (input)) - return; - // Before parsing according to "format", perhaps this is a relative date? if (isRelativeDate (input)) return; @@ -145,6 +141,10 @@ Date::Date (const std::string& input, const std::string& format /* = "m/d/Y" */) if (n.getDate (format, _t) && n.depleted ()) return; + // Perhaps it is an epoch date, in string form? + if (isEpoch (input)) + return; + throw ::format (STRING_DATE_INVALID_FORMAT, input, format); } @@ -771,8 +771,7 @@ void Date::operator++ (int) //////////////////////////////////////////////////////////////////////////////// bool Date::isEpoch (const std::string& input) { - if (digitsOnly (input) && - input.length () > 8 && + if (digitsOnly (input) && input.length () <= 10 ) { _t = (time_t) atoi (input.c_str ());