From 1312259294e859646d5c1a4d3000f2cd160fae94 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Mon, 4 Jun 2007 17:49:43 +0000 Subject: Readable Date and DateTime#inspect. Closes #8570. git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6933 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/core_ext/date/conversions.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activesupport/lib/active_support/core_ext/date') diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb index 25745b0f8b..6e864aee5e 100644 --- a/activesupport/lib/active_support/core_ext/date/conversions.rb +++ b/activesupport/lib/active_support/core_ext/date/conversions.rb @@ -14,6 +14,8 @@ module ActiveSupport #:nodoc: def self.included(klass) #:nodoc: klass.send(:alias_method, :to_default_s, :to_s) klass.send(:alias_method, :to_s, :to_formatted_s) + klass.send(:alias_method, :default_inspect, :inspect) + klass.send(:alias_method, :inspect, :readable_inspect) end def to_formatted_s(format = :default) @@ -27,6 +29,11 @@ module ActiveSupport #:nodoc: to_default_s end end + + # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005" + def readable_inspect + strftime("%a, %d %b %Y") + end # To be able to keep Times, Dates and DateTimes interchangeable on conversions def to_date -- cgit v1.2.3