fix(datepicker): handle output format when reformatting
Fixes issue of datepicker randomly shifting dates if page is reloaded (browser caches fancy formatting, which frontend could not understand)
This commit is contained in:
parent
81415e1afb
commit
09622bdb12
@ -33,7 +33,7 @@ const FORM_DATE_FORMAT_MOMENT = {
|
|||||||
* @param {*} formatOut format string of the desired output date string
|
* @param {*} formatOut format string of the desired output date string
|
||||||
*/
|
*/
|
||||||
function reformatDateString(dateStr, formatIn, formatOut) {
|
function reformatDateString(dateStr, formatIn, formatOut) {
|
||||||
const parsedMomentDate = moment(dateStr, formatIn);
|
const parsedMomentDate = moment(dateStr, [formatIn, formatOut]);
|
||||||
return parsedMomentDate.isValid() ? parsedMomentDate.format(formatOut) : dateStr;
|
return parsedMomentDate.isValid() ? parsedMomentDate.format(formatOut) : dateStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user