LP1840950 Patron expiration date & iPads user/mccanna/lp1840950_mac_patron_expiration_date
authorTerran McCanna <tmccanna@georgialibraries.org>
Wed, 20 May 2020 19:33:57 +0000 (15:33 -0400)
committerTerran McCanna <tmccanna@georgialibraries.org>
Wed, 20 May 2020 19:33:57 +0000 (15:33 -0400)
This resolves a problem where the patron expiration date was not
displaying when editing a patron account on an iOS device because
Safari did not allow the deprecated Date() function.

This code uses javascript to reformat the date, similar to how the
DOB on the same form is handled.

Signed-off-by: Terran McCanna <tmccanna@georgialibraries.org>
Open-ILS/web/js/ui/default/staff/circ/patron/regctl.js

index 4a340bd..2177de3 100644 (file)
@@ -752,7 +752,7 @@ angular.module('egCoreMod')
         var patron = egCore.idl.toHash(current);
 
         patron.home_ou = egCore.org.get(patron.home_ou.id);
-        patron.expire_date = new Date(Date.parse(patron.expire_date));
+        patron.expire_date = service.parse_expire_date(patron.expire_date);
         patron.dob = service.parse_dob(patron.dob);
         patron.profile = current.profile(); // pre-hash version
         patron.net_access_level = current.net_access_level();
@@ -865,6 +865,14 @@ angular.module('egCoreMod')
         return new Date(parts[0], parts[1] - 1, parts[2])
     }
 
+    // parse expire date to reformat with correct time zone format_name
+    // TODO: move this into egDate ?
+    service.parse_expire_date = function(expire_date) {
+        if(!expire_date) return null;
+        var timezoneslice = expire_date.slice(0,22) + ":" + expire_date.slice(22,24);
+        return new Date(timezoneslice)
+    }
+
     service.copy_stage_data = function(user) {
         var cuser = service.stage_user;