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); }