diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-01 13:18:51 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2004-12-01 13:18:51 +0000 |
commit | 0daa29ece29191b288fe86d3616bea0357325419 (patch) | |
tree | 7a86e47e5b7c68467c1ef01e08be0ac24faf29a9 /activerecord/lib | |
parent | 50f333b203756009acff2457b6d1c9da3b532cad (diff) | |
download | rails-0daa29ece29191b288fe86d3616bea0357325419.tar.gz rails-0daa29ece29191b288fe86d3616bea0357325419.tar.bz2 rails-0daa29ece29191b288fe86d3616bea0357325419.zip |
Added proper handling of time fields that are turned into Time objects with the dummy date of 2000/1/1 [HariSeldon]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@40 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 4689ac3ac3..301ee208a3 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -182,6 +182,7 @@ module ActiveRecord when :float then Float when :datetime then Time when :date then Date + when :time then Time when :text, :string then String when :boolean then Object end @@ -195,6 +196,7 @@ module ActiveRecord when :integer then value.to_i when :float then value.to_f when :datetime then string_to_time(value) + when :time then string_to_dummy_time(value) when :date then string_to_date(value) when :boolean then (value == "t" or value == true ? true : false) else value @@ -220,6 +222,14 @@ module ActiveRecord Time.local(*time_array) rescue nil end + def string_to_dummy_time(string) + return string if Time === string + time_array = ParseDate.parsedate(string) + # pad the resulting array with dummy date information + time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; + Time.local(*time_array) rescue nil + end + def extract_limit(sql_type) $1.to_i if sql_type =~ /\((.*)\)/ end @@ -230,8 +240,10 @@ module ActiveRecord :integer when /float|double|decimal|numeric/i :float - when /time/i + when /datetime/i :datetime + when /time/i + :time when /date/i :date when /(c|b)lob/i, /text/i |