Fix incorrect week day calculation in LegacyTimePeriod::ParseTimeSpec

fixes #6943
This commit is contained in:
Gunnar Beutner 2014-12-20 22:04:24 +01:00
parent 9f6b90cd2d
commit 407f88e185
2 changed files with 8 additions and 2 deletions

View File

@ -234,7 +234,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
if (tokens.size() > 1)
FindNthWeekday(wday, n, begin);
else
begin->tm_mday += - begin->tm_wday + wday;
begin->tm_mday += (7 - begin->tm_wday + wday) % 7;
begin->tm_hour = 0;
begin->tm_min = 0;
@ -247,7 +247,7 @@ void LegacyTimePeriod::ParseTimeSpec(const String& timespec, tm *begin, tm *end,
if (tokens.size() > 1)
FindNthWeekday(wday, n, end);
else
end->tm_mday += - end->tm_wday + wday;
end->tm_mday += (7 - end->tm_wday + wday) % 7;
end->tm_hour = 0;
end->tm_min = 0;

View File

@ -114,11 +114,17 @@ std::pair<double, double> ScheduledDowntime::FindNextSegment(void)
ObjectLock olock(ranges);
BOOST_FOREACH(const Dictionary::Pair& kv, ranges) {
Log(LogDebug, "ScheduledDowntime")
<< "Evaluating segment: " << kv.first << ": " << kv.second << " at ";
Dictionary::Ptr segment = LegacyTimePeriod::FindNextSegment(kv.first, kv.second, &reference);
if (!segment)
continue;
Log(LogDebug, "ScheduledDowntime")
<< "Considering segment: " << Utility::FormatDateTime("%c", segment->Get("begin")) << " -> " << Utility::FormatDateTime("%c", segment->Get("end"));
double begin = segment->Get("begin");
if (begin < now)