on OH 3 I would like to have a rule that calculated the DateTime of a pre-defined time for the current day, e.g. at any time I trigger the rule, I want to have the DateTime of today at 20:00.
Any idea how to get that done? Any good docu to check my self for learning?
Yes this can easily be done with blockly. See here:
Edit: Did not see that you need it for DSL rules.
For this I don’t have an idea.
There are several ways
Another is to truncate now to midnight
.truncatedTo(ChronoUnit::DAYS) then add a 20hr duration, or add 20 hours
See ZonedDateTime (Java SE 12 & JDK 12 )
Need to check it but best is probably helping to find documentation to learn and improve!
Blockly not used yet, let’s see…
ZonedDateTime.now.with(LocalTime.of(20, 0, 0, 0))
Comment ; using a “with hour of 20” type method will reliably give you clock time 20:00. Using a “midnight plus 20 hours” method may give you clock 19:00 or 21:00 on odd days when summertime changes, but still a genuine elapsed 20 hours… Be sure to choose the method you actually want.
Just to provide one more way using JS Scripting:
Great - thanks to the many ideas!