Module: Cucumber::Messages::Helpers::TimeConversion

Defined in:
lib/cucumber/messages/helpers/time_conversion.rb

Constant Summary collapse

NANOSECONDS_PER_SECOND =
1_000_000_000

Instance Method Summary collapse

Instance Method Details

#time_to_timestamp(time) ⇒ Object



9
10
11
# File 'lib/cucumber/messages/helpers/time_conversion.rb', line 9

def time_to_timestamp(time)
  Cucumber::Messages::Timestamp.new(seconds: time.to_i, nanos: time.nsec)
end

#timestamp_to_time(timestamp) ⇒ Object



13
14
15
# File 'lib/cucumber/messages/helpers/time_conversion.rb', line 13

def timestamp_to_time(timestamp)
  Time.at(timestamp.seconds, timestamp.nanos, :nanosecond)
end