Changeset 8199
- Timestamp:
- 11/24/07 04:59:21 (1 year ago)
- Files:
-
- trunk/activerecord/CHANGELOG (modified) (1 diff)
- trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb (modified) (1 diff)
- trunk/activerecord/test/migration_test.rb (modified) (2 diffs)
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/date/conversions.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/string/conversions.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/time/calculations.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/time/conversions.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/date_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/string_ext_test.rb (modified) (1 diff)
- trunk/activesupport/test/core_ext/time_ext_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activerecord/CHANGELOG
r8178 r8199 1 1 *SVN* 2 3 * DateTimes use Ruby's default calendar reform setting. #10201 [Geoff Buesing] 2 4 3 5 * Dynamic finders on association collections respect association :order and :limit. #10211, #10227 [Patrick Joyce, Rick Olson, Jack Danger Canty] trunk/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
r8113 r8199 175 175 rescue ArgumentError, TypeError 176 176 zone_offset = Base.default_timezone == :local ? DateTime.local_offset : 0 177 # Append zero calendar reform start to account for dates skipped by calendar reform 178 DateTime.new(year, mon, mday, hour, min, sec, zone_offset, 0) rescue nil 177 DateTime.civil(year, mon, mday, hour, min, sec, zone_offset) rescue nil 179 178 end 180 179 trunk/activerecord/test/migration_test.rb
r7996 r8199 287 287 :wealth => BigDecimal.new("12345678901234567890.0123456789"), 288 288 :birthday => 18.years.ago, :favorite_day => 10.days.ago, 289 :moment_of_truth => "1 582-10-10 21:40:18", :male => true289 :moment_of_truth => "1782-10-10 21:40:18", :male => true 290 290 end 291 291 … … 324 324 assert_not_equal 0, bob.moment_of_truth.offset 325 325 assert_not_equal "Z", bob.moment_of_truth.zone 326 assert_equal DateTime::ITALY, bob.moment_of_truth.start 326 327 end 327 328 trunk/activesupport/CHANGELOG
r8198 r8199 1 1 *SVN* 2 3 * Time#time_with_datetime_fallback, Time#to_datetime, Date#to_datetime and String#to_datetime honor Ruby's default calendar reform setting. #10201 [Geoff Buesing] 2 4 3 5 * Change Time and DateTime #end_of_month to return last second of month instead of beginning of last day of month. Closes #10200 [Geoff Buesing] trunk/activesupport/lib/active_support/core_ext/date/conversions.rb
r7647 r8199 54 54 # Converts self to a Ruby DateTime object; time is set to beginning of day 55 55 def to_datetime 56 ::DateTime.civil(year, month, day, 0, 0, 0, 0 , 0)56 ::DateTime.civil(year, month, day, 0, 0, 0, 0) 57 57 end if RUBY_VERSION < '1.9' 58 58 trunk/activesupport/lib/active_support/core_ext/string/conversions.rb
r6935 r8199 16 16 17 17 def to_datetime 18 ::DateTime.civil(*ParseDate.parsedate(self)[0..5].map {|arg| arg || 0} << 0 << 0)18 ::DateTime.civil(*ParseDate.parsedate(self)[0..5].map {|arg| arg || 0} << 0) 19 19 end 20 20 end trunk/activesupport/lib/active_support/core_ext/time/calculations.rb
r8198 r8199 37 37 rescue 38 38 offset = utc_or_local.to_sym == :local ? ::DateTime.local_offset : 0 39 ::DateTime.civil(year, month, day, hour, min, sec, offset , 0)39 ::DateTime.civil(year, month, day, hour, min, sec, offset) 40 40 end 41 41 trunk/activesupport/lib/active_support/core_ext/time/conversions.rb
r7647 r8199 44 44 # converts to a Ruby DateTime instance; preserves utc offset 45 45 def to_datetime 46 ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400) , 0)46 ::DateTime.civil(year, month, day, hour, min, sec, Rational(utc_offset, 86400)) 47 47 end 48 48 end trunk/activesupport/test/core_ext/date_ext_test.rb
r8076 r8199 24 24 def test_to_datetime 25 25 assert_equal DateTime.civil(2005, 2, 21), Date.new(2005, 2, 21).to_datetime 26 assert_equal 0, Date.new(2005, 2, 21).to_datetime.offset # use UTC offset 27 assert_equal ::Date::ITALY, Date.new(2005, 2, 21).to_datetime.start # use Ruby's default start value 26 28 end 27 29 trunk/activesupport/test/core_ext/string_ext_test.rb
r7656 r8199 84 84 assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time 85 85 assert_equal Time.local_time(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_time(:local) 86 end 87 88 def test_string_to_datetime 89 assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime 90 assert_equal 0, "2039-02-27 23:50".to_datetime.offset # use UTC offset 91 assert_equal ::Date::ITALY, "2039-02-27 23:50".to_datetime.start # use Ruby's default start value 92 end 93 94 def test_string_to_date 86 95 assert_equal Date.new(2005, 2, 27), "2005-02-27".to_date 87 assert_equal DateTime.civil(2039, 2, 27, 23, 50), "2039-02-27 23:50".to_datetime88 96 end 89 97 trunk/activesupport/test/core_ext/time_ext_test.rb
r8198 r8199 335 335 assert_equal Time.local(2005, 2, 21, 17, 44, 30).to_datetime, DateTime.civil(2005, 2, 21, 17, 44, 30, Rational(Time.local(2005, 2, 21, 17, 44, 30).utc_offset, 86400), 0) 336 336 end 337 assert_equal ::Date::ITALY, Time.utc(2005, 2, 21, 17, 44, 30).to_datetime.start # use Ruby's default start value 337 338 end 338 339 … … 379 380 assert_equal Time.time_with_datetime_fallback(:utc, 2005, 2, 21, 17, 44, 30, 1), Time.utc(2005, 2, 21, 17, 44, 30, 1) #with usec 380 381 assert_equal Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30, 1), DateTime.civil(2039, 2, 21, 17, 44, 30, 0, 0) 382 assert_equal ::Date::ITALY, Time.time_with_datetime_fallback(:utc, 2039, 2, 21, 17, 44, 30, 1).start # use Ruby's default start value 381 383 end 382 384