From 9cac9646765c347d8e042ed675e50055c81b3cfd Mon Sep 17 00:00:00 2001 From: David Cook Date: Mon, 17 Apr 2023 00:34:05 +0000 Subject: [PATCH] Bug 32232: Ignore DST when calculating patron age This change calculates patron age using the floating timezone, so that datetimes missing midnight don't cause fatal errors in the comparison. Test plan: 0. Apply patch 1. Change in koha-conf.xml to include Canada/Eastern 2. koha-plack --restart kohadev 3. Create a patron, setting the date of birth to one of these three dates - 1947-04-27 - 1948-04-25 - 1949-04-24 4. Save the patron 5. Patron detail page loads instead of producing fatal error --- Koha/Patron.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index f0e1734217..cbd93501f0 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1312,8 +1312,9 @@ sub get_age { return unless $self->dateofbirth; - my $date_of_birth = dt_from_string( $self->dateofbirth ); - my $today = dt_from_string->truncate( to => 'day' ); + #Set timezone to floating to avoid any datetime math issues caused by DST + my $date_of_birth = dt_from_string( $self->dateofbirth, undef, 'floating' ); + my $today = dt_from_string(undef, undef, 'floating')->truncate( to => 'day' ); return $today->subtract_datetime( $date_of_birth )->years; } -- 2.30.2