File tree 3 files changed +14
-10
lines changed
3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -1292,19 +1292,23 @@ DateUtil = {
1292
1292
1293
1293
parse : function ( date ) {
1294
1294
var timestamp ;
1295
- if ( ! date ) {
1296
- return null ;
1297
- } else if ( TypeUtil . isDate ( date ) ) {
1295
+ var timestampIsValid = function ( t ) {
1296
+ return TypeUtil . isNumber ( t ) && t >= 0 && t <= DateUtil . timestamp ( ) ;
1297
+ } ;
1298
+ if ( TypeUtil . isDate ( date ) ) {
1298
1299
return date ;
1299
1300
} else if ( TypeUtil . isNumber ( date ) ) {
1300
1301
timestamp = date ;
1301
- return new Date ( timestamp ) ;
1302
+ if ( timestampIsValid ( timestamp ) ) {
1303
+ return new Date ( timestamp ) ;
1304
+ }
1302
1305
} else if ( TypeUtil . isString ( date ) ) {
1303
- timestamp = parseInt ( date ) ;
1304
- if ( ! TypeUtil . isNumber ( timestamp ) ) {
1305
- timestamp = Date . parse ( date ) ;
1306
+ timestamp = Number ( date ) ;
1307
+ if ( timestampIsValid ( timestamp ) ) {
1308
+ return new Date ( timestamp ) ;
1306
1309
}
1307
- if ( TypeUtil . isNumber ( timestamp ) ) {
1310
+ timestamp = Date . parse ( date ) ;
1311
+ if ( timestampIsValid ( timestamp ) ) {
1308
1312
return new Date ( timestamp ) ;
1309
1313
}
1310
1314
}
You can’t perform that action at this time.
0 commit comments