summaryrefslogtreecommitdiff
path: root/C4/Letters.pm
authorJonathan Druart <jonathan.druart@biblibre.com>2014-09-30 09:36:39 (GMT)
committer Tomas Cohen Arazi <tomascohen@gmail.com>2014-11-01 12:19:07 (GMT)
commitc5a6a4f18a2c4eb2cb47bc302e539d3b05fcf9b1 (patch) (side-by-side diff)
treeef5729c226c59ed1c8e8cce59c1c20450151883f /C4/Letters.pm
parenta4a2159aad6d7276fc7efb9abb24830f7f473102 (diff)
Bug 13011: 0000-00-00 should not be considered as a valid date
When parsing the letter content, the 0000-00-00 should not be replaced, it's not a valid date. Test plan: prove t/db_dependent/Suggestions.t should not return the following error: 0000-00-00 seems to be a date but an error occurs on generating it (The 'month' parameter ("0") to DateTime::new did not pass the 'an integer between 1 and 12' callback Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz> Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de> Adds another check for 0000-00-00. Passes tests and QA script. Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
Diffstat (limited to 'C4/Letters.pm') (more/less context) (ignore whitespace changes)
-rw-r--r--C4/Letters.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/C4/Letters.pm b/C4/Letters.pm
index 4acc931..519c0f6 100644
--- a/C4/Letters.pm
+++ b/C4/Letters.pm
@@ -652,7 +652,10 @@ sub _parseletter {
$val = GetAuthorisedValueByCode ('ROADTYPE', $val, 0) if $table=~/^borrowers$/ && $field=~/^streettype$/;
my $replacedby = defined ($val) ? $val : '';
- if ( $replacedby and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| ) {
+ if ( $replacedby
+ and not $replacedby =~ m|0000-00-00|
+ and $replacedby =~ m|^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}:\d{2})?$| )
+ {
# If the value is XXXX-YY-ZZ[ AA:BB:CC] we assume it is a date
my $dateonly = defined $1 ? 0 : 1; #$1 refers to the capture group wrapped in parentheses. In this case, that's the hours, minutes, seconds.
eval {