Re: RE: figuring out the number of sundays in a given year

2003-09-21 Thread Joshua Hoblitt
> 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.

I already said this. :)

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

Yes - but if we add the above functionality to DT::Span I think we should also have 
weekday_of_span() or a similar method for finding your location relativity to the 
start of the span (and not just the current month).

-J

--


Re: RE: figuring out the number of sundays in a given year

2003-09-21 Thread rickmeasham
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()'