.state before what?
CurrentDT
is indeed a ZonedDateTime
and it has no .state
.
DefaultDay
is a DateTimeItem
and that is not a ZonedDateTime
and cannot be used in the call to isBefore()
. DefaultDay
does have a .state
but that’s a DateTimeType
, not a ZonedDateTime
so you still cannot use that in the call to isBefore()
. You need to get the ZonedDateTime
from that.
(DefaultDay.state as DateTimeType).zonedDateTime
See DateTime Conversion (openHAB 3.x) (
note that article remains unchanged for OH 4).
All of this works very differently in JS. There is a utility called time.toZDT()
which handles converting just about anything that makes sense into a ZonedDateTime
.
But no, using now.toLocalDateTime()
isn’t going to change anything because a LocalDateTime
doesn’t have a .state
either.
Yes, see above and the link above.