From: Patrick Hurley Date: 2006-09-22T05:20:26+09:00 Subject: Re: Calculate last day of month On 9/21/06, James Moore wrote: > > d += 42 # warp into the next month > > You need to add a month, not a fixed number of days, since you can't predict > how many days are in the next month: > > irb(main):033:0> d = Date.new 2006, 1, 31 > => # > irb(main):034:0> (d >> 1).to_s > => "2006-02-28" > > > irb(main):039:0> d = Date.new 1996, 1, 31 > => # > irb(main):040:0> (d >> 1).to_s > => "1996-02-29" > > - James Moore > > > Yeah that was my first thought too, but notice he is constructing a new date at the beginning of the month. I am guessing he picked 42, over 32 as it is just much better number. pth