Closed jimtng closed 2 years ago
What is the reason for using ZDT instead of the ruby time/date objects and converting to ZDT where necessary?
Sometimes using ZDT is unavoidable, other times, zdt has nicer methods that Ruby Time doesn't have. For example, plus_minutes, plus_hours, etc without having to do maths. It also naturally uses java Duration for deltas.
Sometimes using ZDT is unavoidable, other times, zdt has nicer methods that Ruby Time doesn't have. For example, plus_minutes, plus_hours, etc without having to do maths. It also naturally uses java Duration for deltas.
Makes sense.
This was a bit epic to fix. I had to re-import in rule executions and also in timer executions. I wonder if it's worth doing. Is the performance impact acceptable?
I added a guard in the import method to avoid importing if ZDT is already correct.
:tada: This PR is included in version 4.37.0 :tada:
The release is available on:
4.37.0
Your semantic-release bot :package::rocket:
Move the java_import for ZonedDateTime to the top of dsl.rb so it's available for user scripts. Remove instances of
java_import java.time.ZonedDateTime
in other placesThis makes it no longer necessary to import ZonedDateTime within user scripts even on openhab 3.2. This also deduplicates the multiple imports in submodules.
By "importing", I mean re-assigning the ZonedDateTime constant to the Ruby class version. I'm not sure how "expensive" this operation is, but I suspect it's very "cheap" / fast to execute.