[svlug] need an uptime birthday script
Tom Digby
bubbles at well.com
Sun Jun 21 17:04:37 PDT 2009
Robert Hajime Lanning wrote:
> You could run a script once a day, that parses out the "days" field
> (when it is there,) and emails when divisible by 365.
>
> That would be the easiest.
But what about leap years?
Some other people suggested triggering it every 60 * 60 * 24 * 365
seconds. Changing that to use the average length of a Gregorian
calendar year (365 97/400 days) might be the easiest way to go. You'll
need to be careful that the division by 400 doesn't truncate the
fractional day to zero, but that can be worked around by doing the
arithmetic yourself on a calculator and just putting the total number of
seconds per average year in your code.
That may be better than fetching the year and checking for divisibility
by 4 because you avoid the y2100 (etc.) problem.
It'll trigger about six hours later by the clock/calendar every year
(with the correct date being reset every leap year), but it'll be at
pretty much the same point in Earth's orbit every time.
To be even better, you could use the actual number of seconds it takes
Earth to make one circuit of the sun. Get that from the Naval
Observatory or some such. Of course you then have to decide whether to
worry about precession of the equinoxes. But that's probably beyond the
scope of this project.
--
Tom Digby
http://www.well.com/~bubbles/
http://www.plergb.com/
More information about the svlug
mailing list