Skip to content

Commit

Permalink
Fix long-distance preview of Odd/Even schedule entries.
Browse files Browse the repository at this point in the history
Preview for Odd/Even schedule entries was previously set at 35
days max instead of honoring the Max setting.

Fixes #1616
  • Loading branch information
cpinkham committed Oct 25, 2023
1 parent 68d0086 commit fc5b676
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/Scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ void Scheduler::AddScheduledItems(ScheduleEntry* entry, int index) {
std::time_t currTime = std::time(nullptr);
struct tm now;
localtime_r(&currTime, &now);
int scheduleDistance = getSettingInt("ScheduleDistance");

// Convert everything to a day mask to simplify code below
switch (dayIndex) {
Expand Down Expand Up @@ -299,8 +300,7 @@ void Scheduler::AddScheduledItems(ScheduleEntry* entry, int index) {
if (dayOffset)
entry->pushStartEndTimes(now.tm_wday - 1, m_timeDelta, m_timeDeltaThreshold);

// Schedule out 5 weeks
for (int i = now.tm_wday + dayOffset; i <= 35; i += 2) {
for (int i = now.tm_wday + dayOffset; i <= scheduleDistance; i += 2) {
entry->pushStartEndTimes(i, m_timeDelta, m_timeDeltaThreshold);
}

Expand All @@ -312,7 +312,6 @@ void Scheduler::AddScheduledItems(ScheduleEntry* entry, int index) {
entry->pushStartEndTimes(-1, m_timeDelta, m_timeDeltaThreshold);

if ((entry->dayIndex != INX_ODD_DAY) && (entry->dayIndex != INX_EVEN_DAY)) {
int scheduleDistance = getSettingInt("ScheduleDistance");
for (int weekOffset = 0; weekOffset <= scheduleDistance; weekOffset += 7) {
if (dayIndex & INX_DAY_MASK_SUNDAY)
entry->pushStartEndTimes(INX_SUN + weekOffset, m_timeDelta, m_timeDeltaThreshold);
Expand Down

0 comments on commit fc5b676

Please sign in to comment.