[thelist] Logic help
deke
web at master.gen.in.us
Fri May 3 10:22:01 CDT 2002
On 2 May 2002 at 14:53, John Corry posted a message which said:
> I'm having a hard time coming up with the logic for determining whether
> a date is in winter or not.
> I at first thought it was as easy as making a timestamp out of winter's
> begin date, making a timestamp of winters end date and seeing if my time
> falls between the 2.
> That doesn't work because if it's february, winter began last year. If
> december, winter ends next year.
First, get a timestamp of the time in question, and extract the year.
Let's call those variables $Qtime and $Qyear.
First, you need to know when the Vernal Equinox (start of spring) and
the Winter Solstice (start of winter) is for $Qyear. You can find the
formulae here:
http://serendipity.magnet.ch/hermetic/cal_stud/cassidy/calquest.htm
Let's call the timestamps of those two times $VE and $WS.
$winter = 0;
if ($Qtime < $VE) {$winter = 1;}
if ($Qtime > $WS) {$winter = 1;}
if ($winter)
{
do_winter_stuff();
}
{
do_nonwinter_stuff();
}
deke
--
Do gravediggers qualify for "cost of living" raises?
More information about the thelist
mailing list