From 316f58375c40087bfae32234c4dd3817260831e5 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Mon, 31 Jul 2017 12:53:59 -0400 Subject: [PATCH] LP#1635737: Unit tests for DST and date math Signed-off-by: Mike Rylander --- src/perl/t/09-Utils-interval_to_seconds.t | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/perl/t/09-Utils-interval_to_seconds.t b/src/perl/t/09-Utils-interval_to_seconds.t index 4328fe2..2f82ea2 100644 --- a/src/perl/t/09-Utils-interval_to_seconds.t +++ b/src/perl/t/09-Utils-interval_to_seconds.t @@ -1,6 +1,8 @@ -#!perl -T +#!perl -use Test::More tests => 9; + +use DateTime::Format::ISO8601; +use Test::More tests => 10; BEGIN { use_ok( 'OpenSRF::Utils' ); @@ -12,5 +14,14 @@ 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); + +# With context, no DST change +is (OpenSRF::Utils::interval_to_seconds('1 month', + DateTime::Format::ISO8601->new->parse_datetime('2017-02-04T23:59:59-04')), 2419200); + +# With context, with DST change +is (OpenSRF::Utils::interval_to_seconds('1 month', + DateTime::Format::ISO8601->new->parse_datetime('2017-02-14T23:59:59-04')), 2415600); + is (OpenSRF::Utils::interval_to_seconds('1 year'), 31536000); is (OpenSRF::Utils::interval_to_seconds('1 year 1 second'), 31536001); -- 2.43.2