From: sekhar kavuru [mailto:[EMAIL PROTECTED]
>
> I need help with a generic function that can give the value of next
> day Example : 12/31/2005 => 01/01/2006
>
> I want to accomplish this without Cal::Date
Are you saying you want to do it without using a date module, or
without using that particular date module?
Let me give it a quick shot (off-the-cuff and completely untested):
------------------------------------------------
sub nextDay
{
$date = shift;
@month_days = ( undef, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 );
($m, $d, $y) = $date =~ m#(\d+)/(\d+)/(\d+)#;
# Check for leap year
if ($y % 4 == 0)
{
$month_days[2]++;
}
$d++;
if ($d > $month_days[$m])
{
$d = 1;
$m++;
}
if ($m > 12)
{
$m = 1;
$y++;
}
return "$m/$d/$y";
}
------------------------------------------------
Caveats:
- This assumes the incoming date is valid
- There needs to be a few more checks for the leap year, but I'm too
lazy to look it up right now.
Bowie
_______________________________________________
ActivePerl mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs