@@ -270,14 +270,16 @@ export const useInputDate = ({
270
270
? dateValue . split ( props . dateSeparator as string )
271
271
: dateValue . split ( ' ' ) ;
272
272
273
- const firstDate = formatDateToNative ( dates [ 0 ] , props . format ) ;
274
- const secondDate = secondDateExists ? formatDateToNative ( dates [ 1 ] , props . format ) : '' ;
273
+ const firstDate = formatDateToNative ( dates [ 0 ] . trim ( ) , props . format , true ) ;
274
+ const secondDate = secondDateExists
275
+ ? formatDateToNative ( dates [ 1 ] . trim ( ) , props . format , true )
276
+ : '' ;
275
277
276
- const firstValueAsNumber = firstDate . length && new Date ( firstDate ) . getTime ( ) ;
277
- const secondValueAsNumber = secondDate . length && new Date ( secondDate ) . getTime ( ) ;
278
+ const firstValueAsNumber = firstDate . length && formatDateToUTC ( firstDate ) . getTime ( ) ;
279
+ const secondValueAsNumber = secondDate . length && formatDateToUTC ( secondDate ) . getTime ( ) ;
278
280
279
- const firstValueAsDate = firstDate . length && new Date ( firstDate ) ;
280
- const secondValueAsDate = secondDate . length && new Date ( secondDate ) ;
281
+ const firstValueAsDate = firstDate . length && formatDateToUTC ( firstDate ) ;
282
+ const secondValueAsDate = secondDate . length && formatDateToUTC ( secondDate ) ;
281
283
282
284
adaptEvent = {
283
285
target : {
@@ -346,14 +348,16 @@ export const useInputDate = ({
346
348
? dateValue . split ( props . dateSeparator as string )
347
349
: dateValue . split ( ' ' ) ;
348
350
349
- const firstDate = formatDateToNative ( dates [ 0 ] , props . format ) ;
350
- const secondDate = secondDateExists ? formatDateToNative ( dates [ 1 ] , props . format ) : '' ;
351
+ const firstDate = formatDateToNative ( dates [ 0 ] . trim ( ) , props . format , true ) ;
352
+ const secondDate = secondDateExists
353
+ ? formatDateToNative ( dates [ 1 ] . trim ( ) , props . format , true )
354
+ : '' ;
351
355
352
- const firstValueAsNumber = firstDate . length && new Date ( firstDate ) . getTime ( ) ;
353
- const secondValueAsNumber = secondDate . length && new Date ( secondDate ) . getTime ( ) ;
356
+ const firstValueAsNumber = firstDate . length && formatDateToUTC ( firstDate ) . getTime ( ) ;
357
+ const secondValueAsNumber = secondDate . length && formatDateToUTC ( secondDate ) . getTime ( ) ;
354
358
355
- const firstValueAsDate = firstDate . length && new Date ( firstDate ) ;
356
- const secondValueAsDate = secondDate . length && new Date ( secondDate ) ;
359
+ const firstValueAsDate = firstDate . length && formatDateToUTC ( firstDate ) ;
360
+ const secondValueAsDate = secondDate . length && formatDateToUTC ( secondDate ) ;
357
361
358
362
adaptEvent = {
359
363
target : {
@@ -395,10 +399,10 @@ export const useInputDate = ({
395
399
let adaptEvent ;
396
400
397
401
if ( hasSecondaDate ) {
398
- const firstNativeDate = formatDateToNative ( getDate ( orderedDates [ 0 ] ) , props . format ) ;
399
- const secondNativeDate = formatDateToNative ( getDate ( orderedDates [ 1 ] ) , props . format ) ;
400
- const firstValueAsNumber = new Date ( orderedDates [ 0 ] ) . getTime ( ) ;
401
- const secondValueAsNumber = new Date ( orderedDates [ 1 ] ) . getTime ( ) ;
402
+ const firstNativeDate = formatDateToNative ( getDate ( orderedDates [ 0 ] ) , props . format , true ) ;
403
+ const secondNativeDate = formatDateToNative ( getDate ( orderedDates [ 1 ] ) , props . format , true ) ;
404
+ const firstValueAsNumber = formatDateToUTC ( orderedDates [ 0 ] ) . getTime ( ) ;
405
+ const secondValueAsNumber = formatDateToUTC ( orderedDates [ 1 ] ) . getTime ( ) ;
402
406
403
407
adaptEvent = {
404
408
target : {
0 commit comments