Skip to content
This repository was archived by the owner on Dec 26, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions addon/components/datepicker-support.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/components/bootstrap-datepicker-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down