diff options
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 5 | ||||
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 20 |
2 files changed, 15 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index ce10f03789..12f39c6985 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -221,6 +221,11 @@ module ActiveRecord #:nodoc: cattr_accessor :pluralize_table_names @@pluralize_table_names = true + # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. + # This is set to :local by default. + cattr_accessor :default_timezone + @@default_timezone = :local + # When turned on (which is default), all associations are included using "load". This mean that any change is instant in cached # environments like mod_ruby or FastCGI. When set to false, "require" is used, which is faster but requires server restart to # reflect changes. diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 1ca6d59977..454fe98e7f 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -220,21 +220,21 @@ module ActiveRecord return string if Time === string time_array = ParseDate.parsedate(string).compact # treat 0000-00-00 00:00:00 as nil - Time.local(*time_array) rescue nil + Time.send(Base.default_timezone, *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 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.send(Base.default_timezone, *time_array) rescue nil + end + def extract_limit(sql_type) $1.to_i if sql_type =~ /\((.*)\)/ end - + def simplified_type(field_type) case field_type when /int/i |