In ticket #3212 Almost 1 second extra in time subtraction (rails 2.3.4), it is pointed at that rails 2.3.4 changed
the definition of end_of_day to be
change(:hour => 23, :min => 59, :sec => 59, :usec => 999999.999)
where previously it had been
change(:hour => 23, :min => 59, :sec => 59)
If an object that has a datetime field which is set to
end_of_day is saved, the datetime is rounded down to just the
seconds. When you reload the object, you get back something where
the datetime field doesn't == what was saved.
>> e = Event.new(:transaction_date => Time.zone.now.end_of_day)
=> #<Event id: nil, transaction_date: "2009-10-06 23:59:59">
>> e.transaction_date.to_f
=> 1254873600.0
>> e.save!
=> true
>> e.id
=> 2867
>> new_e = Event.find(2867)
=> #<Event id: 2867, account_id: nil, amount: #<BigDecimal:1fe79b8,'0.1E1',4(8)>, description: "desc", flavor: "Withdraw", created_at: "2009-10-06 23:26:42", updated_at: "2009-10-06 23:26:42", post_balance: nil, transaction_date: "2009-10-06 23:59:59", details: nil>
>> new_e.transaction_date.to_f
=> 1254873599.0
>> e.transaction_date == new_e.transaction_date
=> false
In addition, it's difficult to figure out what is wrong because
the to_s representations of both dates are the same
>> e.transaction_date
=> Tue, 06 Oct 2009 23:59:59 UTC +00:00
>> new_e.transaction_date
=> Tue, 06 Oct 2009 23:59:59 UTC +00:00