diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/datetime_range.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/datetime_range.js | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/app/assets/javascripts/lib/utils/datetime_range.js b/app/assets/javascripts/lib/utils/datetime_range.js index a2b161d1446..840cc4600fe 100644 --- a/app/assets/javascripts/lib/utils/datetime_range.js +++ b/app/assets/javascripts/lib/utils/datetime_range.js @@ -26,7 +26,17 @@ const isValidDateString = (dateString) => { return false; } - return !Number.isNaN(Date.parse(dateformat(dateString, 'isoUtcDateTime'))); + let isoFormatted; + try { + isoFormatted = dateformat(dateString, 'isoUtcDateTime'); + } catch (e) { + if (e instanceof TypeError) { + // not a valid date string + return false; + } + throw e; + } + return !Number.isNaN(Date.parse(isoFormatted)); }; const handleRangeDirection = ({ direction = DEFAULT_DIRECTION, anchorDate, minDate, maxDate }) => { |