Changeset 9137
- Timestamp:
- 03/29/08 21:23:10 (5 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/core_ext/date_time/conversions.rb
r9042 r9137 6 6 def self.included(base) #:nodoc: 7 7 base.class_eval do 8 alias_method :to_default_s, :to_s if instance_methods.include?(:to_s) 8 9 alias_method :to_s, :to_formatted_s 9 10 alias_method :default_inspect, :inspect … … 12 13 # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows 13 14 # DateTimes outside the range of what can be created with Time. 14 remove_method :to_time if base.instance_methods.include?(:to_time)15 remove_method :to_time if instance_methods.include?(:to_time) 15 16 end 16 17 end trunk/activesupport/test/core_ext/date_time_ext_test.rb
r9042 r9137 4 4 def test_to_s 5 5 datetime = DateTime.new(2005, 2, 21, 14, 30, 0, 0) 6 assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s)7 6 assert_equal "2005-02-21 14:30:00", datetime.to_s(:db) 8 7 assert_equal "14:30", datetime.to_s(:time) … … 11 10 assert_equal "Mon, 21 Feb 2005 14:30:00 +0000", datetime.to_s(:rfc822) 12 11 assert_equal "February 21st, 2005 14:30", datetime.to_s(:long_ordinal) 12 assert_match(/^2005-02-21T14:30:00(Z|\+00:00)$/, datetime.to_s) 13 13 end 14 14