aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorAndrew White <andyw@pixeltrix.co.uk>2012-07-01 08:02:41 +0100
committerAndrew White <andyw@pixeltrix.co.uk>2012-07-01 08:02:41 +0100
commitc685d12c19f953768ee445ab29faeb4a1be54535 (patch)
tree5f8bab62d4dd441eab1715d993ed9fa3273b54a1 /activesupport/lib
parent210cd756a628cc19c0d6e44bee8c33dfb2d9d598 (diff)
downloadrails-c685d12c19f953768ee445ab29faeb4a1be54535.tar.gz
rails-c685d12c19f953768ee445ab29faeb4a1be54535.tar.bz2
rails-c685d12c19f953768ee445ab29faeb4a1be54535.zip
Remove DateTime#to_time override
Currently if the offset is not zero then to_time returns self which can lead to errors where a developer assumes that the value is a Time. To solve this we can use the native implementation of DateTime#to_time in Ruby 1.9.3 as it handles offsets properly and is faster than our override.
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/date_time/conversions.rb14
1 files changed, 0 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/core_ext/date_time/conversions.rb b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
index b6a3c02dd6..262c03540b 100644
--- a/activesupport/lib/active_support/core_ext/date_time/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/date_time/conversions.rb
@@ -4,10 +4,6 @@ require 'active_support/core_ext/date_time/calculations'
require 'active_support/values/time_zone'
class DateTime
- # Ruby 1.9 has DateTime#to_time which internally relies on Time. We define our own #to_time which allows
- # DateTimes outside the range of what can be created with Time.
- remove_method :to_time
-
# Convert to a formatted string. See Time::DATE_FORMATS for predefined formats.
#
# This method is aliased to <tt>to_s</tt>.
@@ -57,16 +53,6 @@ class DateTime
alias_method :default_inspect, :inspect
alias_method :inspect, :readable_inspect
- # Attempts to convert self to a Ruby Time object; returns self if out of range of Ruby Time class.
- # If self has an offset other than 0, self will just be returned unaltered, since there's no clean way to map it to a Time.
- def to_time
- if offset == 0
- ::Time.utc_time(year, month, day, hour, min, sec, sec_fraction * 1000000)
- else
- self
- end
- end
-
# Returns DateTime with local offset for given year if format is local else offset is zero
#
# DateTime.civil_from_format :local, 2012