Bug 39748: Fix Koha::Patron->is_expired to calculate using floating timezone
This patch updates Koha::Patron->is_expired so that it uses the floating
timezone for its datemath calculation.
Test plan:
0. Apply only the first patch including the unit test
1. prove -v t/db_dependent/Koha/ILL/Request.t \
t/db_dependent/Koha/Patron/Restriction.t \
t/db_dependent/Koha/Patrons.t \
t/db_dependent/Koha/AdditionalContents.t \
t/db_dependent/ILSDI_Services.t
2. Note that the unit tests fail
3. Apply the patch including the fix
4. prove -v t/db_dependent/Koha/ILL/Request.t \
t/db_dependent/Koha/Patron/Restriction.t \
t/db_dependent/Koha/Patrons.t \
t/db_dependent/Koha/AdditionalContents.t \
t/db_dependent/ILSDI_Services.t
5. Note that all unit tests pass now
6. Bonus points:
- Add the following to the top of /etc/koha/sites/kohadev/plack.psgi
before Modern::Perl:
use Test::MockTime;
BEGIN {
Test::MockTime::set_absolute_time('1745580600');
}
- koha-plack --restart kohadev
- Look at the About page and do some circulation
- Without the patches, you'll get an internal server error
- With the patches, it'll just work
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
parent
e0859f245f
commit
076c5bce8d
|
|
@ -931,7 +931,12 @@ sub is_expired {
|
|||
my ($self) = @_;
|
||||
return 0 unless $self->dateexpiry;
|
||||
return 0 if $self->dateexpiry =~ '^9999';
|
||||
return 1 if dt_from_string( $self->dateexpiry ) < dt_from_string->truncate( to => 'day' );
|
||||
|
||||
#NOTE: We set the timezone to floating so that we can do datetime math regardless of impossible local (DST) times
|
||||
#In this case, we need a comparison with "local midnight" but local midnight doesn't exist for some timezones.
|
||||
return 1
|
||||
if ( dt_from_string( $self->dateexpiry )->set_time_zone('floating') ) <
|
||||
( dt_from_string()->set_time_zone('floating')->truncate( to => 'day' ) );
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue