From: Charlie Farinella
<[EMAIL PROTECTED]>
> 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 );
> }
There is not always the same number of days in a month. Think about
February!
If I did not want to use a module I'd use this:
use Time::Local;
sub GetLastDayOfMonth {
my( $sec, $min, $hours, $mday, $mon, $year ) = localtime( defined
$_[0] ? $_[0] : time());
if ($mon == 11) {
$mon=0;
$year++;
} else {
$mon++;
}
return timelocal( 59, 59, 23, 1, $mon, $year ) - 24*60*60;
}
That is "the first of the next month minus one day".
Jenda
=========== [EMAIL PROTECTED] == http://Jenda.Krynicky.cz ==========
There is a reason for living. There must be. I've seen it somewhere.
It's just that in the mess on my table ... and in my brain
I can't find it.
--- me
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]