in reply to Getting Weekly Dates
That will give you the time for (around) noon on the first day of a given month that is NOT a weekend, the day of the month, and a number representing the day of the week (1 = Monday, 5 = Friday). That's probably the hardest part.use Time::Local; sub getFirstNonWeekend { my ($month, $year) = @_; # (7,2001) for July 2001 # noon on the 1st of the month my $first = timelocal(0,0,12, 1, $month-1, $year-1900); my $shift = ((localtime $first)[6] + 1) % 7; if ($shift < 2) { $first += 86400 * (2 - $shift) if $shift < 2; return ($first, 3 - $shift, 1); } return ($first, 1, $shift - 1); }
What's left is the partitioning of this month and the next. Since you know the day of the month and the day of the week, this shouldn't be too hard. I wouldn't mind showing you the code for it though, if you ask.
japhy --
Perl and Regex Hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Getting Weekly Dates
by petral (Curate) on Mar 09, 2001 at 06:05 UTC | |
by japhy (Canon) on Mar 09, 2001 at 09:36 UTC | |
by petral (Curate) on Mar 09, 2001 at 09:48 UTC | |
|
Re: Re: Getting Weekly Dates
by japhy (Canon) on Mar 09, 2001 at 02:02 UTC |