bool isDST(int day, int month, int dayOfWeek) {
if (month < 3 || month > 10) {
return false;
}
if (month > 3 && month < 10) {
return true;
}
int previousSunday = day - dayOfWeek;
if (month == 3) {
return previousSunday >= 25;
}
if (month == 10) return previousSunday < 25; {
return false;
}
}
It works (after years of struggling with DST!) BUT I’m wondering if it’s slowing down my Core? Button presses which used to be recognised more or less instant sometimes get missed or there is a few seconds’ delay - is there any way I could move this to a twice daily check?
This code does not really do a lot, so I doubt it’s the reason for your issue.
However, there is little use in passing in three parameters when all the information needed is already present in Time.now().
Particularly when only using this function for the current time, there is little sense in passing it as a parameter at all.
I did a search on the topic "oneshot" and found two posts. These helped me square away potential issues I might have had on when to calculate DST (as well as other features in my code).
Then, I borrowed from @Ric and made my own small library. Once done, it was relatively easy to implement oneShotGuard's for many different tasks that I had going and be confident they would fire once and only once, at the appropriate time.