Module: OpenHAB::DSL::Timer::MockedZonedDateTime

Included in:
OpenHAB::DSL::Timer
Defined in:
lib/rspec/openhab/dsl/timers/timer.rb

Instance Method Summary collapse

Instance Method Details

#nowObject



9
10
11
12
13
14
15
# File 'lib/rspec/openhab/dsl/timers/timer.rb', line 9

def now
  mocked_time_stack_item = Timecop.top_stack_item
  return super unless mocked_time_stack_item

  instant = java.time.Instant.of_epoch_milli((Time.now.to_f * 1000).to_i)
  ZonedDateTime.of_instant(instant, java.time.ZoneId.system_default)
end