[OpenSRF-GIT] OpenSRF branch rel_2_4 updated. osrf_rel_2_4_1-3-gb484a31

Evergreen Git git at git.evergreen-ils.org
Thu Feb 4 11:35:28 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, rel_2_4 has been updated
       via  b484a31c413a017c6b7409f3f101636f68c08c9a (commit)
       via  61e6732111db9389038bce1b1f6f655b619fdc86 (commit)
      from  8f6923efc2c632548f860a9aaabd92fdf2545437 (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 b484a31c413a017c6b7409f3f101636f68c08c9a
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 61e6732111db9389038bce1b1f6f655b619fdc86
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