Changeset 4718
- Timestamp:
- 08/07/06 22:07:33 (2 years ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/date/conversions.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/date_ext_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r4692 r4718 1 1 *SVN* 2 3 * DateTime#to_time gives hour/minute/second resolution. #5747 [jon.evans@pobox.com] 2 4 3 5 * attr_internal to support namespacing and deprecation. Like attr_* except backed by internally-named instance variable. Set attr_internal_naming_format to change the format from the default '@_%s'. [Jeremy Kemper] trunk/activesupport/lib/active_support/core_ext/date/conversions.rb
r4653 r4718 8 8 :long => "%B %e, %Y" 9 9 } 10 10 11 11 def self.included(klass) #:nodoc: 12 12 klass.send(:alias_method, :to_default_s, :to_s) 13 13 klass.send(:alias_method, :to_s, :to_formatted_s) 14 14 end 15 15 16 16 def to_formatted_s(format = :default) 17 DATE_FORMATS[format] ? strftime(DATE_FORMATS[format]).strip : to_default_s 17 DATE_FORMATS[format] ? strftime(DATE_FORMATS[format]).strip : to_default_s 18 18 end 19 19 … … 24 24 25 25 def to_time(form = :local) 26 ::Time.send(form, year, month, day) 26 if respond_to?(:hour) 27 ::Time.send(form, year, month, day, hour, min, sec) 28 else 29 ::Time.send(form, year, month, day) 30 end 27 31 end 28 32 trunk/activesupport/test/core_ext/date_ext_test.rb
r4595 r4718 11 11 end 12 12 13 def test_to_time_on_datetime 14 assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12).to_time 15 end 16 13 17 def test_to_date 14 18 assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date