From 7415f5de325a9fe79325cf9349d58bef39730848 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 Signed-off-by: Marius Mandrescu --- Koha/Patron.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index edd115ad59..9cdcde09d4 100755 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -1264,8 +1264,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.34.1