DST offset Auto Adjust on local rule Variable

I have a variable I need to adjust based on DST twice a year, anybody have any thoughts how I can automate this vs. manually editing it?

var setAlarmTime = ZonedDateTime.parse(alarmdate + "T" + alarmtime + "000-05:00[America/Chicago]")		// have to change to 06:00 in fall and 05:00 in spring

Best, Jay

Looks like a similar question that is answered here :wink:

Doing that on linux level e.g in a cron job you could use REST API to set an item variable.
Or execute it via executeCommandLine.

Most probably that also can be returned by using a Java or Javascript command. Unfortunately that’s a bit beyond my knowledge.

In the US the start and end of DST is encoded in law. So it doesn’t change much (and might become moot if the House ever decides to vote on the bill passed by the Senate to stick to DST full time). So the easiest thing to do would be to create a rule that uses a cron trigger at 3 AM on March 12th and November 6th and update the variable as needed.

  • March 12th cron: 0 0 3 12 3 ? *
  • Nov 6th cron: 0 0 3 6 11 ? *

You could also put these into a DateTime Item and use a Time is <Item> to trigger the rule. Then you can just populate the Items once and let restoreOnStartup handle the rest.

The rule can be super simple and check to see if the alarm is 6 and change it to 5 and vice versa, or check to see what month it is when the rule triggers and set it as appropriate.