http://qs1969.pair.com?node_id=827306


in reply to Simple calendar

The calendar thing is one those functions that you do use from day to day. Most of the time I have used Calendar::Calendar to generate a straight grid type, but you mentioned that this may no work for you.

There are formulas to calculate month length, but the easiest is to set up a table, zero relative of the month length. Thirty days as November, April, June, and September, the others, save February, have thirty-one. February....

In February a little math is necessary. It is a leap year, 29 day, if:

$is_leap_year = (($year % 4) == 0) && ((($year % 100) != 0) #<- fixed typo... || (($year % 400) == 0));

So, right to left, years that are divisible by 400 are leap years, years divisible by 100, but not 400, are not, other years, save those divisible by 100 before, that are divisible by 4 are, and what is left is not.

I hope was able to give you some timely information.

Good luck. -c

Updated to fix a typo... -c