aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/type/time_value.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-20 14:07:58 -0700
committerSean Griffin <sean@thoughtbot.com>2014-05-20 14:07:58 -0700
commit8f387995054d9ce79522da8ef65fba28c6ea0785 (patch)
tree53d38918ff2ccbb11dd503d56108e21df031646c /activerecord/lib/active_record/connection_adapters/type/time_value.rb
parent25c672637206a2c48fd829c58596c788b6e31c5d (diff)
downloadrails-8f387995054d9ce79522da8ef65fba28c6ea0785.tar.gz
rails-8f387995054d9ce79522da8ef65fba28c6ea0785.tar.bz2
rails-8f387995054d9ce79522da8ef65fba28c6ea0785.zip
Inline typecasting helpers from Column to the appropriate types
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/type/time_value.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/type/time_value.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/type/time_value.rb b/activerecord/lib/active_record/connection_adapters/type/time_value.rb
index d9564d7f48..654e5c7943 100644
--- a/activerecord/lib/active_record/connection_adapters/type/time_value.rb
+++ b/activerecord/lib/active_record/connection_adapters/type/time_value.rb
@@ -18,6 +18,14 @@ module ActiveRecord
::Time.public_send(Base.default_timezone, year, mon, mday, hour, min, sec, microsec) rescue nil
end
end
+
+ # Doesn't handle time zones.
+ def fast_string_to_time(string)
+ if string =~ Column::Format::ISO_DATETIME
+ microsec = ($7.to_r * 1_000_000).to_i
+ new_time $1.to_i, $2.to_i, $3.to_i, $4.to_i, $5.to_i, $6.to_i, microsec
+ end
+ end
end
end
end