File tree Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Expand file tree Collapse file tree 1 file changed +18
-12
lines changed Original file line number Diff line number Diff line change @@ -77,20 +77,26 @@ const Input: React.FC<Props> = (e: Props) => {
7777 }
7878 } else {
7979 const parsed = inputValue . split ( separator ) ;
80+
81+ let startDate = null ;
82+ let endDate = null ;
83+
8084 if ( parsed . length === 2 ) {
81- const startDate = parseFormattedDate ( parsed [ 0 ] , displayFormat ) ;
82- const endDate = parseFormattedDate ( parsed [ 1 ] , displayFormat ) ;
83-
84- if (
85- dateIsValid ( startDate . toDate ( ) ) &&
86- dateIsValid ( endDate . toDate ( ) ) &&
87- startDate . isBefore ( endDate )
88- ) {
89- dates . push ( startDate . format ( DATE_FORMAT ) ) ;
90- dates . push ( endDate . format ( DATE_FORMAT ) ) ;
91- }
85+ startDate = parseFormattedDate ( parsed [ 0 ] , displayFormat ) ;
86+ endDate = parseFormattedDate ( parsed [ 1 ] , displayFormat ) ;
9287 } else {
93- // TODO: Handle the case where there is separator in the date format or no separator at all
88+ const middle = Math . floor ( inputValue . length / 2 ) ;
89+ startDate = parseFormattedDate ( inputValue . slice ( 0 , middle ) , displayFormat ) ;
90+ endDate = parseFormattedDate ( inputValue . slice ( middle ) , displayFormat ) ;
91+ }
92+
93+ if (
94+ dateIsValid ( startDate . toDate ( ) ) &&
95+ dateIsValid ( endDate . toDate ( ) ) &&
96+ startDate . isBefore ( endDate )
97+ ) {
98+ dates . push ( startDate . format ( DATE_FORMAT ) ) ;
99+ dates . push ( endDate . format ( DATE_FORMAT ) ) ;
94100 }
95101 }
96102
You can’t perform that action at this time.
0 commit comments