diff options
Diffstat (limited to 'project2/common/functions/dates.cpp')
-rw-r--r-- | project2/common/functions/dates.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/project2/common/functions/dates.cpp b/project2/common/functions/dates.cpp index c1992f7..7ace436 100644 --- a/project2/common/functions/dates.cpp +++ b/project2/common/functions/dates.cpp @@ -7,7 +7,7 @@ #include <iostream> #include <boost/date_time.hpp> -class ParseError { }; +SimpleMessage2Exception(DateParseError); /// Variable implementation to access platform configuration values class ParseDate : public VariableImplDyn { public: @@ -21,15 +21,14 @@ class ParseDate : public VariableImplDyn { { const char * s = string(); const char * f = format(); - boost::posix_time::ptime t; struct tm tm; memset(&tm, 0, sizeof(struct tm)); mktime(&tm); const char * e = strptime(s, f, &tm); - if (!e) { + if (!e || *e) { Logger()->messagef(LOG_ERR, "%s: check failed (parse) for '%s' against '%s' (remaining chars='%s')", __PRETTY_FUNCTION__, s, f, e); - throw ParseError(); + throw DateParseError(string(), format()); } return boost::posix_time::ptime(boost::posix_time::ptime_from_tm(tm)); } |