module Tracebin::Helpers

Public Instance Methods

deserialize_time_string(str) click to toggle source
# File lib/tracebin/helpers.rb, line 15
def deserialize_time_string(str)
  Time.parse(str).in_time_zone('UTC')
end
milliseconds_between(time1, time2) click to toggle source
# File lib/tracebin/helpers.rb, line 19
def milliseconds_between(time1, time2)
  time1 = deserialize_time_string(time1) if time1.is_a?(String)
  time2 = deserialize_time_string(time2) if time2.is_a?(String)

  to_milliseconds(time1 - time2).abs
end
time_to_string(time) click to toggle source
# File lib/tracebin/helpers.rb, line 7
def time_to_string(time)
  time.is_a?(String) ? time : time.in_time_zone('UTC').iso8601(6)
end
timestamp_string() click to toggle source
# File lib/tracebin/helpers.rb, line 11
def timestamp_string
  Time.now.in_time_zone('UTC').iso8601 6
end
to_milliseconds(time) click to toggle source
# File lib/tracebin/helpers.rb, line 3
def to_milliseconds(time)
  time.to_f * 1000
end