Skip to content

Commit

Permalink
Remove references to deprecated DateTimeType method getZonedDateTime (#…
Browse files Browse the repository at this point in the history
…2432)

Signed-off-by: Jacob Laursen <[email protected]>
  • Loading branch information
jlaur authored Dec 22, 2024
1 parent 85f084b commit c64ed13
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion configuration/actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ Action | Returns
`getNextBankHoliday` | name of the next bank holiday
`getNextBankHoliday(<file>)` | name of the next bank holiday defined in `<file>`
`getNextBankHoliday(<offset>)` | name of the next bank holiday after `<offset>` days from today
`getNextBankHoliday(<offset>, <file>)` | name of the next bank holiday after `<offset>` days from today defined in `<file>`. :warning: This action is broken in OH 2.5.x. Use `getNextBankHoliday(<datetime>, <file>)` instead by replacing `<datetime>` with `new DateTimeType().zonedDateTime.now().plusDays(<offset>)`
`getNextBankHoliday(<offset>, <file>)` | name of the next bank holiday after `<offset>` days from today defined in `<file>`. :warning: This action is broken in OH 2.5.x. Use `getNextBankHoliday(<datetime>, <file>)` instead by replacing `<datetime>` with `now.plusDays(<offset>)`
`getNextBankHoliday(<datetime>)` | name of the next bank holiday after the day defined by the `ZonedDateTime` `<datetime>`
`getNextBankHoliday(<datetime>, <file>)` | name of the next bank holiday after the day defined by the `ZonedDateTime` `<datetime>` defined in `<file>`
`isBankHoliday` | `true` if today is a bank holiday (see below), `false` otherwise
Expand Down
10 changes: 5 additions & 5 deletions configuration/rules-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -496,13 +496,13 @@ A DateTime Item carries a **DateTimeType**, which internally holds a Java `Zoned

```java
// Get epoch from DateTimeType
val Number epoch = (MyDateTimeItem.state as DateTimeType).zonedDateTime.toInstant.toEpochMilli
val Number epoch = (MyDateTimeItem.state as DateTimeType).instant.toEpochMilli

// Get epoch from Java ZonedDateTime
val Number nowEpoch = now.toInstant.toEpochMilli

// Convert DateTimeType to Java ZonedDateTime
val javaZonedDateTime = (MyDateTimeItem.state as DateTimeType).zonedDateTime
val javaZonedDateTime = (MyDateTimeItem.state as DateTimeType).getZonedDateTime(ZoneId.systemDefault)

// Convert Java ZonedDateTime to DateTimeType
val DateTimeType date = new DateTimeType(now)
Expand Down Expand Up @@ -531,13 +531,13 @@ ZonedDateTimes provide a number of useful methods for comparing date times toget

```java
// See if DateTimeType is before now
if(now.isBefore((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
if(now.toInstant.isBefore((MyDateTimeItem.state as DateTimeType).instant)) ...

// See if DateTimeType is after now
if(now.isAfter((MyDateTimeItem.state as DateTimeType).zonedDateTime)) ...
if(now.toInstant.isAfter((MyDateTimeItem.state as DateTimeType).instant)) ...

// Get the hour in the day from a DateTimeType
val hour = (MyDateTimeItem.state as DateTimeType).zonedDateTime.hour
val hour = (MyDateTimeItem.state as DateTimeType).getZonedDateTime(ZoneId.systemDefault).hour
```

##### Dimmer Item
Expand Down

0 comments on commit c64ed13

Please sign in to comment.