Permalink
Browse files

Refactor ActiveRecord::ConnectionAdapters::Column.new_time: leverage …

…DateTime failover behavior of Time#time_with_datetime_fallback

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8881 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 1d5ea18 commit 4e3ecec9c76c612facd995031fb1c2a499d5d4c4 @gbuesing gbuesing committed Feb 16, 2008
View
@@ -1,5 +1,7 @@
*SVN*
+* Refactor ConnectionAdapters::Column.new_time: leverage DateTime failover behavior of Time#time_with_datetime_fallback [Geoff Buesing]
+
* Improve associations performance by using symbol callbacks instead of string callbacks. #11108 [adymo]
* Optimise the BigDecimal conversion code. #11110 [adymo]
@@ -172,12 +172,8 @@ def new_date(year, mon, mday)
def new_time(year, mon, mday, hour, min, sec, microsec)
# Treat 0000-00-00 00:00:00 as nil.
return nil if year.nil? || year == 0
-
- Time.send(Base.default_timezone, year, mon, mday, hour, min, sec, microsec)
- # Over/underflow to DateTime
- rescue ArgumentError, TypeError
- zone_offset = Base.default_timezone == :local ? DateTime.local_offset : 0
- DateTime.civil(year, mon, mday, hour, min, sec, zone_offset) rescue nil
+
+ Time.time_with_datetime_fallback(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil
end
def fast_string_to_date(string)

0 comments on commit 4e3ecec

Please sign in to comment.