Fix: "day -X" time specifications are parsed incorrectly

fixes #11147
This commit is contained in:
Gunnar Beutner 2016-05-11 09:23:55 +02:00
parent 1246d7dda3
commit ed27130402
1 changed files with 4 additions and 2 deletions

View File

@ -150,6 +150,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
BOOST_THROW_EXCEPTION(std::invalid_argument("Invalid day in time specification: " + timespec));
if (begin) {
*begin = *reference;
begin->tm_year = year - 1900;
begin->tm_mon = month - 1;
begin->tm_mday = day;
@ -159,6 +160,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
}
if (end) {
*end = *reference;
end->tm_year = year - 1900;
end->tm_mon = month - 1;
end->tm_mday = day;
@ -191,7 +193,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
/* Negative days are relative to the next month. */
if (mday < 0) {
end->tm_mday--;
begin->tm_mday = mday * -1 - 1;
begin->tm_mon++;
}
}
@ -206,7 +208,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
/* Negative days are relative to the next month. */
if (mday < 0) {
end->tm_mday--;
end->tm_mday = mday * -1 - 1;
end->tm_mon++;
}
}