Skip to content

Commit

Permalink
Add PersistedState#instant
Browse files Browse the repository at this point in the history
See openhab/openhab-core#4384

Signed-off-by: Jimmy Tanagra <[email protected]>
  • Loading branch information
jimtng committed Nov 26, 2024
1 parent 2cf93a7 commit 9998fd7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/openhab/core/items/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,14 @@ class PersistedState < SimpleDelegator
# @!attribute [r] timestamp
# @return [ZonedDateTime]

# @!attribute [r] instant
# @return [Instant] The timestamp as an Instant
# @since openHAB 4.3

# @!attribute [r] name
# @return [String] Item name

delegate %i[timestamp name] => :@historic_item
delegate %i[timestamp instant name] => :@historic_item

def initialize(historic_item, state = nil)
@historic_item = historic_item
Expand Down
4 changes: 4 additions & 0 deletions spec/openhab/core/items/persistence_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def initialize(timestamp, state, name)
expect(max).to be_a described_class::PersistedState
expect(max).to eql max.state
expect(max.timestamp).to be_a ZonedDateTime
# @deprecated OH 4.2 - Remove if guard when dropping oh 4.2 support
if OpenHAB::Core.version >= OpenHAB::Core::V4_3 && described_class::PersistedState.instance_methods.include?(:instant)
expect(max.instant).to be_a Instant
end
end

it "is inspectable" do
Expand Down

0 comments on commit 9998fd7

Please sign in to comment.