The issue is that 1.5.days.ago == 1.days.ago, at all times in all cases.
This feels very bad.
The patch should handle this in a more sensible way, moving 1 day  
back, then moving 6 hours back.

I agree that the duration objects are a much more accurate apprioach  
than the 1.month == 30.days at all times stuff, but this is a bug  
caused by date (quite rightly) expecting to move only integer days, or  
integer months.

So no, 1.5.days.ago is not the same as 36.hours.ago in all cases, but  
it is the same a (1.days + 12.hours).ago in all cases.

Any clearer?

On 8 Sep 2008, at 10:43, Frederick Cheung wrote:

>
>
> On 8 Sep 2008, at 10:02, Tom Lea wrote:
>
>>
>> Hi Core,
>>      The following lighthouse ticket discusses an issue with the way
>> Time#advance works. By deferring all processing of days, and weeks to
>> the Date class, we loose the ability to deal in fractional days and
>> weeks.
>>
>> As a day an a week are both absolute length of times, we can handle
>> fractional ones just fine. This patch deals with that.
>>
>> http://rails.lighthouseapp.com/projects/8994/tickets/970
>>
>> Looking for feedback on the basic idea, or if anyone has a neater way
>> of doing it, but +1's or a commit would be nice.
>>
>
> Do you always expect 1.5 days to be == 36.hours ?
>
> For example, if the time is 12.00 on 26/10/2008 and you're working in
> london time, do you expect 1.5. days ago to be
>
> - midnight on 25/10/2008 (which is what the current code does)
> - 01:00 on  25/10/2008 (which is what subtracting 36 hours does)
>
> In 1.2.x 1.5.days and so on were just convenience methods that
> returned numbers of seconds, whereas now they are duration objects.
>
> Fred
>
>
>> Thanks
>> -Tom
>>
>>>
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to