Sha256: 195322114ac8659fb45608f80104c7983a3772e83fdeb5583d9a4237f9b5a346

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

module Tracebin
  module Helpers
    def to_milliseconds(time)
      time.to_f * 1000
    end

    def time_to_string(time)
      time.is_a?(String) ? time : time.in_time_zone('UTC').iso8601(6)
    end

    def timestamp_string
      Time.now.in_time_zone('UTC').iso8601 6
    end

    def deserialize_time_string(str)
      Time.parse(str).in_time_zone('UTC')
    end

    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
  end
end

module Tracebin
  class PatchHelper
    class << self
      include ::Tracebin::Helpers
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.13 lib/tracebin/helpers.rb