[UPHPU] building a dynamic calendar
Daniel C.
dcrookston at gmail.com
Thu Mar 15 00:14:43 MDT 2007
On 3/14/07, Wade Preston Shearer <lists at wadeshearer.com> wrote:
> I am building a calendar inside of a web application. Is there a way
> to determine how many days are in each month (February would be the
> only one that varies) and which day of the week it begins on without
> hard coding an array?
cal_days_in_month and friends
If you want to do it manually - it's a leap year if it's divisible by
4, but not by 100. Unless it's divisible by 400, in which case it is
again. This keeps us very close to the actual rotation of the earth,
and only needs to be adjusted by a couple of minutes every few decades
or so.
If you want to have more fun, you can calculate when Easter is on each
year (done for you with easter_date), or even better, Mardi Gras.
(The first Tuesday after the day which is 47 days prior to Easter.)
If you want to get absolutely insane, you can calculate what day
Calendar Programmer Appreciation Day lands on. (The first Friday
after the first full moon after the date six months previous to the
next year's Mardi Gras. It varies, of course, if the next year (the
year whose Mardi Gras you're considering) is a leap year.)
DTC
More information about the UPHPU
mailing list