Bugzilla – Attachment 131673 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: Deal with timezones
Bug-30059-Deal-with-timezones.patch (text/plain), 1.84 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-03-14 18:13:48 UTC
(
hide
)
Description:
Bug 30059: Deal with timezones
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-03-14 18:13:48 UTC
Size:
1.84 KB
patch
obsolete
>From ff8a10f68e9c33dae17a31d4ca0d2d2a253224d9 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 3 Mar 2022 10:21:48 +0100 >Subject: [PATCH] Bug 30059: Deal with timezones > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > .../prog/en/includes/js-patron-get-age.inc | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) > >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 >index c4ab0c0cab..25d824490c 100644 >--- 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 >@@ -1,14 +1,25 @@ > <!-- js-patron-get-age.inc --> >+[% USE KohaDates %] > <script> > (function() { > >+ const tz = '[% KohaDates.tz | html %]'; > window.$get_age = function(dob, options) { > if(!dob) return ''; > >- var today = new Date(); >+ let today = new Date(); > dob = new Date(dob); >- var age = today.getFullYear() - dob.getFullYear(); >- var m = today.getMonth() - dob.getMonth(); >+ if ( tz ) { >+ let today_tz = new Date(today.toLocaleString('en-US', {timeZone: tz})); >+ let diff = today.getTime() - today_tz.getTime(); >+ today = new Date(today.getTime() - diff); >+ >+ let dob_tz = new Date(dob.toLocaleString('en-US', {timeZone: tz})); >+ diff = dob.getTime() - dob_tz.getTime(); >+ dob = new Date(dob.getTime() - diff); >+ } >+ let age = today.getFullYear() - dob.getFullYear(); >+ let m = today.getMonth() - dob.getMonth(); > if (m < 0 || (m === 0 && today.getDate() < dob.getDate())) { > age--; > } >-- >2.32.0
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