summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xLedgerSMB/Form.pm7
-rw-r--r--t/03-date-handling.t2
2 files changed, 7 insertions, 2 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm
index 47b25a6e..423da27d 100755
--- a/LedgerSMB/Form.pm
+++ b/LedgerSMB/Form.pm
@@ -1383,6 +1383,9 @@ sub add_date {
my $diff = 0;
my $spc = $myconfig->{dateformat};
+ my $yy;
+ my $mm;
+ my $dd;
$spc =~ s/\w//g;
$spc = substr( $spc, 0, 1 );
@@ -1406,7 +1409,7 @@ sub add_date {
else {
# ISO
- ( $yy, $mm, $dd ) =~ /(....)(..)(..)/;
+ ( $yy, $mm, $dd ) = ($date =~ /(....)(..)(..)/);
}
if ( $unit eq 'days' ) {
@@ -1423,7 +1426,7 @@ sub add_date {
my $whole = int( $diff / 12 );
$yy += $whole;
- $mm = ( $diff % 12 );
+ $mm = ( $diff % 12 );
$mm = '12' if $mm == 0;
$yy-- if $mm == 12;
$diff = 0;
diff --git a/t/03-date-handling.t b/t/03-date-handling.t
index 019115a0..be252e9d 100644
--- a/t/03-date-handling.t
+++ b/t/03-date-handling.t
@@ -328,5 +328,7 @@ foreach my $format (0 .. $#formats) {
cmp_ok($form->add_date(\%myconfig, $start, 2, 'years'), 'eq',
$results, "add_date, $fmt, 2 years, 2000-01-29");
}
+cmp_ok($form->add_date(\%myconfig, '20000129', 2, 'years'), 'eq',
+ '20020129', 'add_date, yyyymmdd, 2 years, 20000129');
ok(!defined $form->add_date(\%myconfig),
'add_date, undef if no date');