From: Michael Kohl Date: 2009-06-11T19:52:46+09:00 Subject: Re: Is there a decent canonical way to get total days in a month from say Time class? On Thu, Jun 11, 2009 at 3:02 AM, Xeno Campanoli wrote: > I suppose I could flip through local until I generate an exception, but > somehow I would think there would be a set of class methods to get: > >        daysofmonth = Time.daysofmonth(y,m) Do you want to get the maximum number of days for a given year/month combination? Here you go: def days_of_month(year=Time.now.year, m=1) (Date.new(year,12,31)<<12-month).day end days_of_month(2004, 2) # => 29 days_of_month(2003, 2) # => 28 Michael -- Blog: http://citizen428.net/ Twitter: http://twitter.com/citizen428