Bug 30061 - Simplify Koha::Patron->get_age
Summary: Simplify Koha::Patron->get_age
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: unspecified
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Tomás Cohen Arazi
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-09 13:44 UTC by Tomás Cohen Arazi
Modified: 2022-03-25 13:38 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00


Attachments
Bug 30061: Make Koha::Patron->get_age use DateTime math (1.82 KB, patch)
2022-02-09 13:47 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 30061: Make Koha::Patron->get_age use DateTime math (1.87 KB, patch)
2022-03-03 19:40 UTC, David Nind
Details | Diff | Splinter Review
Bug 30061: Make Koha::Patron->get_age use DateTime math (1.96 KB, patch)
2022-03-18 07:49 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi 2022-02-09 13:44:04 UTC
The method could just use regular DateTime/DateTime::Duration arithmetic instead of parsing strings and doing math manually.
Comment 1 Tomás Cohen Arazi 2022-02-09 13:47:44 UTC
Created attachment 130362 [details] [review]
Bug 30061: Make Koha::Patron->get_age use DateTime math

This patch does what the title says. Instead of converting dates to
strings and performing math manually, we can just use the DateTime
objects we have and calculate the DateTime::Duration there's between
them, to get the years count.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patrons.t
=> SUCCESS: Tests pass
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 2 David Nind 2022-03-03 19:40:11 UTC
Created attachment 131360 [details] [review]
Bug 30061: Make Koha::Patron->get_age use DateTime math

This patch does what the title says. Instead of converting dates to
strings and performing math manually, we can just use the DateTime
objects we have and calculate the DateTime::Duration there's between
them, to get the years count.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patrons.t
=> SUCCESS: Tests pass
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Marcel de Rooy 2022-03-18 07:49:40 UTC
Created attachment 131858 [details] [review]
Bug 30061: Make Koha::Patron->get_age use DateTime math

This patch does what the title says. Instead of converting dates to
strings and performing math manually, we can just use the DateTime
objects we have and calculate the DateTime::Duration there's between
them, to get the years count.

To test:
1. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Patrons.t
=> SUCCESS: Tests pass
2. Apply this patch
3. Repeat 1
=> SUCCESS: Tests pass
4. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 4 Fridolin Somers 2022-03-22 20:19:15 UTC
Pushed to master for 22.05, thanks to everybody involved 🦄