File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 119119 ] ,
120120 onClick : ( index , fp ) => {
121121 if ( index === 0 ) {
122- const today = new Date ( ) ;
123- // If there isn't a selected date, then use 12:00 am on the current date.
124- const selectedDate = fp . selectedDates [ 0 ] ?? new Date ( new Date ( ) . toDateString ( ) ) ;
125- selectedDate . setFullYear ( today . getFullYear ( ) ) ;
126- selectedDate . setMonth ( today . getMonth ( ) ) ;
127- selectedDate . setDate ( today . getDate ( ) ) ;
128- fp . setDate ( selectedDate , true ) ;
122+ // The initial date represents 12:00 am on the current date.
123+ const today = new Date ( new Date ( ) . toDateString ( ) ) ;
124+ if ( fp . selectedDates [ 0 ] ) {
125+ today . setHours ( fp . selectedDates [ 0 ] . getHours ( ) ) ;
126+ today . setMinutes ( fp . selectedDates [ 0 ] . getMinutes ( ) ) ;
127+ today . setSeconds ( fp . selectedDates [ 0 ] . getSeconds ( ) ) ;
128+ }
129+ fp . setDate ( today , true ) ;
129130 } else if ( index === 1 ) {
130131 fp . setDate ( new Date ( ) , true ) ;
131132 }
Original file line number Diff line number Diff line change 251251 ] ,
252252 onClick : ( index , fp ) => {
253253 if ( index === 0 ) {
254- const today = new Date ( ) ;
255- // If there isn't a selected date, then use 12:00 am on the current date.
256- const selectedDate = fp . selectedDates [ 0 ] ?? new Date ( new Date ( ) . toDateString ( ) ) ;
257- selectedDate . setFullYear ( today . getFullYear ( ) ) ;
258- selectedDate . setMonth ( today . getMonth ( ) ) ;
259- selectedDate . setDate ( today . getDate ( ) ) ;
260- fp . setDate ( selectedDate ) ;
254+ // The initial date represents 12:00 am on the current date.
255+ const today = new Date ( new Date ( ) . toDateString ( ) ) ;
256+ if ( fp . selectedDates [ 0 ] ) {
257+ today . setHours ( fp . selectedDates [ 0 ] . getHours ( ) ) ;
258+ today . setMinutes ( fp . selectedDates [ 0 ] . getMinutes ( ) ) ;
259+ today . setSeconds ( fp . selectedDates [ 0 ] . getSeconds ( ) ) ;
260+ }
261+ fp . setDate ( today , true ) ;
261262 } else if ( index === 1 ) {
262263 fp . setDate ( new Date ( ) ) ;
263264 }
You can’t perform that action at this time.
0 commit comments