From 87eb8da76e65f7cefd9a62833f175538bf297826 Mon Sep 17 00:00:00 2001 From: Phil True Date: Tue, 25 Aug 2015 12:41:44 -0500 Subject: [PATCH 1/2] code works, tests not updated yet --- addon/components/datepicker-support.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/addon/components/datepicker-support.js b/addon/components/datepicker-support.js index 233954b..86ae266 100644 --- a/addon/components/datepicker-support.js +++ b/addon/components/datepicker-support.js @@ -133,6 +133,15 @@ export default Ember.Mixin.create({ case 'date': dates = [value]; break; + case 'string': + // try to convert strings to dates + // if it's an ISO formatted date it'll work, otherwise set to null + try { + dates = [new Date(value)]; + } catch (e) { + dates = [null]; + } + break; default: dates = [null]; } From 1eafefb1e9fb10ffb30ab98552b5b5c7f7378e65 Mon Sep 17 00:00:00 2001 From: maladon Date: Mon, 31 Aug 2015 13:58:26 -0500 Subject: [PATCH 2/2] test for ISO date format --- tests/unit/components/bootstrap-datepicker-test.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/unit/components/bootstrap-datepicker-test.js b/tests/unit/components/bootstrap-datepicker-test.js index ad291c9..d0b3352 100644 --- a/tests/unit/components/bootstrap-datepicker-test.js +++ b/tests/unit/components/bootstrap-datepicker-test.js @@ -42,6 +42,14 @@ test('displays date with custom format when format is set', function(assert) { assert.equal(this.$().val(), '31.Dec.14'); }); +test('allow input of ISO date strings', function(assert) { + this.subject({ + value: '2014-12-31T06:00:00Z' + }); + + assert.equal(this.$().val(), '12/31/2014'); +}); + test('resets date when input is cleared', function(assert) { this.subject({ value: new Date(2014, 11, 31)