Charlie Farinella wrote:
> I have an error popping up in an application that runs monthly reports
> and everymonth seems to leave off the last day's entries.
>
> The subroutine that determines the last day of the month is here:
>
> sub GetLastDayOfMonth {
> my( $sec, $min, $hours, $mday, $mon, $year ) = localtime( $_[0] );
>
> return timelocal( 59, 59, 23, $monthDays[$mon], $mon, $year );
> }
>
> This is over my head and I'm hoping someone might look at this and point
> out any errors they might see. Either an explanation of what's going on
> here, or a pointer to appropriate documentation would also be
> appreciated.
>
> thanks.
>
try the Date::Manip module out:
#!/usr/bin/perl -w
use strict;
use Date::Manip;
print Date_DaysInMonth(12,2002),"\n"; #-- number of days in Dec 2002
__END__
or you can also try this:
#!/usr/bin/perl -w
use strict;
use Time::Local
my ($month,$year) = (localtime)[4..5];
if($month == 11){
$month = 0;
$year += 1;
}else{
$month++;
}
my $seconds = timelocal(0,0,0,1,$month,$year);
$seconds -= 3600;
my $day = (localtime($seconds))[3];
print "$day\n";
__END__
if you don't want to use another module.
david
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]