Your question is a little confusing, you ask how to get the first day of the month and then cut-and-paste Date::Calc instructions on figuring out the first Monday of a week. If you want the first day of the month, simply refer to is with the number '1'. No Data::Calc required, that's always the first day.
Now how to figure the first Monday of a given month? It takes a little logic, what the Date::Calc instructions are explaining is how to get the Monday of any given week, now if you want the first Monday of the month you should check Monday_of_Week() of the first day of a month. If the result is in the same month, you got lucky and Monday falls on the first, if not, increment the week of the year by 1 and you will have your answer.
#$year, $month, and $day are set to the first of any given month my ($week,undef)=Week_of_Year($year,$month,$day); my (undef, $tmpmonth, $firstmonday)=Monday_of_Week($week,$year); if ($tmpmonth != $month) { (undef, undef, $firstmonday)=Monday_of_Week(++$week,$year); } #$firstmonday now contains the date of the first Monday of a given mon +th. #Put this in a loop or a sub or whatever and you can call it with argu +ments. print "First monday of $month/$year is $firstmonday\n";
In reply to Re: getting the First day of the month
by pzbagel
in thread getting the First day of the month
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |