Re: DateTime->season?
[email protected] (Rick Measham)
| Newsgroups | perl.datetime |
|---|---|
| Message-ID | <[email protected]> |
David E. Wheeler wrote:
> Hey All,
>
> Someone on the Bricolage list needed a season method, so I whipped up
> this ugly one:
>
> sub season {
> my $date = shift->strftime('%m-%d');
> return $date lt '03-21' ? 'winter'
> : $date lt '06-21' ? 'spring'
> : $date lt '09-21' ? 'summer'
> : $date lt '12-21' ? 'autumn'
> : 'winter';
> }
>
> Since seasons can sometimes change on the 22nd instead of the 21st, this
> isn't quite right. Anyone else done something like this but more accurate?
Where in the world do you want to calculate them?
http://en.wikipedia.org/wiki/Season#Reckoning seems to have the
information you need.
Cheers!
Rick Measham
smime.p7s
(application/x-pkcs7-signature, 3.2 KB) - not displayed