aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--activesupport/CHANGELOG2
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb9
-rw-r--r--activesupport/test/core_ext/time_ext_test.rb10
3 files changed, 14 insertions, 7 deletions
diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 3559f715d5..cf8b935be1 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Add :rfc822 as an option for Time#to_s (to get rfc822-formatted times)
+
* Chain the const_missing hook to any previously existing hook so rails can play nicely with rake
* Clean logger is compatible with both 1.8.2 and 1.8.3 Logger. #2263 [Michael Schuerig <michael@schuerig.de>]
diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb
index fadfb6b0df..6e7299762d 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -6,9 +6,10 @@ module ActiveSupport #:nodoc:
# Getting times in different convenient string representations and other objects
module Conversions
DATE_FORMATS = {
- :db => "%Y-%m-%d %H:%M:%S",
- :short => "%e %b %H:%M",
- :long => "%B %e, %Y %H:%M"
+ :db => "%Y-%m-%d %H:%M:%S",
+ :short => "%e %b %H:%M",
+ :long => "%B %e, %Y %H:%M",
+ :rfc822 => "%a, %d %b %Y %H:%M:%S %z"
}
def self.append_features(klass)
@@ -32,4 +33,4 @@ module ActiveSupport #:nodoc:
end
end
end
-end \ No newline at end of file
+end
diff --git a/activesupport/test/core_ext/time_ext_test.rb b/activesupport/test/core_ext/time_ext_test.rb
index 60649e4c76..86f8b7e4f6 100644
--- a/activesupport/test/core_ext/time_ext_test.rb
+++ b/activesupport/test/core_ext/time_ext_test.rb
@@ -118,9 +118,13 @@ class TimeExtCalculationsTest < Test::Unit::TestCase
end
def test_to_s
- assert_equal "2005-02-21 17:44:30", Time.local(2005, 2, 21, 17, 44, 30).to_s(:db)
- assert_equal "21 Feb 17:44", Time.local(2005, 2, 21, 17, 44, 30).to_s(:short)
- assert_equal "February 21, 2005 17:44", Time.local(2005, 2, 21, 17, 44, 30).to_s(:long)
+ time = Time.local(2005, 2, 21, 17, 44, 30)
+ assert_equal "2005-02-21 17:44:30", time.to_s(:db)
+ assert_equal "21 Feb 17:44", time.to_s(:short)
+ assert_equal "February 21, 2005 17:44", time.to_s(:long)
+
+ time = Time.utc(2005, 2, 21, 17, 44, 30)
+ assert_equal "Mon, 21 Feb 2005 17:44:30 +0000", time.to_s(:rfc822)
end
def test_to_date