From 381e00b74fa3fc4f7a71906fa8de18d4f2328c18 Mon Sep 17 00:00:00 2001 From: Billy Zhou Date: Tue, 2 Oct 2018 06:45:52 +0200 Subject: [PATCH] Fixed issue #2173 - Invalid date causes errors (fixes #2173) --- .../javascripts/app/controllers/_ui_element/datetime.coffee | 1 + public/assets/tests/form_validation.js | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/app/assets/javascripts/app/controllers/_ui_element/datetime.coffee b/app/assets/javascripts/app/controllers/_ui_element/datetime.coffee index 648aa9981..4e6c5ba5f 100644 --- a/app/assets/javascripts/app/controllers/_ui_element/datetime.coffee +++ b/app/assets/javascripts/app/controllers/_ui_element/datetime.coffee @@ -37,6 +37,7 @@ class App.UiElement.datetime extends App.UiElement.basedate @buildTimestamp: (currentInput) -> timestamp = "#{currentInput[0]}T#{currentInput[1]}:00.000Z" time = new Date( Date.parse(timestamp) ) + return '' if isNaN time time.setMinutes( time.getMinutes() + time.getTimezoneOffset() ) @log 'setNewTime', time.toString() time.toISOString().replace(/\d\d\.\d\d\dZ$/, '00.000Z') diff --git a/public/assets/tests/form_validation.js b/public/assets/tests/form_validation.js index 1a4291130..08876a344 100644 --- a/public/assets/tests/form_validation.js +++ b/public/assets/tests/form_validation.js @@ -309,6 +309,10 @@ test( "datetime selector check", function() { } deepEqual(params, test_params, 'params check') + // Regression test for issue #2173 - Invalid date causes errors + el.find('.js-datepicker').datepicker('setDate', '01/01/99999') + el.find('.js-datepicker').datepicker('setDate', '01/01/1ABCDEFG') + el.find('.js-datepicker').datepicker('setDate', '01/01/1äöüß') }); test( "date selector check", function() {