module Cucumber::Messages::Helpers::TimeConversion
Constants
- NANOSECONDS_PER_SECOND
- NANOSECOND_POWER
Public Instance Methods
Source
# File lib/cucumber/messages/helpers/time_conversion.rb, line 10 def seconds_to_duration(seconds_float) seconds, decimal = seconds_float.to_s.split('.') nanos = decimal.to_s.ljust(NANOSECOND_POWER, '0').to_i { 'seconds' => seconds.to_i, 'nanos' => nanos } end
Source
# File lib/cucumber/messages/helpers/time_conversion.rb, line 16 def time_to_timestamp(time) Cucumber::Messages::Timestamp.new(seconds: time.to_i, nanos: time.nsec) end
Source
# File lib/cucumber/messages/helpers/time_conversion.rb, line 20 def timestamp_to_time(timestamp) Time.at(timestamp.seconds, timestamp.nanos, :nanosecond) end