aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2011-02-13 02:10:13 -0200
committerSantiago Pastorino <santiago@wyeworks.com>2011-02-13 02:10:13 -0200
commit944d314244676932eb1aa285d23f7d91f0678e68 (patch)
tree804bd0d58e1b3311bbab5df02f68e26df7e0100d
parentfbd917f50a6046d02dd6a64ccfb1aed0cbce68d8 (diff)
downloadrails-944d314244676932eb1aa285d23f7d91f0678e68.tar.gz
rails-944d314244676932eb1aa285d23f7d91f0678e68.tar.bz2
rails-944d314244676932eb1aa285d23f7d91f0678e68.zip
Add Date#rfc3339 and Date#iso8601 to AS
-rw-r--r--actionpack/lib/action_view/helpers/date_helper.rb1
-rw-r--r--activesupport/lib/active_support/core_ext/date/conversions.rb6
-rw-r--r--activesupport/test/core_ext/date_ext_test.rb10
3 files changed, 17 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/date_helper.rb b/actionpack/lib/action_view/helpers/date_helper.rb
index 737720792a..dc8e4bc316 100644
--- a/actionpack/lib/action_view/helpers/date_helper.rb
+++ b/actionpack/lib/action_view/helpers/date_helper.rb
@@ -1,5 +1,6 @@
require 'date'
require 'action_view/helpers/tag_helper'
+require 'active_support/core_ext/date/conversions'
require 'active_support/core_ext/hash/slice'
require 'active_support/core_ext/object/with_options'
diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb
index 06d868a3b0..769ead9544 100644
--- a/activesupport/lib/active_support/core_ext/date/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date/conversions.rb
@@ -93,6 +93,12 @@ class Date
::DateTime.civil(year, month, day, 0, 0, 0, 0)
end if RUBY_VERSION < '1.9'
+ def iso8601
+ strftime('%F')
+ end if RUBY_VERSION < '1.9'
+
+ alias_method :rfc3339, :iso8601 if RUBY_VERSION < '1.9'
+
def xmlschema
to_time_in_current_zone.xmlschema
end
diff --git a/activesupport/test/core_ext/date_ext_test.rb b/activesupport/test/core_ext/date_ext_test.rb
index 342a31cdef..b4d7633e5f 100644
--- a/activesupport/test/core_ext/date_ext_test.rb
+++ b/activesupport/test/core_ext/date_ext_test.rb
@@ -376,6 +376,16 @@ class DateExtCalculationsTest < ActiveSupport::TestCase
end
end
+ if RUBY_VERSION < '1.9'
+ def test_rfc3339
+ assert_equal('1980-02-28', Date.new(1980, 2, 28).rfc3339)
+ end
+
+ def test_iso8601
+ assert_equal('1980-02-28', Date.new(1980, 2, 28).iso8601)
+ end
+ end
+
def test_today
Date.stubs(:current).returns(Date.new(2000, 1, 1))
assert_equal false, Date.new(1999, 12, 31).today?