Bug 11120: the date input should be in a iso format (YYYY-MM-DD)
authorJonathan Druart <jonathan.druart@biblibre.com>
Tue, 6 Jan 2015 13:27:17 +0000 (14:27 +0100)
committerTomas Cohen Arazi <tomascohen@gmail.com>
Mon, 30 Mar 2015 16:43:59 +0000 (13:43 -0300)
Note that it cans also accept a date in the same format defined in the
dateformat system preference.

Signed-off-by: Brendan Gallagher <brendan@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
misc/cronjobs/overdue_notices.pl

index c9c2d69..e46b3f0 100755 (executable)
@@ -360,13 +360,15 @@ if (@branchcodes) {
 my $date_to_run;
 my $date;
 if ( $date_input ){
-    $date = $dbh->quote($date);
     eval {
-        $date_to_run = dt_from_string( $date_input );
+        $date_to_run = dt_from_string( $date_input, 'iso' );
     };
     die "$date_input is not a valid date, aborting! Use a date in format YYYY-MM-DD."
         if $@ or not $date_to_run;
 
+    # It's certainly useless to escape $date_input
+    # dt_from_string should not return something if $date_input is not correctly set.
+    $date = $dbh->quote( $date_input );
 }
 else {
     $date="NOW()";