From: Galen Charlton Date: Fri, 20 Dec 2019 17:55:16 +0000 (-0500) Subject: LP#1857156: handle HHH:MM:SS durations in loans X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=75c6b77aabfd5fc0c1db36aa3b7b4f0d7357dd4a;p=working%2FEvergreen.git LP#1857156: handle HHH:MM:SS durations in loans This patch fixes a problem where loan durations of the form HHH:MM:SS, where the hours component is longer than 2 digits, could cause checkouts to fail. This sort of duration has been observed in cases where a library wanted a long-term reserves loan that doesn't have the due time bumped up to midnight. To test ------- [1] Set up a circulation policy that has a loan duration of 167:59:59. [2] Attempt a checkout that uses that policy. Note that the checkout will fail. [3] Apply the patch and repeat step 2. This time, the checkout should succeed. Signed-off-by: Galen Charlton Signed-off-by: Dan Scott Signed-off-by: Michele Morgan --- diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Utils/DateTime.pm b/Open-ILS/src/perlmods/lib/OpenILS/Utils/DateTime.pm index 1da0951f40..bef04c5afb 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Utils/DateTime.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Utils/DateTime.pm @@ -109,7 +109,7 @@ sub interval_to_seconds { my $interval = ($class eq __PACKAGE__) ? shift : $class; my $context = shift; - $interval =~ s/(\d{2}):(\d{2}):(\d{2})/ $1 h $2 min $3 s /go; + $interval =~ s/(\d{2,}):(\d{2}):(\d{2})/ $1 h $2 min $3 s /go; $interval =~ s/and/,/g; $interval =~ s/,/ /g; diff --git a/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t b/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t index 81cf90ffae..2aa2afb5d3 100644 --- a/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t +++ b/Open-ILS/src/perlmods/t/14-OpenILS-Utils.t @@ -14,7 +14,7 @@ # truckload to verify that everything would continue to work if # we turn it on across the board. -use Test::More tests => 47; +use Test::More tests => 48; use Test::Warn; use DateTime::TimeZone; use DateTime::Format::ISO8601; @@ -140,6 +140,7 @@ is (OpenILS::Utils::DateTime::interval_to_seconds('1 month', is (OpenILS::Utils::DateTime::interval_to_seconds('1 year'), 31536000); is (OpenILS::Utils::DateTime::interval_to_seconds('1 year 1 second'), 31536001); +is (OpenILS::Utils::DateTime::interval_to_seconds('167:59:59'), 604799, 'correctly convert HHH:MM:SS intervals where hours longer than 2 digits'); sub get_offset { # get current timezone offset for future use