ZonedDateTime… until… ChronoUnit.TemporalUnit…
import java.time.temporal.ChronoUnit
...
val date_1 = Virtual_DateTime_1.getStateAs(DateTimeType).zonedDateTime
val date_2 = Virtual_DateTime_2.getStateAs(DateTimeType).zonedDateTime
val seconds_between = date_1.until(date_2, ChronoUnit.SECONDS)
val minutes_between = date_1.until(date_2, ChronoUnit.MINUTES)
val days_between = date_1.until(date_2, ChronoUnit.DAYS)
val weeks_between = date_1.until(date_2, ChronoUnit.WEEKS)
val months_between = date_1.until(date_2, ChronoUnit.MONTHS)
val years_between = date_1.until(date_2, ChronoUnit.MONTHS)
logWarn("Rules", "[{}], [{}]\nSeconds [{}]\nMinutes [{}]\nDays [{}]\nWeeks [{}]\nMonths [{}]\nYears [{}]", date_1, date_2, seconds_between, minutes_between, days_between, weeks_between, months_between, years_between)
Here’s another way to use ChronoUnit…