From: Serg Koren Date: 2008-02-29T07:36:42+09:00 Subject: Re: Getting number of days in a month -- getting the number of weeks in a year. A more interesting question is how do you get the number of weeks in a year. Some years have 52...some have 54. Calendar weeks...not 7 day weeks. S On Feb 28, 2008, at 5:20 PM, William James wrote: > On Feb 27, 10:17 am, Shandy Nantz wrote: >> This is probably an easy question but I am trying to get at the >> number >> of days that are in a month. I have this calendar that I have >> built, the >> idea being that when a month turns from February to March, for >> example, >> the calendar should redisplay itself properly formated showing the >> new >> month and the correct number of days. I have it so that it starts >> counting the days on the right day of the week, but I have to know >> when >> to stop counting. Any ideas, Thanks, >> >> -S >> -- >> Posted viahttp://www.ruby-forum.com/. > > Awk (not my code): > > function days_in_month( y, m ) > { > return m==2 ? 28+!(y%4)-!(y%100)+!(y%400) : 30+(m%2 != (m>7)) > } >