Re: DateTime->season?

[email protected] (Zefram)
Newsgroups perl.datetime
Message-ID <[email protected]>
David E. Wheeler wrote:
>        return $date lt '03-21' ? 'winter'
>             : $date lt '06-21' ? 'spring'

Northern hemisphere chauvinism.

Aside from the hemisphere issue, the code is also wrong for tropical
latitudes, where the four-season system doesn't apply.  If you're trying
to answer a user's question of "what season is it?" then you need a lot
more flexibility.  Even within the four-season system, people draw the
boundaries in different places.  That's inevitable when trying to impose
sharp distinctions on a system that actually has a fuzzy continuum.

>Since seasons can sometimes change on the 22nd instead of the 21st,  
>this isn't quite right.

Sounds like you're looking for the equinox and solstice dates.  I don't
see any CPAN module providing this, on search.cpan.org.  I guess
that makes it your job to write one.  Ideally you'd want to work from
Astronomical Algorithms <http://www.willbell.com/math/mc1.htm>.  Google
for "equinox calculation" to find several lower-precision algorithms in
various programming languages.

-zefram
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.