Sha256: 038ec769e86043bc0d6d8d01f6cd8020315ca49fefa04a20ec5e12a0bd801b6f

Contents?: true

Size: 576 Bytes

Versions: 9

Compression:

Stored size: 576 Bytes

Contents

require 'date'

class DateTime
  # Don't remove method if exists or it will conflict with ActiveRecord.
  # See http://github.com/weppos/whois/issues#issue/24
  unless method_defined?(:to_time)
    # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class
    # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time.
    #
    # Extracted from ActiveSupport.
    def to_time
      self.offset == 0 ? ::Time.utc(year, month, day, hour, min, sec) : self
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
whois-1.6.6 lib/core_ext.rb
whois-1.6.5 lib/core_ext.rb
whois-1.6.4 lib/core_ext.rb
whois-1.6.3 lib/core_ext.rb
whois-1.6.2 lib/core_ext.rb
whois-1.6.1 lib/core_ext.rb
whois-1.6.0 lib/core_ext.rb
whois-1.5.1 lib/core_ext.rb
whois-1.5.0 lib/core_ext.rb