Bugzilla – Attachment 132178 Details for
Bug 30059
Add a JS equivalent to Koha::Patron->get_age
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30059: Add JS equivalent for Koha::Patron->get_age
Bug-30059-Add-JS-equivalent-for-KohaPatron-getage.patch (text/plain), 1.74 KB, created by
Nick Clemens (kidclamp)
on 2022-03-24 15:27:14 UTC
(
hide
)
Description:
Bug 30059: Add JS equivalent for Koha::Patron->get_age
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2022-03-24 15:27:14 UTC
Size:
1.74 KB
patch
obsolete
>From b9968c9a29f29721983bceccd78586547406ad2e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 3 Feb 2022 10:31:27 +0100 >Subject: [PATCH] Bug 30059: Add JS equivalent for Koha::Patron->get_age > >On bug 30055 we are going to use the REST API to display the patron >search result, we will then need to calculate patron's age client-side. >This is moved to its own bug report in case we need to reuse it >somewhere else. > >Test plan: >Copy/paste the JS function in your browser's console then call it and >confirm that the result is correct >For instance: > $get_age('2000-01-01') > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > .../prog/en/includes/js-patron-get-age.inc | 20 +++++++++++++++++++ > 1 file changed, 20 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-get-age.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-get-age.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-get-age.inc >new file mode 100644 >index 0000000000..c4ab0c0cab >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/js-patron-get-age.inc >@@ -0,0 +1,20 @@ >+<!-- js-patron-get-age.inc --> >+<script> >+ (function() { >+ >+ window.$get_age = function(dob, options) { >+ if(!dob) return ''; >+ >+ var today = new Date(); >+ dob = new Date(dob); >+ var age = today.getFullYear() - dob.getFullYear(); >+ var m = today.getMonth() - dob.getMonth(); >+ if (m < 0 || (m === 0 && today.getDate() < dob.getDate())) { >+ age--; >+ } >+ return age; >+ } >+ >+ })(); >+</script> >+<!-- / js-patron-get-age.inc --> >-- >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 30059
:
130358
|
130665
|
131309
|
131672
|
131673
| 132178 |
132179