Fix parsing of YYYY-MM-DD in LegacyTimePeriod::ParseTimeSpec

fixes #11132

Signed-off-by: Jean Flach <jean-marcel.flach@netways.de>
This commit is contained in:
Adam James 2016-02-09 18:04:37 +00:00 committed by Gunnar Beutner
parent 2ec36d20ce
commit 998abbbae7
1 changed files with 9 additions and 4 deletions

View File

@ -144,10 +144,15 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
int month = Convert::ToLong(timespec.SubStr(5, 2));
int day = Convert::ToLong(timespec.SubStr(8, 2));
if (month < 1 || month > 12)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid month in time specification: " + timespec));
if (day < 1 || day > 31)
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid day in time specification: " + timespec));
if (begin) {
begin->tm_year = year - 1900;
begin->tm_mon = month;
begin->tm_mday = day + 1;
begin->tm_mon = month - 1;
begin->tm_mday = day;
begin->tm_hour = 0;
begin->tm_min = 0;
begin->tm_sec = 0;
@ -155,8 +160,8 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
if (end) {
end->tm_year = year - 1900;
end->tm_mon = month;
end->tm_mday = day + 1;
end->tm_mon = month - 1;
end->tm_mday = day;
end->tm_hour = 24;
end->tm_min = 0;
end->tm_sec = 0;