Dear experts,
I have a piece of codes that has work for me for quite a long time and it suddenly stopped working.
And here is my machine time:
Could someone tell me what the problem is and how to fix it?
Many thanks!!
I have a piece of codes that has work for me for quite a long time and it suddenly stopped working.
Code:
#! /usr/bin/perl
use strict;
use warnings;
use POSIX qw(strftime);
use Date::Calc qw (Add_Delta_Days);
my $offset = -1;
my $thisDay = &getThisDayDate($offset);
print "\$thisDay = $thisDay\n"; # should be yesterday's date
exit;
sub getDate {
my @today = localtime;
return @today;
}
sub getThisDayDate {
my ($offset) = @_;
$offset = 0 if(!$offset);
my @today = &getDate();
my $todayStr = join ', ', @today;
print "\$offset = $offset, \@today = $todayStr\n";
[b][COLOR=red]@today[5,4,3] = Add_Delta_Days(@today[5,4,3], $offset); # Line 24!![/color][/b]
my $thisday = strftime "%Y%m%d", @today;
return $thisday;
}
% ./testDateCalc.pl
$offset = 1, @today = 38, 9, 14, 31, 9, 111, 1, 303, 0
[b]Date::Calc::PP::Add_Delta_Days(): Date::Calc::Add_Delta_Days(): not a valid date at ./testDateCalc.pl line 24 [/b]
And here is my machine time:
Code:
% date
Mon Oct 31 14:09:40 UTC 2011
Could someone tell me what the problem is and how to fix it?
Many thanks!!