From: Brian Candler Date: 2008-10-28T19:18:52+09:00 Subject: Re: Days in a year P奪l Bergstr旦m wrote: > A stupid question in the first place. I've done like this; I check if > Feb in a particular year has 29 days or not, so it gives 365 or 366 > days. Simple. :-) And notice how days_in_month is implemented in activesupport: def days_in_month(month, year = now.year) return 29 if month == 2 && ::Date.gregorian_leap?(year) COMMON_YEAR_DAYS_IN_MONTH[month] end So all you need is: irb(main):001:0> require 'date' => true irb(main):002:0> Date.gregorian_leap?(2008) ? 366 : 365 => 366 irb(main):003:0> Date.gregorian_leap?(2009) ? 366 : 365 => 365 -- Posted via http://www.ruby-forum.com/.