File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed
Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -1292,19 +1292,23 @@ DateUtil = {
12921292
12931293 parse : function ( date ) {
12941294 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 ) ) {
12981299 return date ;
12991300 } else if ( TypeUtil . isNumber ( date ) ) {
13001301 timestamp = date ;
1301- return new Date ( timestamp ) ;
1302+ if ( timestampIsValid ( timestamp ) ) {
1303+ return new Date ( timestamp ) ;
1304+ }
13021305 } 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 ) ;
13061309 }
1307- if ( TypeUtil . isNumber ( timestamp ) ) {
1310+ timestamp = Date . parse ( date ) ;
1311+ if ( timestampIsValid ( timestamp ) ) {
13081312 return new Date ( timestamp ) ;
13091313 }
13101314 }
You can’t perform that action at this time.
0 commit comments