Commit f370eab 1 parent f9d65f2 commit f370eab Copy full SHA for f370eab
File tree 2 files changed +1
-38
lines changed
2 files changed +1
-38
lines changed Original file line number Diff line number Diff line change @@ -855,26 +855,15 @@ describe('Validators', function () {
855
855
validator : 'isDate'
856
856
, valid : [
857
857
'2011-08-04'
858
- , '2011-09-30'
859
858
, '04. 08. 2011.'
860
859
, '08/04/2011'
861
860
, '2011.08.04'
862
861
, '4. 8. 2011. GMT'
863
- , '2. 28. 2011. GMT'
864
- , '2. 29. 2008. GMT'
865
- , '2. 29. 1988. GMT'
866
862
, '2011-08-04 12:00'
867
- , '2/29/24'
868
- , '2-29-24'
869
863
]
870
864
, invalid : [
871
865
'foo'
872
866
, '2011-foo-04'
873
- , '2011-09-31'
874
- , '2. 29. 1987. GMT'
875
- , '2. 29. 2011. GMT'
876
- , '2/29/25'
877
- , '2-29-25'
878
867
, 'GMT'
879
868
]
880
869
} ) ;
Original file line number Diff line number Diff line change 450
450
} ;
451
451
452
452
validator . isDate = function ( str ) {
453
- var normalizedDate = new Date ( ( new Date ( str ) ) . toUTCString ( ) ) ;
454
- var regularDay = String ( normalizedDate . getDate ( ) ) ;
455
- var utcDay = String ( normalizedDate . getUTCDate ( ) ) ;
456
- var dayOrYear , dayOrYearMatches , year ;
457
- if ( isNaN ( Date . parse ( normalizedDate ) ) ) {
458
- return false ;
459
- }
460
- //check for valid double digits that could be late days
461
- //check for all matches since a string like '12/23' is a valid date
462
- dayOrYearMatches = str . match ( / [ 2 3 ] \d ( \D | $ ) / g) ;
463
- if ( ! dayOrYearMatches ) {
464
- return true ;
465
- }
466
- dayOrYear = dayOrYearMatches . map ( function ( match ) {
467
- return match . slice ( 0 , 2 ) ;
468
- } ) . join ( '/' ) ;
469
- year = String ( normalizedDate . getFullYear ( ) ) . slice ( - 2 ) ;
470
- //local date and UTC date can differ, but both are valid, so check agains both
471
- if ( dayOrYear === regularDay || dayOrYear === utcDay || dayOrYear === year ) {
472
- return true ;
473
- } else if ( ( dayOrYear === ( regularDay + '/' + year ) ) || ( dayOrYear === ( year + '/' + regularDay ) ) ) {
474
- return true ;
475
- } else if ( ( dayOrYear === ( utcDay + '/' + year ) ) || ( dayOrYear === ( year + '/' + utcDay ) ) ) {
476
- return true ;
477
- } else {
478
- return false ;
479
- }
453
+ return ! isNaN ( Date . parse ( str ) ) ;
480
454
} ;
481
455
482
456
validator . isAfter = function ( str , date ) {
You can’t perform that action at this time.
0 commit comments