@@ -12,19 +12,19 @@ describe('Date Time Parsing', () => {
1212 it ( 'should correctly parse all date time parts (base)' , ( ) => {
1313 const result = DatePickerUtil . parseDateTimeFormat ( 'dd/MM/yyyy HH:mm:ss tt' ) ;
1414 const expected = [
15- { start : 0 , end : 2 , type : DatePart . Date , format : 'dd' } ,
16- { start : 2 , end : 3 , type : DatePart . Literal , format : '/' } ,
17- { start : 3 , end : 5 , type : DatePart . Month , format : 'MM' } ,
18- { start : 5 , end : 6 , type : DatePart . Literal , format : '/' } ,
19- { start : 6 , end : 10 , type : DatePart . Year , format : 'yyyy' } ,
20- { start : 10 , end : 11 , type : DatePart . Literal , format : ' ' } ,
21- { start : 11 , end : 13 , type : DatePart . Hours , format : 'HH' } ,
22- { start : 13 , end : 14 , type : DatePart . Literal , format : ':' } ,
23- { start : 14 , end : 16 , type : DatePart . Minutes , format : 'mm' } ,
24- { start : 16 , end : 17 , type : DatePart . Literal , format : ':' } ,
25- { start : 17 , end : 19 , type : DatePart . Seconds , format : 'ss' } ,
26- { start : 19 , end : 20 , type : DatePart . Literal , format : ' ' } ,
27- { start : 20 , end : 22 , type : DatePart . AmPm , format : 'tt' }
15+ { start : 0 , end : 2 , type : DatePart . Date , format : 'dd' } ,
16+ { start : 2 , end : 3 , type : DatePart . Literal , format : '/' } ,
17+ { start : 3 , end : 5 , type : DatePart . Month , format : 'MM' } ,
18+ { start : 5 , end : 6 , type : DatePart . Literal , format : '/' } ,
19+ { start : 6 , end : 10 , type : DatePart . Year , format : 'yyyy' } ,
20+ { start : 10 , end : 11 , type : DatePart . Literal , format : ' ' } ,
21+ { start : 11 , end : 13 , type : DatePart . Hours , format : 'HH' } ,
22+ { start : 13 , end : 14 , type : DatePart . Literal , format : ':' } ,
23+ { start : 14 , end : 16 , type : DatePart . Minutes , format : 'mm' } ,
24+ { start : 16 , end : 17 , type : DatePart . Literal , format : ':' } ,
25+ { start : 17 , end : 19 , type : DatePart . Seconds , format : 'ss' } ,
26+ { start : 19 , end : 20 , type : DatePart . Literal , format : ' ' } ,
27+ { start : 20 , end : 22 , type : DatePart . AmPm , format : 'tt' }
2828 ] ;
2929 expect ( JSON . stringify ( result ) ) . toEqual ( JSON . stringify ( expected ) ) ;
3030 } ) ;
@@ -67,4 +67,14 @@ describe('Date Time Parsing', () => {
6767 expect ( resDict [ DatePart . Month ] ) . toEqual ( jasmine . objectContaining ( { start : 5 , end : 7 } ) ) ;
6868 expect ( resDict [ DatePart . Date ] ) . toEqual ( jasmine . objectContaining ( { start : 8 , end : 10 } ) ) ;
6969 } ) ;
70+
71+ it ( 'should correctly parse boundary dates' , ( ) => {
72+ const parts = DatePickerUtil . parseDateTimeFormat ( 'MM/dd/yyyy' ) ;
73+ let result = DatePickerUtil . parseValueFromMask ( '08/31/2020' , parts ) ;
74+ expect ( result ) . toEqual ( new Date ( 2020 , 7 , 31 ) ) ;
75+ result = DatePickerUtil . parseValueFromMask ( '09/30/2020' , parts ) ;
76+ expect ( result ) . toEqual ( new Date ( 2020 , 8 , 30 ) ) ;
77+ result = DatePickerUtil . parseValueFromMask ( '10/31/2020' , parts ) ;
78+ expect ( result ) . toEqual ( new Date ( 2020 , 9 , 31 ) ) ;
79+ } ) ;
7080} ) ;
0 commit comments