From bd11c0c8baaee0e743adc55d31dad06f5f449a21 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Thu, 23 Mar 2017 16:33:57 -0400 Subject: [PATCH] LP#1635737 Date intervals live test Signed-off-by: Bill Erickson --- .../live_t/22-lp1635737-date-duration-math.t | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Open-ILS/src/perlmods/live_t/22-lp1635737-date-duration-math.t diff --git a/Open-ILS/src/perlmods/live_t/22-lp1635737-date-duration-math.t b/Open-ILS/src/perlmods/live_t/22-lp1635737-date-duration-math.t new file mode 100644 index 0000000000..87506cfe96 --- /dev/null +++ b/Open-ILS/src/perlmods/live_t/22-lp1635737-date-duration-math.t @@ -0,0 +1,42 @@ +#!perl + +use Test::More tests => 2; + +diag("Test date duration addition across time change boundaries"); + +use strict; use warnings; + +use OpenILS::Utils::TestUtils; +use OpenILS::Application::AppUtils; +my $script = OpenILS::Utils::TestUtils->new(); + +$script->bootstrap; +my $U = 'OpenILS::Application::AppUtils'; + +# To ensure we're always comparing Apples to Apples, apply the +# same time zone to all dates tested. +my $tz = 'America/Los_Angeles'; + +# Testing 2016-10-10 00:05:00-0700 + 28 days which +# crosses the November 6 2016 time change boundary. +my $test_date = DateTime->new( + year => 2016, + month => 10, + day => 10, + hour => 0, + minute => 5, + time_zone => $tz +); + +my $new_date = $U->date_plus_interval($test_date, '28 days'); +$new_date->set_time_zone($tz); + +is($new_date->strftime('%FT%T%z'), '2016-11-07T00:05:00-0800', + 'Date plus interval includes extra hour from time change'); + +$test_date = DateTime->now(time_zone => $tz); +$new_date = $U->date_plus_interval($test_date, '10 years'); +$new_date->set_time_zone($tz); + +is($new_date->day, $test_date->day, 'Days match across multiple leap years'); + -- 2.11.0