aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSantiago Pastorino <santiago@wyeworks.com>2012-01-12 15:32:40 -0800
committerSantiago Pastorino <santiago@wyeworks.com>2012-01-12 15:32:40 -0800
commit31472ba6328e1be5f7390840d00e67862510c2e2 (patch)
tree2e42000246c4a5af148d44730e7a9a20d52dfa64
parenta59269d9990ea579610641736e89e6560015b6d8 (diff)
parentb8e1efdf3e773b9c08940d4fafd6804107e67c03 (diff)
downloadrails-31472ba6328e1be5f7390840d00e67862510c2e2.tar.gz
rails-31472ba6328e1be5f7390840d00e67862510c2e2.tar.bz2
rails-31472ba6328e1be5f7390840d00e67862510c2e2.zip
Merge pull request #4432 from lest/patch-1
to_date, to_time, and to_datetime Time methods present in ruby 1.9
-rw-r--r--activesupport/lib/active_support/core_ext/time/conversions.rb28
1 files changed, 0 insertions, 28 deletions
diff --git a/activesupport/lib/active_support/core_ext/time/conversions.rb b/activesupport/lib/active_support/core_ext/time/conversions.rb
index 5a17fc1afa..0fdcd383f0 100644
--- a/activesupport/lib/active_support/core_ext/time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/time/conversions.rb
@@ -53,32 +53,4 @@ class Time
def formatted_offset(colon = true, alternate_utc_string = nil)
utc? && alternate_utc_string || ActiveSupport::TimeZone.seconds_to_utc_offset(utc_offset, colon)
end
-
- # Converts a Time object to a Date, dropping hour, minute, and second precision.
- #
- # my_time = Time.now # => Mon Nov 12 22:59:51 -0500 2007
- # my_time.to_date # => Mon, 12 Nov 2007
- #
- # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
- # your_time.to_date # => Tue, 13 Jan 2009
- def to_date
- ::Date.new(year, month, day)
- end unless method_defined?(:to_date)
-
- # A method to keep Time, Date and DateTime instances interchangeable on conversions.
- # In this case, it simply returns +self+.
- def to_time
- self
- end unless method_defined?(:to_time)
-
- # Converts a Time instance to a Ruby DateTime instance, preserving UTC offset.
- #
- # my_time = Time.now # => Mon Nov 12 23:04:21 -0500 2007
- # my_time.to_datetime # => Mon, 12 Nov 2007 23:04:21 -0500
- #
- # your_time = Time.parse("1/13/2009 1:13:03 P.M.") # => Tue Jan 13 13:13:03 -0500 2009
- # your_time.to_datetime # => Tue, 13 Jan 2009 13:13:03 -0500
- def to_datetime
- ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400))
- end unless method_defined?(:to_datetime)
end