From 82be444710f0da2a2f16336281f80832eba8db99 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 3 May 2022 15:31:32 +0000 Subject: [PATCH] Bug 30673: Improve is_valid_date function for validating date strings This patch corrects a couple of issues with our date validation in both the staff interface and the OPAC. The "is_valid_date" function needs to be able to accept a custom date format when one has been defined to override the default Flatpickr configuration. The function also needs to do better checking of the date itself following the transition to Flatpickr. jQueryUI's parse method had better built-in error handling, whereas Flatpickr's simply tries its best to convert a string into a date. We can use the existing Date_from_syspref function to check that the date string can be converted to a valid JavaScript Date object. To test, apply the patch and test date input fields in a few places in the staff interface, e.g. the patron edit form, the circulation statistics wizard, or the overdues page. Also check these specific pages: - With the dateformat system preference set to something other than "yyyy-mm-dd" open an item for editing. The "Date acquired" date picker should work correctly and fill the date in "yyyy-mm-dd" format (overriding the Flatpickr default). - Check Serial -> Claims to confirm that the "To" and "From" filters work correctly. - Test that various dateformat preference settings work in all cases. In the OPAC, test that date picker inputs work correctly on pages like the "Place hold" page, the "Your personal details" page, and "Your summary" -> "Holds" -> "Suspend." --- .../prog/en/includes/calendar.inc | 2 +- koha-tmpl/intranet-tmpl/prog/js/calendar.js | 59 +++++++------- .../bootstrap/en/includes/calendar.inc | 77 ++++++++++++++----- 3 files changed, 86 insertions(+), 52 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc index 549d046cd7..47a3f76ec2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc @@ -5,7 +5,7 @@ [% FILTER collapse %]