DST trigger

I created two cron jobs in MainUI so that I get an event when DST is adjusted (last Sunday of March and October).
However, I expect some problems when switching back from summer time to winter time where time is set from 3 a.m. to 2 a.m. so that the cron job will run twice.
Is there decent way to handle this like providing the time of the cron job in UTC time?
I prefer not to have a separate item to prevent the cron job running twice at this day.

I don’t think so. This would be a different UTC time for each run.
What about detection inside of the cronjob ?
As you stated you have two cronjobs.
So the cronjob that switches from DST to none DST need to detect if it is 2:00 CEST or 2:00 CET.
If you would try to detect this by using a shell script you could run:

date | grep CET && echo we are in CET

The echo command only will be executed when date is in CET.

Of course you also can get the epoch time inside of the cron job with

date +"%s"

and use it to detect if it was the first or second call to your cronjob.

Codes are shell script examples. There should be similar examples for calls in javascript or any other language.

I am sorry. I meant to say a cron trigger (time event in MainUI by a cron expression), not a cron job (at operating system level)

Thanks. This is a good idea.

In case someone needs a trigger when daylight saving time is set back and you want to avoid that the rule runs twice.

cronExpression:

0 0 3 * 10 7L *
var zdt = java.time.ZonedDateTime.now();
var zone = zdt.getZone().getDisplayName(java.time.format.TextStyle.SHORT, java.util.Locale.GERMANY);
if (zone == "MESZ") {
  your code here;
}
1 Like

Cool. Very elegant. Will be included