This project is archived and is in readonly mode.
Change to end_of_day causes problem with saving records
Reported by Steven | October 7th, 2009 @ 12:30 AM
In ticket #3212, 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
Comments and changes to this ticket
-
Gregory Becker November 3rd, 2009 @ 04:45 PM
+1 this change is not compatible with the way date are stored in databases
-
Rohit Arondekar October 6th, 2010 @ 06:33 AM
- State changed from new to stale
- Importance changed from to
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>