Sha256: 946e70c611b550bf00687c70ef0ae15d2632dbb88339506a9cebdc611e7267b9

Contents?: true

Size: 741 Bytes

Versions: 3

Compression:

Stored size: 741 Bytes

Contents

require 'time'

class DateTime
  ##
  # Convert to Time object (for DateTime/Time conversion protocol).
  #
  #   DateTime.now.to_time    #=> Wed Nov 19 20:04:51 -0800 2008
  #
  # @return [Time] Time object representing the same moment as receiver
  #
  # @api public
  remove_method :to_time if instance_methods(false).any? { |m| m.to_sym == :to_time }
  def to_time
    Time.parse self.to_s
  end

  ##
  # Return receiver (for DateTime/Time conversion protocol).
  #
  #   DateTime.now.to_datetime    #=> #<DateTime: 212093913977/86400,-1/3,2299161>
  #
  # @return [DateTime] Receiver
  #
  # @api public
  remove_method :to_datetime if instance_methods(false).any? { |m| m.to_sym == :to_datetime }
  def to_datetime
    self
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
extlib-0.9.16 lib/extlib/datetime.rb
extlib-0.9.15 lib/extlib/datetime.rb
robsharp-extlib-0.9.15 lib/extlib/datetime.rb