Skip to content

Commit

Permalink
[Fix] new Date(new Date()) should work in IE 8.
Browse files Browse the repository at this point in the history
Fixes #389.
  • Loading branch information
ljharb committed Feb 24, 2016
1 parent 4e1710a commit d90b7b6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion es5-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ if (doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExtendedYears) {
length >= 4 ? new NativeDate(Y, M, D, h) :
length >= 3 ? new NativeDate(Y, M, D) :
length >= 2 ? new NativeDate(Y, M) :
length >= 1 ? new NativeDate(Y) :
length >= 1 ? new NativeDate(Y instanceof NativeDate ? +Y : Y) :
new NativeDate();
} else {
date = NativeDate.apply(this, arguments);
Expand Down
9 changes: 9 additions & 0 deletions tests/spec/s-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ describe('Date', function () {
var expectedVeryBrokenTS = veryBrokenTS + (largeDate.getTimezoneOffset() * 60e3);
expect(veryBrokenDate.getTime()).toBe(expectedVeryBrokenTS); // NaN in Safari 8/9
});

it('works with a Date object', function () {
var date = new Date(1456297712984);
var copiedDate = new Date(date);
expect(date).not.toBe(copiedDate);
expect(copiedDate.getTime()).toBe(date.getTime());
expect(+copiedDate).toBe(+date);
expect(String(copiedDate)).toBe(String(date));
});
});

describe('.parse()', function () {
Expand Down

0 comments on commit d90b7b6

Please sign in to comment.