There's more than one way to do things | |
PerlMonks |
Counting number of a particular day of the month.by ninja-joe (Monk) |
on May 31, 2002 at 20:16 UTC ( [id://170821]=perlquestion: print w/replies, xml ) | Need Help?? |
ninja-joe has asked for the wisdom of the Perl Monks concerning the following question:
I'm writing a billing system for a musical instruction facility. They have students that come in on a weekly basis on a particular day. Let's say for instance this day is Wenesday. Some months will either have four or five of Wenesdays depending on what type of day the month begins on. Here's my method (assuming the day of the week would be Wenesday): Given: $n = # of days so far 1. Find the date on which the first Wenesday of that month would occur ($n=1); 2. Add 7 to that date, if the date is within the current month you're trying to calculate then increment $n ($n++); 3. If the date is beyond the interested month, exit the loop. That's a pretty brute forced method. Anybody have any better ideas? Is there a module that any knows of that will count it for me? It may be too simple of a task to really need a better method too.
Back to
Seekers of Perl Wisdom
|
|