[OpenSRF-GIT] OpenSRF branch master updated. 69cbe8000a5123aab33fcb2441c1e136506964a0
Evergreen Git
git at git.evergreen-ils.org
Thu Feb 4 11:34:59 EST 2016
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "OpenSRF".
The branch, master has been updated
via 69cbe8000a5123aab33fcb2441c1e136506964a0 (commit)
via 7a714ae480f238211b37fcdb248aecea93ece234 (commit)
from 55807240854d0d532a5f70f1f483ed8086eb9d95 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 69cbe8000a5123aab33fcb2441c1e136506964a0
Author: Jason Etheridge <jason at esilibrary.com>
Date: Tue Jul 14 14:54:27 2015 -0400
LP#1474507: fix interval_to_seconds for weeks and seconds
This patch fixes an issue where OpenSRF::Utils::interval_to_seconds()
was not recognizing intervals expressed as seconds or weeks.
Signed-off-by: Jason Etheridge <jason at esilibrary.com>
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
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);
}
commit 7a714ae480f238211b37fcdb248aecea93ece234
Author: Jason Etheridge <jason at esilibrary.com>
Date: Tue Jul 14 15:10:15 2015 -0400
LP#1474507: tests for interval_to_seconds
Signed-off-by: Galen Charlton <gmc at esilibrary.com>
diff --git a/src/perl/t/09-Utils-interval_to_seconds.t b/src/perl/t/09-Utils-interval_to_seconds.t
new file mode 100644
index 0000000..4328fe2
--- /dev/null
+++ b/src/perl/t/09-Utils-interval_to_seconds.t
@@ -0,0 +1,16 @@
+#!perl -T
+
+use Test::More tests => 9;
+
+BEGIN {
+ use_ok( 'OpenSRF::Utils' );
+}
+
+is (OpenSRF::Utils::interval_to_seconds('1 second'), 1);
+is (OpenSRF::Utils::interval_to_seconds('1 minute'), 60);
+is (OpenSRF::Utils::interval_to_seconds('1 hour'), 3600);
+is (OpenSRF::Utils::interval_to_seconds('1 day'), 86400);
+is (OpenSRF::Utils::interval_to_seconds('1 week'), 604800);
+is (OpenSRF::Utils::interval_to_seconds('1 month'), 2628000);
+is (OpenSRF::Utils::interval_to_seconds('1 year'), 31536000);
+is (OpenSRF::Utils::interval_to_seconds('1 year 1 second'), 31536001);
-----------------------------------------------------------------------
Summary of changes:
src/perl/lib/OpenSRF/Utils.pm | 4 ++--
src/perl/t/09-Utils-interval_to_seconds.t | 16 ++++++++++++++++
2 files changed, 18 insertions(+), 2 deletions(-)
create mode 100644 src/perl/t/09-Utils-interval_to_seconds.t
hooks/post-receive
--
OpenSRF
More information about the opensrf-commits
mailing list