Make date "At"-type check more robust

Previously the "At" check could skip the desired time window if e.g another
macro was performing a long wait wait action or condition was taking
a long time to check.
The date condition will now take into consideration when the last time
was the condition checked a date instead of simply applying a fixed
window of "switcher->interval".
This commit is contained in:
WarmUpTill
2022-04-02 13:54:12 +02:00
committed by WarmUpTill
parent eb8a9df627
commit 1a8b185f7d
4 changed files with 32 additions and 12 deletions

View File

@@ -48,8 +48,8 @@ public:
bool _dayOfWeekCheck = false;
private:
bool checkDayOfWeek();
bool checkRegularDate();
bool CheckDayOfWeek(int64_t);
bool CheckRegularDate(int64_t);
static bool _registered;
static const std::string id;

View File

@@ -78,6 +78,7 @@ public:
bool PerformActions(bool forceParallel = false,
bool ignorePause = false);
bool Matched() { return _matched; }
int64_t MsSinceLastCheck();
std::string Name() { return _name; }
void SetName(const std::string &name);
void SetRunInParallel(bool parallel) { _runInParallel = parallel; }
@@ -139,6 +140,8 @@ private:
bool _wasExecutedRecently = false;
bool _onChangeTriggered = false;
std::chrono::high_resolution_clock::time_point _lastCheckTime{};
bool _die = false;
bool _stop = false;
bool _done = true;