[UPHPU] building a dynamic calendar

Brandon Stout bms at mscis.org
Thu Mar 15 00:27:28 MDT 2007


Daniel C. wrote:

> 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

BC will introduce complications here, and if you want to-the-second accuracy, there is a change in earth's rotation with every earthquake and potentially a resulting leap second or two - which can be forward or backward, depending on if the earth's rotation sped up or slowed down.  Plus the fact that leap year started some year AD.  All this, of course assumes you're using a Gregorian calendar.  Mayan, Aztec, Chinese, Hebrew, and many other calendars exist.

Brandon Stout
http://mscis.org



More information about the UPHPU mailing list