Jerry Wilcox <[EMAIL PROTECTED]> wrote:
> I'm not sure about the count in a year, but
I frequently need to 
> determine how many of a given day of the
week fall in a given month 
> of the year, or, more precisely, given that
today is Saturday, 
> September 20, I need to figure out whether
today is the first, 
> second, third, fourth, or fifth Saturday of
the month. I've worked 
> out code using existing methods to tell me
what I need to know, and 
> I'm not sure that an entirely new method is
warranted here.

Jerry: There's two functionality in the above.

First: How many of a particular DOW are in a
period. This is just a matter of dividing the
total days by seven then adding one if
needed. If a function were added for this,
then I imagine its more a part of
DateTime::Span rather than DateTime itself.

Secondly you ask about getting the weekday of
the month. There's already a function in
DateTime for this:
$dt->weekday_of_month();

Test it with this:
perl -MDateTime -e 'print DateTime->new( year
=> 2003, month => 9, day =>
20)->weekday_of_month()'

Reply via email to