[thelist] Logic help

Erik Mattheis gozz at gozz.com
Thu May 2 20:24:00 CDT 2002

>I'm working in PHP...but that's kind of beside the point.
>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.

You have like 7 months to figure it out on your own, but I feel like
trying to help:

Use however you find out what the day of year is, as in 1-365 or
0-362, however PHP thinks about it ... here it is in my own super
secret scripting language:

winter_starts = DayOfYear(DateObject('december 21, 2034'))
spring_starts = DayOfYear(DateObject('april 21, 2034'))
today = DayOfYear(DateObject(whenIsNow())

if (winter_starts <= today < spring_starts) {
   // it's winter
else {
   // it's not winter


- Erik Mattheis

(612) 377 2272

Through June 15
9am - 3pm M-F:
(952) 838 7698


More information about the thelist mailing list