[Opensrf-commits] r1714 - trunk/src/perl/lib/OpenSRF (miker)

svn at svn.open-ils.org svn at svn.open-ils.org
Thu Jun 4 12:33:46 EDT 2009


Author: miker
Date: 2009-06-04 12:33:43 -0400 (Thu, 04 Jun 2009)
New Revision: 1714

Modified:
   trunk/src/perl/lib/OpenSRF/Utils.pm
Log:
teach interval_to_seconds about negative intervals

Modified: trunk/src/perl/lib/OpenSRF/Utils.pm
===================================================================
--- trunk/src/perl/lib/OpenSRF/Utils.pm	2009-06-03 15:59:34 UTC (rev 1713)
+++ trunk/src/perl/lib/OpenSRF/Utils.pm	2009-06-04 16:33:43 UTC (rev 1714)
@@ -259,8 +259,9 @@
         $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/);



More information about the opensrf-commits mailing list