Skip to content

Commit 7ea8b1f

Browse files
authored
Merge pull request #3246 from OpenTreeMap/jcw/date-picker-bug
Use strict mode when using moment.isValid to check date formatting.
2 parents b7e7bbf + 929595c commit 7ea8b1f

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

opentreemap/treemap/js/src/lib/udfcSearch.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,11 @@ function resetAction(state) {
156156
function resetDateBox(widgetName, state) {
157157
var name = makeNameAttribute(state, state.dateFieldKey),
158158
$widget = $(widgets[widgetName].selector),
159-
longDate = moment(state[widgetName], DATETIME_FORMAT),
160-
shortDate = moment(state[widgetName], 'MM/DD/YYYY'),
159+
// Passing `true` as the third argument when creating a moment enables
160+
// strict mode, which we need for the `isValid` check below to work
161+
// properly.
162+
longDate = moment(state[widgetName], DATETIME_FORMAT, true),
163+
shortDate = moment(state[widgetName], 'MM/DD/YYYY', true),
161164
shouldEnable = !_.isNull(state.modelName) && !_.isNull(state.type),
162165
val;
163166

0 commit comments

Comments
 (0)