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

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

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

2003-09-20 Thread Jerry Wilcox
At 11:40 PM -0500 9/19/03, Dave Rolsky wrote: DateTime-day_count_in_year( year = 1999, day = 4 ); I think this is what was originally meant. What would people need this info for? 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

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

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

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

2003-09-20 Thread Bruce Van Allen
On 9/20/03 Joshua Hoblitt 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,

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

2003-09-19 Thread Ron Hill
Hi Dave Josh, Dave Rolsky [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On Wed, 17 Sep 2003, Hill, Ronald wrote: [snipped] Josh is confused because you're passing arguments to the day_of_week method. These arguments are completely ignored by DateTime.pm! -dave Ok, I see I

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

2003-09-19 Thread RIck Measham
Syamala Tadigadapa wrote: Here is a simple solution ... I'd hate to see your complex solution ... Rick

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

2003-09-19 Thread Dave Rolsky
On Wed, 17 Sep 2003, Ron Hill wrote: Ok, I see I can just do my $dow = $dt2-day_of_week( year = $dt-year, ); The day_of_week() method DOES NOT TAKE ARGUMENTS! I don't know what you think the code above does, but I can tell you that all it does is return the day of the

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

2003-09-19 Thread Joshua Hoblitt
The day_of_week() method DOES NOT TAKE ARGUMENTS! I wonder if it's worth the overhead of checking for extraneous parameters on all methods? -J --

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

2003-09-19 Thread Dave Rolsky
On Fri, 19 Sep 2003, Joshua Hoblitt wrote: The day_of_week() method DOES NOT TAKE ARGUMENTS! I wonder if it's worth the overhead of checking for extraneous parameters on all methods? I'd rather try to keep accessors as quick as possible. -dave /*=== House Absolute

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

2003-09-17 Thread Joshua Hoblitt
Hi Ron, I'm a bit confused by your parameters to day_of_week(). This is the actual implementation from DateTime.pm sub day_of_week { $_[0]-{local_c}{day_of_week} } -J -- script= use strict; use warnings; use DateTime; my $dt =

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

2003-09-17 Thread Hill, Ronald
Hi Josh, Hi Ron, I'm a bit confused by your parameters to day_of_week(). This is the actual implementation from DateTime.pm sub day_of_week { $_[0]-{local_c}{day_of_week} } -J I compute the number of days in the current year I figure out the day of week for january the

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

2003-09-17 Thread Dave Rolsky
On Wed, 17 Sep 2003, Hill, Ronald wrote: I checked the docs for datetime and used them F:\scriptsperldoc DateTime|grep day_of_week File STDIN: $dow= $dt-day_of_week; # 1-7 (Monday is 1) - also dow, wday _0. So for example, this class provides both day_of_week() and

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

2003-09-17 Thread Syamala Tadigadapa
Here is a simple solution (unless you are bent on doing it in a longer way using a date time class.) sub jan1{ my $y = shift; my $m = 1; $d = 1; $m = 11; $y--; my $c = int($y / 100); $yy = $y %100; my $z = ( 1 + $yy + int($yy/4) + int($c/4) - 2*$c) % 7; $z += 7 if $z 0; return $z; #