diff options
-rw-r--r-- | LedgerSMB/Form.pm | 5 | ||||
-rw-r--r-- | t/03-date-handling.t | 2 |
2 files changed, 6 insertions, 1 deletions
diff --git a/LedgerSMB/Form.pm b/LedgerSMB/Form.pm index 5771e124..b8a23b01 100644 --- a/LedgerSMB/Form.pm +++ b/LedgerSMB/Form.pm @@ -1376,6 +1376,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 ); @@ -1399,7 +1402,7 @@ sub add_date { else { # ISO - ( $yy, $mm, $dd ) =~ /(....)(..)(..)/; + ( $yy, $mm, $dd ) = ($date =~ /(....)(..)(..)/); } if ( $unit eq 'days' ) { 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'); |