Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 1959

Show
Ignore:
Timestamp:
07/31/05 09:16:21 (4 years ago)
Author:
minam
Message:

Fixed that Time#midnight would have a non-zero usec on some platforms #1836

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r1881 r1959  
    11*SVN* 
     2 
     3* Fixed that Time#midnight would have a non-zero usec on some platforms #1836 
    24 
    35* Fixed inflections of "index/indices" #1766 [damn_pepe@gmail.com] 
  • trunk/activesupport/lib/active_support/core_ext/time/calculations.rb

    r1431 r1959  
    102102        # Returns a new Time representing the start of the day (0:00) 
    103103        def beginning_of_day 
    104           self - self.seconds_since_midnight 
     104          (self - self.seconds_since_midnight).change(:usec => 0) 
    105105        end 
    106106        alias :midnight :beginning_of_day 
  • trunk/activesupport/test/core_ext/time_ext_test.rb

    r1431 r1959  
    131131    assert_equal Time.local(2005, 2, 21, 17, 44, 30), Time.local(2005, 2, 21, 17, 44, 30).to_time 
    132132  end 
     133 
     134  # NOTE: this test seems to fail (changeset 1958) only on certain platforms, 
     135  # like OSX, and FreeBSD 5.4. 
     136  def test_fp_inaccuracy_ticket_1836 
     137    midnight = Time.local(2005, 2, 21, 0, 0, 0) 
     138    assert_equal midnight.midnight, (midnight + 1.hour + 0.000001).midnight 
     139  end 
    133140end