8#include <boost/lexical_cast.hpp>
23struct tm getTimeValue(const
std::string &sDate, std::string &
error) {
34 timeinfo.tm_isdst = -1;
36 timeinfo.tm_gmtoff = 0;
37 timeinfo.tm_zone =
nullptr;
40 std::basic_string<char>::size_type
index, off = 0;
44 index = sDate.find(
'/', off);
45 if (
index == std::string::npos) {
46 error =
"Invalid Date:date format must be DD/MM/YYYY";
52 day = boost::lexical_cast<int>(sDate.substr(off,
index - off).c_str());
53 }
catch (boost::bad_lexical_cast &) {
54 error =
"Invalid Date";
57 timeinfo.tm_mday = day;
62 index = sDate.find(
'/', off);
63 if (
index == std::string::npos) {
64 error =
"Invalid Date:date format must be DD/MM/YYYY";
69 month = boost::lexical_cast<int>(sDate.substr(off,
index - off).c_str());
71 }
catch (boost::bad_lexical_cast &) {
72 error =
"Invalid Date";
75 timeinfo.tm_mon = month - 1;
80 year = boost::lexical_cast<int>(sDate.substr(off, 4).c_str());
82 }
catch (boost::bad_lexical_cast &) {
83 error =
"Invalid Date";
87 timeinfo.tm_year = year - 1900;
105 std::string formaterror;
106 struct tm timeinfo = getTimeValue(
value, formaterror);
107 if (!formaterror.empty()) {
111 if (timeinfo.tm_mday < 1 || timeinfo.tm_mday > 31) {
112 return "Invalid Date:Day part of the Date parameter must be between 1 and "
115 if (timeinfo.tm_mon < 0 || timeinfo.tm_mon > 11) {
116 return "Invalid Date:Month part of the Date parameter must be between 1 "
122 struct tm *currenttime = localtime(&rawtime);
123 if (timeinfo.tm_year > currenttime->tm_year) {
124 return "Invalid Date:Year part of the Date parameter can not be greater "
125 "than the current year";
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
std::string checkValidity(const std::string &value) const override
Checks the value is valid.
IValidator_sptr clone() const override
Clone the current state.
std::shared_ptr< IValidator > IValidator_sptr
A shared_ptr to an IValidator.