This actually seems to work just fine (which was a surprise to me, and  
I'll have to look into why at a later date), adding the following  
tests work just fine:

     def test_fractional_days_with_bst
       Time.zone_default = nil
       with_env_tz 'GB' do
         Time.stubs(:now).returns Time.local(2008, 10, 26, 12)
         assert_equal(Time.local(2008, 10, 25, 0), 1.5.days.ago)
       end
     end

     def test_fractional_days_additional_equivilance_with_dst
       with_env_tz 'GB' do
         Time.stubs(:now).returns Time.local(2008, 10, 25, 12)
         assert_equal(Time.now + 3.days, Time.now + 1.5.days + 1.5.days)
         assert_equal(Time.now + 3.days, Time.now + (1.5.days +  
1.5.days))
         assert_equal(Time.now + 3.days, (Time.now + 1.5.days) +  
1.5.days)
       end
     end

Do you have a test case that fails?

On 8 Sep 2008, at 17:15, Geoff B <[EMAIL PROTECTED]> wrote:

>
> On Sep 8, 5:46 am, Tom Lea <[EMAIL PROTECTED]> wrote:
>> 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.
>
> So, in other words, the fractional part of a day would always be
> relative to a standard 24 hour day, whereas the integer part will be
> sensitive to the 23 and 25 hour days that occur once per year in zones
> with DST.
>
> One issue with this setup would be:
>
> Time.now + 1.5.days + 1.5.days
>
> would not always return the same result as:
>
> Time.now + 3.days
>
> Is this edge case acceptable? Thoughts?
> >

--~--~---------~--~----~------------~-------~--~----~
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