From d531f1d87c1336645100cefef0eb3ec725918a5e Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 4 Jun 2009 16:33:43 +0000 Subject: [PATCH] teach interval_to_seconds about negative intervals git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1714 9efc2488-bf62-4759-914b-345cdb29e865 --- src/perl/lib/OpenSRF/Utils.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/perl/lib/OpenSRF/Utils.pm b/src/perl/lib/OpenSRF/Utils.pm index 46816cb..b6e24d5 100644 --- a/src/perl/lib/OpenSRF/Utils.pm +++ b/src/perl/lib/OpenSRF/Utils.pm @@ -259,8 +259,9 @@ sub interval_to_seconds { $interval =~ s/,/ /g; my $amount = 0; - while ($interval =~ /\s*\+?\s*(\d+)\s*(\w+)\s*/g) { - my ($count, $type) = ($1, $2); + while ($interval =~ /\s*([\+-]?)\s*(\d+)\s*(\w+)\s*/g) { + my ($sign, $count, $type) = ($1, $2, $3); + $count = "$sign$count" if ($sign); $amount += $count if ($type eq 's'); $amount += 60 * $count if ($type =~ /^m(?!o)/oi); $amount += 60 * 60 * $count if ($type =~ /^h/); -- 2.43.2