From a6e2082fa6246f4af517e7e35d0bbec621deffe0 Mon Sep 17 00:00:00 2001 From: Jason Etheridge Date: Tue, 14 Jul 2015 14:54:27 -0400 Subject: [PATCH] lp#1474507 fix interval_to_seconds for weeks and seconds Signed-off-by: Jason Etheridge --- src/perl/lib/OpenSRF/Utils.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/perl/lib/OpenSRF/Utils.pm b/src/perl/lib/OpenSRF/Utils.pm index 61596d0..bb6858a 100644 --- a/src/perl/lib/OpenSRF/Utils.pm +++ b/src/perl/lib/OpenSRF/Utils.pm @@ -261,11 +261,11 @@ sub interval_to_seconds { 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 += $count if ($type =~ /^s/); $amount += 60 * $count if ($type =~ /^m(?!o)/oi); $amount += 60 * 60 * $count if ($type =~ /^h/); $amount += 60 * 60 * 24 * $count if ($type =~ /^d/oi); - $amount += 60 * 60 * 24 * 7 * $count if (defined $2 && $2 =~ /^w/oi); + $amount += 60 * 60 * 24 * 7 * $count if ($type =~ /^w/oi); $amount += ((60 * 60 * 24 * 365)/12) * $count if ($type =~ /^mo/io); $amount += 60 * 60 * 24 * 365 * $count if ($type =~ /^y/oi); } -- 2.11.0