Skip to content

Commit

Permalink
Merge 8676f75 into d0f0dd8
Browse files Browse the repository at this point in the history
  • Loading branch information
jnelssonsmith committed May 4, 2019
2 parents d0f0dd8 + 8676f75 commit a73bf17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/create/from-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ export function configFromObject(config) {
}

var i = normalizeObjectUnits(config._i);
config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {

var dayOrDate = i.day === undefined ? i.date : i.day;
config._a = map([i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond], function (obj) {
return obj && parseInt(obj, 10);
});

Expand Down
7 changes: 7 additions & 0 deletions src/test/moment/create.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ test('object', function (assert) {
}
});

test('invalid date for object with zero value date or day keys', function (assert) {
assert.equal(moment({date: '0'}).format(), 'Invalid date');
assert.equal(moment({date: 0}).format(), 'Invalid date');
assert.equal(moment({day: '0'}).format(), 'Invalid date');
assert.equal(moment({day: 0}).format(), 'Invalid date');
});

test('multi format array copying', function (assert) {
var importantArray = ['MM/DD/YYYY', 'YYYY-MM-DD', 'MM-DD-YYYY'];
moment('1999-02-13', importantArray);
Expand Down

0 comments on commit a73bf17

Please sign in to comment.