Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions xSchedule/Schedule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ wxTimeSpan Schedule::GetTimeSinceStartTime() const

if (start > now)
{
start -= wxTimeSpan(24);
start -= wxDateSpan::Day();
spdlog::debug("last start time adjusted by 24 hrs {}.", (const char*)start.FormatISOCombined().c_str());
}

Expand Down Expand Up @@ -647,7 +647,7 @@ bool Schedule::CheckActiveAt(const wxDateTime& now)

if (e < s)
{
end.Add(wxTimeSpan(24));
end.Add(wxDateSpan::Day());
}

// handle the 24 hours a day case
Expand Down Expand Up @@ -676,11 +676,11 @@ bool Schedule::CheckActiveAt(const wxDateTime& now)

if (e < s && now.FormatISOTime() < end.FormatISOTime())
{
start.Add(wxTimeSpan(-24));
start -= wxDateSpan::Day();
}
else if (e < s)
{
end.Add(wxTimeSpan(24));
end.Add(wxDateSpan::Day());
}

_active = now >= start && now < end;
Expand Down Expand Up @@ -750,7 +750,7 @@ wxDateTime Schedule::GetNextTriggerDateTime()

for (int i = 0; i < 7; i++)
{
next += wxTimeSpan(24);
next += wxDateSpan::Day();
#ifdef LOGCALCNEXTTRIGGERTIME
spdlog::debug(" Checking {}.", (const char*)next.Format("%Y-%m-%d %H:%M").c_str());
#endif
Expand Down Expand Up @@ -779,7 +779,7 @@ wxDateTime Schedule::GetNextTriggerDateTime()

for (int i = 0; i < 7; i++)
{
next += wxTimeSpan(24);
next += wxDateSpan::Day();
#ifdef LOGCALCNEXTTRIGGERTIME
spdlog::debug(" Checking {}.", (const char*)next.Format("%Y-%m-%d %H:%M").c_str());
#endif
Expand All @@ -796,15 +796,14 @@ wxDateTime Schedule::GetNextTriggerDateTime()
std::string Schedule::GetNextNthDay(int nthDay, int nthDayOffset)
{
wxDateTime now = wxDateTime::Now();
wxTimeSpan day(24);

for (int i = 0; i < 15; i++)
{
if ((now.GetDayOfYear() % nthDay) - nthDayOffset == 0)
{
return now.FormatISODate().ToStdString();
}
now.Add(day);
now += wxDateSpan::Day();
}

return "Unknown";
Expand Down Expand Up @@ -880,7 +879,7 @@ std::string Schedule::GetNextTriggerTime()

for (int i = 0; i < 7; i++)
{
next += wxTimeSpan(24);
next += wxDateSpan::Day();
#ifdef LOGCALCNEXTTRIGGERTIME
spdlog::debug("Checking {}.", (const char *)next.Format("%Y-%m-%d %H:%M").c_str());
#endif
Expand Down Expand Up @@ -910,7 +909,7 @@ std::string Schedule::GetNextTriggerTime()

for (int i = 0; i < 7; i++)
{
next += wxTimeSpan(24);
next += wxDateSpan::Day();
SetTime(next, __city, _startTime, _startTimeString, _onOffsetMins);
#ifdef LOGCALCNEXTTRIGGERTIME
spdlog::debug("Checking {}.", (const char *)next.Format("%Y-%m-%d %H:%M").c_str());
Expand Down Expand Up @@ -986,7 +985,7 @@ std::string Schedule::GetNextEndTime()

if (end < start)
{
end += wxTimeSpan(24);
end += wxDateSpan::Day();
}

SetTime(end, __city, _endTime, _endTimeString, _offOffsetMins);
Expand Down
Loading