From: miker Date: Thu, 4 Jun 2009 16:33:43 +0000 (+0000) Subject: teach interval_to_seconds about negative intervals X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=d531f1d87c1336645100cefef0eb3ec725918a5e;p=opensrf%2Fbjwebb.git teach interval_to_seconds about negative intervals git-svn-id: svn://svn.open-ils.org/OpenSRF/trunk@1714 9efc2488-bf62-4759-914b-345cdb29e865 --- 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/);