Sha256: 651c7f1115c96a22c91a107cae5da8dcd3f1e6ea12c3518f2ad1c383051bf15b

Contents?: true

Size: 467 Bytes

Versions: 16

Compression:

Stored size: 467 Bytes

Contents

# frozen_string_literal: true

module Trusona
  module Helpers
    ##
    # Normalizes Strings, Date, DateTime, and Time into a UTC Time object
    module TimeNormalizer
      def normalize_time(time)
        return nil if time.nil?
        return time.to_time.gmtime if time.is_a?(DateTime)
        return time.gmtime if time.is_a?(Time)
        return Time.parse(time).gmtime if time.is_a?(String)
        return nil if time.is_a?(Date)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
trusona-2.5.3 lib/trusona/helpers/time_normalizer.rb
trusona-2.5.2 lib/trusona/helpers/time_normalizer.rb
trusona-2.5.1 lib/trusona/helpers/time_normalizer.rb
trusona-2.5.0 lib/trusona/helpers/time_normalizer.rb
trusona-2.4.0 lib/trusona/helpers/time_normalizer.rb
trusona-2.3.0 lib/trusona/helpers/time_normalizer.rb
trusona-2.2.0 lib/trusona/helpers/time_normalizer.rb
trusona-2.1.0 lib/trusona/helpers/time_normalizer.rb
trusona-2.0.0 lib/trusona/helpers/time_normalizer.rb
trusona-1.0.1 lib/trusona/helpers/time_normalizer.rb
trusona-1.0.0 lib/trusona/helpers/time_normalizer.rb
trusona-0.20.0 lib/trusona/helpers/time_normalizer.rb
trusona-0.19.0 lib/trusona/helpers/time_normalizer.rb
trusona-0.18.2 lib/trusona/helpers/time_normalizer.rb
trusona-0.18.1 lib/trusona/helpers/time_normalizer.rb
trusona-0.16.0 lib/trusona/helpers/time_normalizer.rb