When evaluating twilight restriction, shift dusk to next day when it happens…

Authored by TallFurryMan on Jul 14 2019, 4:04 PM.

Description

When evaluating twilight restriction, shift dusk to next day when it happens before dawn on the same day.

Summary:
Near the summer solstice, it may happen that dusk occurs before dawn on the same day.
The twilight restriction did not take this situation into account, and was unable to shift restricted jobs to the next dusk.

This change shifts dusk to the next day when it happens before dawn on the same day, resolving this issue when evaluating jobs.
This change also fixes the accompanying exception on dark sky score occurring when debugging in that situation, as the job was occuring during daytime.

Test Plan:
Test during a period of the year where dusk happens after the local midnight, so that "dusk happens before dawn", for instance around 1am.
Test during daytime, so that a default ASAP job would happen during the day (this is not required given the execution path, but makes the end-user issue obvious).
Add a single job on a circumpolar target, with twilight restriction, ASAP startup, and let Scheduler evaluate.

  • Without this change, job startup is left unmodified although it will start during daytime. An exception happens if debugging.
  • With this change, job startup is properly shifted to next dusk, on the following day. No exception is triggered.

Reviewers: mutlaqja, wreissenberger

Reviewed By: wreissenberger

Subscribers: kde-edu

Tags: KDE Edu

Differential Revision: https://phabricator.kde.org/D22391