From: Jonathan Gray Date: Sat, 21 May 2016 20:06:10 +0000 (-0700) Subject: toDate: remove ternary, add unit test X-Git-Tag: 2.14.0~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=697203b545f6fd459b15f3159ab023a53c454ac1;p=thirdparty%2Fmoment.git toDate: remove ternary, add unit test --- diff --git a/src/lib/moment/to-type.js b/src/lib/moment/to-type.js index 261225bc0..a990dd200 100644 --- a/src/lib/moment/to-type.js +++ b/src/lib/moment/to-type.js @@ -7,7 +7,7 @@ export function unix () { } export function toDate () { - return this._offset ? new Date(this.valueOf()) : new Date(this._d); + return new Date(this.valueOf()); } export function toArray () { diff --git a/src/test/moment/to_type.js b/src/test/moment/to_type.js index bbe2b5789..24d8e8339 100644 --- a/src/test/moment/to_type.js +++ b/src/test/moment/to_type.js @@ -20,3 +20,10 @@ test('toArray', function (assert) { var expected = [2014, 11, 26, 11, 46, 58, 17]; assert.deepEqual(moment(expected).toArray(), expected, 'toArray invalid'); }); + +test('toDate returns a copy of the internal date', function (assert) { + var m = moment(); + var d = m.toDate(); + m.year(0); + assert.notEqual(d, m.toDate()); +});