Sha256: e6b84432cf195d28ac03a610bbfd529d0d8fe7247e19479d10531c435386926c

Contents?: true

Size: 741 Bytes

Versions: 22

Compression:

Stored size: 741 Bytes

Contents

require "date"

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

22 entries across 21 versions & 5 rubygems

Version Path
sundbp-extlib-0.9.14 lib/extlib/datetime.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.9.1/gems/extlib-0.9.14/lib/extlib/datetime.rb
middleman-0.13.1 lib/middleman/vendor/gems/ruby/1.8/gems/extlib-0.9.14/lib/extlib/datetime.rb
middleman-0.12.2 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/datetime.rb
middleman-0.12.1 lib/middleman/vendor/gems/gems/extlib-0.9.14/lib/extlib/datetime.rb
extlib-0.9.14 lib/extlib/datetime.rb
ginst-2009.12.8 vendor/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.12.0.pre3 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.12.0.pre2 lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.12.0.pre lib/middleman/vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
ginst-2009.11.24 vendor/gems/extlib-0.9.13/lib/extlib/datetime.rb
ginst-2009.11.23 vendor/gems/extlib-0.9.13/lib/extlib/datetime.rb
rango-0.0.6 vendor/extlib/lib/extlib/datetime.rb
rango-0.1.pre vendor/extlib/lib/extlib/datetime.rb
middleman-0.10.17 vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.10.16 vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.10.15 vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
middleman-0.10.14 vendor/gems/gems/extlib-0.9.13/lib/extlib/datetime.rb
ginst-2.0.1 vendor/gems/extlib-0.9.13/lib/extlib/datetime.rb
ginst-2.0.0 vendor/gems/extlib-0.9.13/lib/extlib/datetime.rb