Skip to content

Commit

Permalink
Use native Date parse for ISO 8601 string
Browse files Browse the repository at this point in the history
Fixes #1
  • Loading branch information
CaptainCodeman committed Sep 14, 2016
1 parent 08fdc67 commit ae61c9a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
11 changes: 11 additions & 0 deletions test/time-display_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@
</template>
</test-fixture>

<test-fixture id="datetimeset">
<template>
<time-display datetime="2016-09-14T14:55:48.000Z"></time-display>
</template>
</test-fixture>

<script>
suite('time-display', function() {

Expand All @@ -26,6 +32,11 @@
assert.equal(element.is, 'time-display');
});

test('datetime is parsed correctly', function() {
var element = fixture('datetimeset');
assert.equal(element.datetime, element.ISOString);
});

});
</script>
</body>
Expand Down
2 changes: 1 addition & 1 deletion time-diff.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
},

_update: function(datetime, format) {
this._datetime = (datetime === 'now') ? this._nowUTC() : fecha.parse(datetime, 'YYYY-MM-DDTHH:mm:ss');
this._datetime = (datetime === 'now') ? this._nowUTC() : new Date(datetime);
this.ISOString = this._datetime.toISOString();

if (this._timer) {
Expand Down
2 changes: 1 addition & 1 deletion time-display.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
],

_update: function(datetime, format) {
this._datetime = (datetime === 'now') ? this._nowUTC() : fecha.parse(datetime, 'YYYY-MM-DDTHH:mm:ss');
this._datetime = (datetime === 'now') ? this._nowUTC() : new Date(datetime);
this.ISOString = this._datetime.toISOString();
this.value = fecha.format(this._datetime, format);
},
Expand Down

0 comments on commit ae61c9a

Please sign in to comment.