From: "David A. Black" Date: 2005-04-26T03:20:21+09:00 Subject: Re: Days in month Hi -- On Tue, 26 Apr 2005, Dan Fitzpatrick wrote: > Is there a method of Date or Time that gives the number of days in a date's > month or the last day of the month like: > > d = Date.new(2005,4,20) > d.days_in_month #-> 30 > #or > d.last_day_of_month #-> 30 Funny you should ask :-) This came up on IRC a month or two ago, and the answer appears to be no. So I wrote one: # Date.dim -- days in month require 'date' class Date def dim d,m,y = mday,month,year d += 1 while Date.valid_civil?(y,m,d) d - 1 end end if __FILE__ == $0 puts (Date.today >> 1).dim puts (Date.today << 1).dim puts (Date.new(2004,2)).dim end __END__ David -- David A. Black dblack@wobblini.net