SirsiDynix: Additional Datepicker fixes #619
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is an extension of #581 and #582
Prior to this fix, dates within a form are formatted by the datepicker plugin. Thus, in the config file, if the format were
dd/mm/yyyy
, the date January 2nd, 2019 would be formatted and submitted as the string02/01/2019
.But the php scripts that parse the
$_POST
variables are usingstrtotime()
, which "..expects to be given a string containing an English date format". Further digging into php docs showed that strtotime only works with American date formatting when using forward slashes, and has very specific formats for dashes.Thus the above string of
02/01/2019
will always be parsed as February 1st, 2019 usingstrtotime()
Here, I've written the necessary functions to use
date_create_from_format()
, which, instead, lets you pass a specific format to the parser, so the parse knows exactly where days and months exist in the string.Testing
common/configuration.ini
Change thedatepicker_date_format
anddate_format
settings to something else (e.g.dd-mm-yyyy
and%d-%m-%Y
, respectively).20-12-2019
would have resulted in a 1969 date because strtotime cannot parse that string.