aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2006-08-07 22:07:33 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2006-08-07 22:07:33 +0000
commit52c9ad4c9828504ff7859a9dc7ee33d3bdd532c4 (patch)
tree20b4475565a10b5810948fcdccd0b1c2126ccd3a /activesupport/lib/active_support/core_ext/date
parentc3cdd3b6595ad59129d7652f6f3274f26509a4dc (diff)
downloadrails-52c9ad4c9828504ff7859a9dc7ee33d3bdd532c4.tar.gz
rails-52c9ad4c9828504ff7859a9dc7ee33d3bdd532c4.tar.bz2
rails-52c9ad4c9828504ff7859a9dc7ee33d3bdd532c4.zip
DateTime#to_time gives hour/minute/second resolution. Closes #5747.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4718 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/core_ext/date')
-rw-r--r--activesupport/lib/active_support/core_ext/date/conversions.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/activesupport/lib/active_support/core_ext/date/conversions.rb b/activesupport/lib/active_support/core_ext/date/conversions.rb
index bae20c66db..4b9388dacd 100644
--- a/activesupport/lib/active_support/core_ext/date/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date/conversions.rb
@@ -7,14 +7,14 @@ module ActiveSupport #:nodoc:
:short => "%e %b",
:long => "%B %e, %Y"
}
-
+
def self.included(klass) #:nodoc:
klass.send(:alias_method, :to_default_s, :to_s)
klass.send(:alias_method, :to_s, :to_formatted_s)
end
-
+
def to_formatted_s(format = :default)
- DATE_FORMATS[format] ? strftime(DATE_FORMATS[format]).strip : to_default_s
+ DATE_FORMATS[format] ? strftime(DATE_FORMATS[format]).strip : to_default_s
end
# To be able to keep Dates and Times interchangeable on conversions
@@ -23,7 +23,11 @@ module ActiveSupport #:nodoc:
end
def to_time(form = :local)
- ::Time.send(form, year, month, day)
+ if respond_to?(:hour)
+ ::Time.send(form, year, month, day, hour, min, sec)
+ else
+ ::Time.send(form, year, month, day)
+ end
end
def xmlschema