Bug 15260: (follow-up) Fix bug in subtraction
authorAndrew Isherwood <andrew.isherwood@ptfs-europe.com>
Wed, 1 May 2019 11:12:14 +0000 (12:12 +0100)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 31 Oct 2019 11:53:06 +0000 (11:53 +0000)
prev_open_days can receive either positive or negative numbers and
then does the right thing with them. However, we weren't also doing this
with the number it receives back from get_push_amt

Signed-off-by: Liz Rea <wizzyrea@gmail.com>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Koha/Calendar.pm

index 25299c1..775c775 100644 (file)
@@ -310,6 +310,8 @@ sub prev_open_days {
 
     while ($self->is_holiday($base_date)) {
         my $sub_next = $self->get_push_amt($base_date);
+        # Ensure we're subtracting when we need to be
+        $sub_next = $sub_next > 0 ? 0 - $sub_next : $sub_next;
         $base_date->add(days => $sub_next);
     }