[Koha-bugs] [Bug 30673] New: Improve is_valid_date function for validating date strings
bugzilla-daemon at bugs.koha-community.org
bugzilla-daemon at bugs.koha-community.org
Tue May 3 18:22:49 CEST 2022
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30673
Bug ID: 30673
Summary: Improve is_valid_date function for validating date
strings
Change sponsored?: ---
Product: Koha
Version: master
Hardware: All
OS: All
Status: ASSIGNED
Severity: minor
Priority: P5 - low
Component: Templates
Assignee: oleonard at myacpl.org
Reporter: oleonard at myacpl.org
QA Contact: testopia at bugs.koha-community.org
The is_valid_date() function in calendar.js has two jobs: Confirm that the date
string matches the current date format according to a regular expression; and
confirm that the date is an actual date. Both must be true.
For example:
"2002-03-14" matches the date format "Y-m-d" and is a valid date -- valid date.
"03/14/2002" doesn't match the date format "Y-m-d" even though it is a valid
date -- invalid date.
"38-44-2103" doesn't match the date format "Y-m-d" and isn't a valid date --
invalid date.
is_valid_date() needs some changes in order for it to correctly handle custom
date formats being specified which override the default date format (from the
system preference).
It also needs a new way to check that a date string represents a valid date.
The old jQueryUI method looks similar but behaves differently.
$.datepicker.parseDate() would throw an exception if the date were invalid.
flatpickr.parseDate() will try to interpret an invalid date as if it were
valid.
For example:
flatpickr.parseDate("2002-48-66", "Y-m-d") -> Date Sat Feb 04 2006 00:00:00
flatpickr.parseDate("2002-48-66", "m/d/Y") -> Date Mon Aug 02 2027 00:00:00
--
You are receiving this mail because:
You are watching all bug changes.
More information about the Koha-bugs
mailing list