Skip to content

Commit

Permalink
Add fallback for Qt Script bug with wrong conversion date to number, #…
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 8, 2016
1 parent b2c2ad9 commit 52b288c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion library/modules/es6.date.now.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 20.3.3.1 / 15.9.4.4 Date.now()
var $export = require('./_export');

$export($export.S, 'Date', {now: function(){ return +new Date; }});
$export($export.S, 'Date', {now: function(){ return new Date().getTime(); }});
5 changes: 3 additions & 2 deletions library/modules/es6.date.to-iso-string.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
var $export = require('./_export')
, fails = require('./_fails');
, fails = require('./_fails')
, getTime = Date.prototype.getTime;

var lz = function(num){
return num > 9 ? num : '0' + num;
Expand All @@ -14,7 +15,7 @@ $export($export.P + $export.F * (fails(function(){
new Date(NaN).toISOString();
})), 'Date', {
toISOString: function toISOString(){
if(!isFinite(this))throw RangeError('Invalid time value');
if(!isFinite(getTime.call(this)))throw RangeError('Invalid time value');
var d = this
, y = d.getUTCFullYear()
, m = d.getUTCMilliseconds()
Expand Down
2 changes: 1 addition & 1 deletion modules/es6.date.now.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// 20.3.3.1 / 15.9.4.4 Date.now()
var $export = require('./_export');

$export($export.S, 'Date', {now: function(){ return +new Date; }});
$export($export.S, 'Date', {now: function(){ return new Date().getTime(); }});
5 changes: 3 additions & 2 deletions modules/es6.date.to-iso-string.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
'use strict';
// 20.3.4.36 / 15.9.5.43 Date.prototype.toISOString()
var $export = require('./_export')
, fails = require('./_fails');
, fails = require('./_fails')
, getTime = Date.prototype.getTime;

var lz = function(num){
return num > 9 ? num : '0' + num;
Expand All @@ -14,7 +15,7 @@ $export($export.P + $export.F * (fails(function(){
new Date(NaN).toISOString();
})), 'Date', {
toISOString: function toISOString(){
if(!isFinite(this))throw RangeError('Invalid time value');
if(!isFinite(getTime.call(this)))throw RangeError('Invalid time value');
var d = this
, y = d.getUTCFullYear()
, m = d.getUTCMilliseconds()
Expand Down
5 changes: 3 additions & 2 deletions modules/es6.date.to-string.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
var DateProto = Date.prototype
, INVALID_DATE = 'Invalid Date'
, TO_STRING = 'toString'
, $toString = DateProto[TO_STRING];
, $toString = DateProto[TO_STRING]
, getTime = DateProto.getTime;
if(new Date(NaN) + '' != INVALID_DATE){
require('./_redefine')(DateProto, TO_STRING, function toString(){
var value = +this;
var value = getTime.call(this);
return value === value ? $toString.call(this) : INVALID_DATE;
});
}

0 comments on commit 52b288c

Please sign in to comment.