Loosing time when using active support time helpers

Time.parse('2009-01-01')+15.days+0.5.days
=> Fri Jan 16 00:00:00 +0100 2009

Time.parse('2009-01-01')+15.days+0.5.days.to_i
=> Fri Jan 16 12:00:00 +0100 2009

12.hours gone :(

ruby version 1.8.7

2 thoughts on “Loosing time when using active support time helpers

  1. I think it would be more expressive to say:

    Time.parse(‘2009-01-01’)+15.days+12.hours

    which works properly. The problem appears to be that 0.5.days returns a Float, whereas 15.days returns a FixNum.

Leave a reply to Craig Buchek Cancel reply