Skip to content

Commit

Permalink
sch: skip next day search w/ valid sunrise or sunset
Browse files Browse the repository at this point in the history
  • Loading branch information
mcspr committed Dec 7, 2024
1 parent 6500f45 commit 758ff84
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions code/espurna/scheduler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1005,24 +1005,26 @@ void update_after(const datetime::Context& ctx) {
return;
}

auto next = update(time_point, ctx.utc, CompareAfter{});
const auto next = update(time_point, ctx.utc, CompareAfter{});

event::time_point unordered[] {
next,
match.rising.next,
match.setting.next,
};

if (event::is_valid(match.rising.next)) {
DEBUG_MSG_P(PSTR("[SCH] Sunrise at %s\n"),
datetime::format_local_tz(match.rising.next).c_str());
unordered[0] = event::DefaultTimePoint;
}

if (event::is_valid(match.setting.next)) {
DEBUG_MSG_P(PSTR("[SCH] Sunset at %s\n"),
datetime::format_local_tz(match.setting.next).c_str());
unordered[0] = event::DefaultTimePoint;
}

const event::time_point unordered[] {
next,
match.rising.next,
match.setting.next,
};

next_update = event::DefaultTimePoint;

for (const auto& value : unordered) {
Expand Down

0 comments on commit 758ff84

Please sign in to comment.