aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/conversions.rb
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2010-07-03 21:30:33 -0300
committerJeremy Kemper <jeremy@bitsweat.net>2010-07-04 14:10:28 -0700
commit5bf3294c8b3aeb3afd426e8c182456c675829c1e (patch)
tree7445fa6fd045d3525241d6f397e178261aaa361f /activesupport/lib/active_support/core_ext/date/conversions.rb
parent8a09ea6d6dbbd6a1325b3be429d96d9c45c046df (diff)
downloadrails-5bf3294c8b3aeb3afd426e8c182456c675829c1e.tar.gz
rails-5bf3294c8b3aeb3afd426e8c182456c675829c1e.tar.bz2
rails-5bf3294c8b3aeb3afd426e8c182456c675829c1e.zip
Move Date#xmlschema to conversions and add a missing require
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date/conversions.rb')
-rw-r--r--activesupport/lib/active_support/core_ext/date/conversions.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb
index 48d474dd9a..092f936961 100644
--- a/activesupport/lib/active_support/core_ext/date/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date/conversions.rb
@@ -1,5 +1,6 @@
require 'date'
require 'active_support/inflector'
+require 'active_support/core_ext/date/zones'
class Date
DATE_FORMATS = {
@@ -12,7 +13,10 @@ class Date
}
# Ruby 1.9 has Date#to_time which converts to localtime only.
- remove_method :to_time if instance_methods.include?(:to_time)
+ remove_method :to_time if method_defined?(:to_time)
+
+ # Ruby 1.9 has Date#xmlschema which converts to a string without the time component.
+ remove_method :xmlschema if method_defined?(:xmlschema)
# Convert to a formatted string. See DATE_FORMATS for predefined formats.
#
@@ -77,7 +81,7 @@ class Date
def to_time(form = :local)
::Time.send("#{form}_time", year, month, day)
end
-
+
# Converts a Date instance to a DateTime, where the time is set to the beginning of the day
# and UTC offset is set to 0.
#
@@ -88,4 +92,8 @@ class Date
def to_datetime
::DateTime.civil(year, month, day, 0, 0, 0, 0)
end if RUBY_VERSION < '1.9'
+
+ def xmlschema
+ to_time_in_current_zone.xmlschema
+ end
end