Bugzilla – Attachment 150416 Details for
Bug 32232
Koha crashes if dateofbirth is 1947-04-27, 1948-04-25, or 1949-04-24
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32232: Ignore DST when calculating patron age
Bug-32232-Ignore-DST-when-calculating-patron-age.patch (text/plain), 1.52 KB, created by
Nick Clemens (kidclamp)
on 2023-04-28 18:56:56 UTC
(
hide
)
Description:
Bug 32232: Ignore DST when calculating patron age
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2023-04-28 18:56:56 UTC
Size:
1.52 KB
patch
obsolete
>From f1c41a48226156d57e19ab7950e9acabf113e6c6 Mon Sep 17 00:00:00 2001 >From: David Cook <dcook@prosentient.com.au> >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 <timezone></timezone> 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 <marius.mandrescu@inLibro.com> >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > 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
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 32232
:
149737
|
149738
|
149754
|
149758
| 150416