DateTime->season?

[email protected] (David E . Wheeler)
Newsgroups perl.datetime
Message-ID <[email protected]>
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?

Best,

David
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.