Changeset 271
- Timestamp:
- 12/28/04 17:30:17 (4 years ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/base.rb (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb (modified) (1 diff)
- trunk/activerecord/test/base_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r270 r271 1 1 *SVN* 2 3 * Added Base.default_timezone accessor that determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates 4 and times from the database. This is set to :local by default. 2 5 3 6 * Added the possibility for adapters to overwrite add_limit! to implement a different limiting scheme than "LIMIT X" used by MySQL, PostgreSQL, and SQLite. trunk/activerecord/lib/active_record/base.rb
r269 r271 221 221 cattr_accessor :pluralize_table_names 222 222 @@pluralize_table_names = true 223 224 # Determines whether to use Time.local (using :local) or Time.utc (using :utc) when pulling dates and times from the database. 225 # This is set to :local by default. 226 cattr_accessor :default_timezone 227 @@default_timezone = :local 223 228 224 229 # When turned on (which is default), all associations are included using "load". This mean that any change is instant in cached trunk/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
r269 r271 221 221 time_array = ParseDate.parsedate(string).compact 222 222 # treat 0000-00-00 00:00:00 as nil 223 Time. local(*time_array) rescue nil224 end 225 226 def string_to_dummy_time(string)227 return string if Time === string228 time_array = ParseDate.parsedate(string)229 # pad the resulting array with dummy date information230 time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1;231 Time.local(*time_array) rescue nil232 end233 223 Time.send(Base.default_timezone, *time_array) rescue nil 224 end 225 226 def string_to_dummy_time(string) 227 return string if Time === string 228 time_array = ParseDate.parsedate(string) 229 # pad the resulting array with dummy date information 230 time_array[0] = 2000; time_array[1] = 1; time_array[2] = 1; 231 Time.send(Base.default_timezone, *time_array) rescue nil 232 end 233 234 234 def extract_limit(sql_type) 235 235 $1.to_i if sql_type =~ /\((.*)\)/ 236 236 end 237 237 238 238 def simplified_type(field_type) 239 239 case field_type trunk/activerecord/test/base_test.rb
r228 r271 328 328 assert_nil topic.last_read 329 329 end 330 330 331 def test_utc_as_time_zone 332 Topic.default_timezone = :utc 333 attributes = { "bonus_time" => "5:42:00AM" } 334 topic = Topic.find(1) 335 topic.attributes = attributes 336 assert_equal Time.utc(2000, 1, 1, 5, 42, 0), topic.bonus_time 337 Topic.default_timezone = :local 338 end 339 331 340 def test_default_values_on_empty_strings 332 341 topic = Topic.new