Module: LogStruct::Integrations::EventTime

Extended by:
T::Sig
Defined in:
lib/log_struct/integrations/event_time.rb

Class Method Summary collapse

Class Method Details

.coerce_event_time(value) ⇒ Time

Parameters:

  • value (T.untyped)

Returns:

  • (Time)


10
11
12
13
14
15
16
# File 'lib/log_struct/integrations/event_time.rb', line 10

def self.coerce_event_time(value)
  return value if value.is_a?(Time)
  return Time.now unless value.is_a?(Numeric)

  monotonic_now = ::Process.clock_gettime(::Process::CLOCK_MONOTONIC)
  Time.now - (monotonic_now - value)
end