Skip to content

Commit

Permalink
DateTimeType spec fix
Browse files Browse the repository at this point in the history
Signed-off-by: Jimmy Tanagra <[email protected]>
  • Loading branch information
jimtng committed Sep 16, 2024
1 parent d8f0e9e commit 4ae2b0b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion lib/openhab/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1042,7 +1042,9 @@ def try_parse_time_like(string)

exception = nil
[java.time.LocalTime, java.time.LocalDate, java.time.MonthDay, java.time.ZonedDateTime, Time].each do |klass|
return klass.parse(string)
result = klass.parse(string)
logger.trace { "DSL#try_parse_time_like parsed '#{string}' as #{result} (#{result.class})" }
return result
rescue ArgumentError => e
exception ||= e
next
Expand Down
7 changes: 3 additions & 4 deletions spec/openhab/core/types/date_time_type_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,9 @@
end

it "parses time only strings with a timezone" do
zone_id = ZoneId.of("+1000")
date_time_type = DateTimeType.parse("3:30+1000").to_zone(zone_id)
date_time = ZonedDateTime.now.with(LocalTime.parse("3:30")).with_zone_same_local(zone_id)
expect(date_time_type).to eq date_time
expect(DateTimeType.parse("3:30+0500").zoned_date_time).to eq LocalTime.parse("3:30")
.at_date(LocalDate.now)
.at_zone(ZoneId.of("+05:00"))
end
end
end

0 comments on commit 4ae2b0b

Please sign in to comment.