Skip to content

Commit

Permalink
Make sure Date.parse is not enumerable.
Browse files Browse the repository at this point in the history
Fixes #310.
  • Loading branch information
ljharb committed Jun 17, 2015
1 parent a91d34e commit ab9ff98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion es5-shim.js
Original file line number Diff line number Diff line change
Expand Up @@ -1029,7 +1029,7 @@ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExt
}, true);

// Upgrade Date.parse to handle simplified ISO 8601 strings
DateShim.parse = function parse(string) {
var parseShim = function parse(string) {
var match = isoDateExpression.exec(string);
if (match) {
// parse months, days, hours, minutes, seconds, and milliseconds
Expand Down Expand Up @@ -1084,6 +1084,7 @@ if (!Date.parse || doesNotParseY2KNewYear || acceptsInvalidDates || !supportsExt
}
return NativeDate.parse.apply(this, arguments);
};
defineProperties(DateShim, { parse: parseShim });

return DateShim;
}(Date));
Expand Down
4 changes: 4 additions & 0 deletions tests/spec/s-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ describe('Date', function () {
describe('parse', function () {
// TODO: Write the rest of the test.

ifSupportsDescriptorsIt('is not enumerable', function () {
expect(Object.getOwnPropertyDescriptor(Date, 'parse').enumerable).toBe(false);
});

it('should support extended years', function () {
expect(Date.parse('0001-01-01T00:00:00Z')).toBe(-62135596800000);
expect(Date.parse('+275760-09-13T00:00:00.000Z')).toBe(8.64e15);
Expand Down

0 comments on commit ab9ff98

Please sign in to comment.