On Mon, Oct 27, 2008 at 1:20 PM, PÃ¥l Bergström <pal / palbergstrom.com> wrote: > Todd Benson wrote: >> On Mon, Oct 27, 2008 at 9:12 AM, P�ì Bergstr�í <pal / palbergstrom.com> wrote: >>> How do I get number of days in a year? >> >> You can use the date library... >> >> require 'date'; puts Date.new(2005) - Date.new(2004) >> => 366 >> >> Todd > > So there's nothing like this (Rails) > > Time.days_in_month() You could just "require 'activesupport'" or look at the code in activesupport... condensed for your immediate use! class Time COMMON_YEAR_DAYS_IN_MONTH = [nil, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] class << self # Return the number of days in the given month. # If no year is specified, it will use the current year. def days_in_month(month, year = now.year) return 29 if month == 2 && ::Date.gregorian_leap?(year) COMMON_YEAR_DAYS_IN_MONTH[month] end end end