Sha256: 5a05c7704e03af9cf3e592b9d21b6297c9577b1cf07d639a41f481bc19fc083f

Contents?: true

Size: 549 Bytes

Versions: 12

Compression:

Stored size: 549 Bytes

Contents

require 'time'

module BerkeleyLibrary
  module Util
    module Times
      class << self
        include Times
      end

      # @param time [Time, Date] the time
      # @return the UTC time corresponding to `time`
      def ensure_utc(time)
        return unless time
        return time if time.respond_to?(:utc?) && time.utc?
        return time.getutc if time.respond_to?(:getutc)
        return time.to_time.getutc if time.respond_to?(:to_time)

        raise ArgumentError, "Not a date or time: #{time.inspect}"
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
berkeley_library-util-0.1.9 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.8 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.7 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.6 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.5 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.4 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.3 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.2 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.1 lib/berkeley_library/util/times.rb
berkeley_library-util-0.1.0 lib/berkeley_library/util/times.rb
berkeley_library-tind-0.4.1 lib/berkeley_library/util/times.rb
berkeley_library-tind-0.4.0 lib/berkeley_library/util/times.rb