aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/date/conversions.rb7
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb7
2 files changed, 14 insertions, 0 deletions
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
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index 1b78a72eea..ce0bfd8e0a 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -6,6 +6,8 @@ module ActiveSupport #:nodoc:
def self.included(klass)
klass.send(:alias_method, :to_datetime_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)
@@ -19,6 +21,11 @@ module ActiveSupport #:nodoc:
to_datetime_default_s
end
end
+
+ # Overrides the default inspect method with a human readable one, e.g., "Mon, 21 Feb 2005 14:30:00 +0000"
+ def readable_inspect
+ to_s(:rfc822)
+ end
# Converts self to a Ruby Date object; time portion is discarded
def to_date