@@ -575,7 +575,7 @@ describe("DatePicker with timeZone prop", () => {
575575 expect ( changedEndDate ) . toBeNull ( ) ;
576576 } ) ;
577577
578- it ( "should handle time change with timezone and selectsRange using legacy showTimeSelect" , ( ) => {
578+ it ( "should handle time change with timezone and selectsRange using legacy showTimeSelect (both dates) " , ( ) => {
579579 // Mock ResizeObserver
580580 const mockResizeObserver = jest . fn ( ) . mockImplementation ( ( ) => ( {
581581 observe : jest . fn ( ) ,
@@ -612,6 +612,48 @@ describe("DatePicker with timeZone prop", () => {
612612 // onChange should have been called with timezone conversion
613613 expect ( onChangeMock ) . toHaveBeenCalled ( ) ;
614614 } ) ;
615+
616+ it ( "should handle time change with timezone and selectsRange using legacy showTimeSelect (only start date)" , ( ) => {
617+ // Mock ResizeObserver
618+ const mockResizeObserver = jest . fn ( ) . mockImplementation ( ( ) => ( {
619+ observe : jest . fn ( ) ,
620+ unobserve : jest . fn ( ) ,
621+ disconnect : jest . fn ( ) ,
622+ } ) ) ;
623+ window . ResizeObserver = mockResizeObserver ;
624+
625+ const startDate = new Date ( "2024-06-15T12:00:00Z" ) ;
626+ const onChangeMock = jest . fn ( ) ;
627+
628+ const { container } = render (
629+ < DatePicker
630+ selectsRange
631+ startDate = { startDate }
632+ endDate = { null }
633+ onChange = { onChangeMock }
634+ timeZone = "America/New_York"
635+ showTimeSelect
636+ dateFormat = "yyyy-MM-dd HH:mm"
637+ inline
638+ /> ,
639+ ) ;
640+
641+ // Find and click a time option (legacy single time picker behavior - applies to start date when no end date)
642+ const timeOptions = container . querySelectorAll (
643+ ".react-datepicker__time-list-item" ,
644+ ) ;
645+ if ( timeOptions . length > 0 ) {
646+ fireEvent . click ( timeOptions [ 0 ] ! ) ;
647+ }
648+
649+ // onChange should have been called with timezone conversion
650+ expect ( onChangeMock ) . toHaveBeenCalled ( ) ;
651+ const [ changedStartDate , changedEndDate ] = onChangeMock . mock . calls [ 0 ] [ 0 ] ;
652+
653+ // Start date should be converted, end date should be null
654+ expect ( changedStartDate ) . toBeInstanceOf ( Date ) ;
655+ expect ( changedEndDate ) . toBeNull ( ) ;
656+ } ) ;
615657} ) ;
616658
617659describe ( "Timezone fallback behavior (when date-fns-tz is not installed)" , ( ) => {
0 commit comments