summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-07 21:19:32 +0000
committertetragon <tetragon@4979c152-3d1c-0410-bac9-87ea11338e46>2007-05-07 21:19:32 +0000
commit5f08e16d4ccc930ad22f53800cd09a4d0e0a7867 (patch)
tree6922f5eeac49f73642260066c73b6cbffc77dce6
parent7b0c5980f358925ddb4f9f9eef86774249e7de5b (diff)
Scope fixing and a bugfix for $form->add_date
git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1160 4979c152-3d1c-0410-bac9-87ea11338e46
-rw-r--r--LedgerSMB/Form.pm5
-rw-r--r--t/03-date-handling.t2
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');