Bugzilla – Attachment 194929 Details for
Bug 39748
Daylight savings breaks circulation (when DST change eliminates 00:00 to 00:59)
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 39748: Unit test for CalcDateDue
Bug-39748-Unit-test-for-CalcDateDue.patch (text/plain), 2.70 KB, created by
Lucas Gass (lukeg)
on 2026-03-06 22:25:31 UTC
(
hide
)
Description:
Bug 39748: Unit test for CalcDateDue
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2026-03-06 22:25:31 UTC
Size:
2.70 KB
patch
obsolete
>From f259c950daca3a97912438620acb93938a36e831 Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Fri, 6 Mar 2026 22:12:09 +0000 >Subject: [PATCH] Bug 39748: Unit test for CalcDateDue > >1. prove t/db_dependent/Circulation/CalcDateDue.t >2. it fails >--- > t/db_dependent/Circulation/CalcDateDue.t | 50 +++++++++++++++++++++++- > 1 file changed, 49 insertions(+), 1 deletion(-) > >diff --git a/t/db_dependent/Circulation/CalcDateDue.t b/t/db_dependent/Circulation/CalcDateDue.t >index 485b15b8181..51d63ddceed 100755 >--- a/t/db_dependent/Circulation/CalcDateDue.t >+++ b/t/db_dependent/Circulation/CalcDateDue.t >@@ -3,7 +3,7 @@ > use Modern::Perl; > > use Test::NoWarnings; >-use Test::More tests => 24; >+use Test::More tests => 25; > use Test::MockModule; > use DBI; > use DateTime; >@@ -494,3 +494,51 @@ is( > > $cache->clear_from_cache($key); > $schema->storage->txn_rollback; >+ >+subtest 'CalcDateDue does not crash when loan period lands on DST transition (Bug 39748)' => sub { >+ plan tests => 2; >+ >+ my $schema = Koha::Database->new->schema; >+ $schema->storage->txn_begin; >+ >+ my $mock_context = Test::MockModule->new('C4::Context'); >+ $mock_context->mock( 'tz', sub { DateTime::TimeZone->new( name => 'America/New_York' ) } ); >+ >+ my $library = $builder->build_object( { class => 'Koha::Libraries' } )->store; >+ my $patron = $builder->build_object( { class => 'Koha::Patrons', value => { dateexpiry => '2099-01-01' } } )->store; >+ my $itemtype = $builder->build_object( { class => 'Koha::ItemTypes' } )->store->itemtype; >+ >+ Koha::CirculationRules->set_rules( >+ { >+ categorycode => undef, >+ itemtype => $itemtype, >+ branchcode => $library->branchcode, >+ rules => { >+ issuelength => 21, >+ renewalperiod => 21, >+ lengthunit => 'days', >+ daysmode => 'Days', >+ } >+ } >+ ); >+ >+ # Feb 15 2026 at 02:31 America/New_York + 21 days = March 8 2026 at 02:31 >+ # March 8 is the DST spring-forward day in America/New_York - clocks jump from 02:00 to 03:00 >+ my $dst_start = DateTime->new( >+ year => 2026, >+ month => 2, >+ day => 15, >+ hour => 2, >+ minute => 31, >+ time_zone => 'America/New_York', >+ ); >+ >+ my $dst_date; >+ eval { $dst_date = C4::Circulation::CalcDateDue( $dst_start, $itemtype, $library->branchcode, $patron ); }; >+ ok( !$@, 'CalcDateDue does not crash when due date lands in DST gap' ); >+ is( $dst_date->ymd, '2026-03-08', 'Due date is correctly March 8 despite spring forward through DST' ); >+ >+ $mock_context->unmock('tz'); >+ $schema->storage->txn_rollback; >+}; >+ >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 39748
: 194929