diff options
author | Geoff Buesing <gbuesing@gmail.com> | 2008-02-16 20:13:38 +0000 |
---|---|---|
committer | Geoff Buesing <gbuesing@gmail.com> | 2008-02-16 20:13:38 +0000 |
commit | 4e3ecec9c76c612facd995031fb1c2a499d5d4c4 (patch) | |
tree | 40e2cdf4544ecdff9ff520352d7d484b3fba89a5 /activerecord | |
parent | 1d5ea1857fc0be912b89c4c5032733163da5b31b (diff) | |
download | rails-4e3ecec9c76c612facd995031fb1c2a499d5d4c4.tar.gz rails-4e3ecec9c76c612facd995031fb1c2a499d5d4c4.tar.bz2 rails-4e3ecec9c76c612facd995031fb1c2a499d5d4c4.zip |
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
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 8 |
2 files changed, 4 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 7ebe34b190..6231cc8bf8 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -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] diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index f7ee7ac7fd..d30f9b4d32 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -172,12 +172,8 @@ module ActiveRecord 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) |