A little app I wrote has a calendar view for three months.
Everything went fine until today, when it didn't display August -
September - October, but August - August - September. Next month had
become this month.
Watch this:
Time.now
=> Wed Aug 01 21:13:55 +0200 2007
1.month.from_now
=> Fri Aug 31 21:14:01 +0200 2007
Time.now.advance :months=>1
=> Sat Sep 01 21:14:13 +0200 2007
Especially annoying since the rdoc for
ActiveSupport::CoreExtensions::Numeric::Time pretends that:
These methods use Time#advance for precise date calculations when using
from_now, ago, etc. as well as adding or subtracting their results from a Time object. For example:
# equivalent to Time.now.advance(:months => 1)
1.month.from_now
A little app I wrote has a calendar view for three months.
Everything went fine until today, when it didn't display August -
September - October, but August - August - September. Next month had
become this month.
Watch this:
Time.now
=> Wed Aug 01 21:13:55 +0200 2007
1.month.from_now
=> Fri Aug 31 21:14:01 +0200 2007
Time.now.advance :months=>1
=> Sat Sep 01 21:14:13 +0200 2007
Especially annoying since the rdoc for
ActiveSupport::CoreExtensions::Numeric::Time pretends that:
These methods use Time#advance for precise date calculations when using
from_now, ago, etc. as well as adding or subtracting their results from a Time
object. For example:
# equivalent to Time.now.advance(:months => 1)
1.month.from_now