@@ -13,6 +13,7 @@ import drawMarks from './drawMarks';
1313import drawEvents from './drawEvents' ;
1414
1515import { useLocalStorage } from '/src/hooks' ;
16+ import { dateToDateString } from '/src/utils' ;
1617
1718const CalendarCanvas = styled . canvas `
1819 background-color: #24202e;
@@ -91,7 +92,7 @@ const Calendar = ({
9192 return { x, y } ;
9293 } ;
9394
94- const eventAtPos = ( ) => {
95+ const eventAtPos = useCallback ( ( ) => {
9596 if ( ! cursorTime . current ) return null ;
9697 const currentTs = cursorTime . current . getTime ( ) / 1000 ;
9798
@@ -127,7 +128,7 @@ const Calendar = ({
127128 }
128129 // no valid event under the cursor
129130 return null ;
130- } ;
131+ } , [ events , dayStartOffsetSeconds ] ) ;
131132
132133 // Update drawParams reference
133134
@@ -139,6 +140,7 @@ const Calendar = ({
139140 drawParams . current . pos2time = pos2time ;
140141 drawParams . current . time2pos = time2pos ;
141142 drawParams . current . startTime = startTime ;
143+ //eslint-disable-next-line react-hooks/exhaustive-deps
142144 } , [ drawParams . current , dayRef . current , zoom , startTime ] ) ;
143145
144146 //
@@ -204,6 +206,7 @@ const Calendar = ({
204206
205207 useEffect ( ( ) => {
206208 drawCalendar ( ) ;
209+ //eslint-disable-next-line react-hooks/exhaustive-deps
207210 } , [ cursorTime . current , events ] ) ;
208211
209212 // Event handlers
@@ -256,7 +259,8 @@ const Calendar = ({
256259 const basePath = '/mam/rundown' ;
257260 const searchParams = new URLSearchParams ( location . search ) ;
258261 const startTs = event . start - dayStartOffsetSeconds ;
259- const targetDate = new Date ( startTs * 1000 ) . toISOString ( ) . slice ( 0 , 10 ) ;
262+ const localDateTime = new Date ( startTs * 1000 ) ;
263+ const targetDate = dateToDateString ( localDateTime ) ;
260264 searchParams . set ( 'date' , targetDate ) ;
261265 const hash = `#${ event . id } ` ;
262266 const fullPath = `${ basePath } ?${ searchParams . toString ( ) } ${ hash } ` ;
@@ -330,6 +334,7 @@ const Calendar = ({
330334 calendarRef . current . removeEventListener ( 'mousemove' , onMouseMove ) ;
331335 document . removeEventListener ( 'mouseup' , onMouseUp ) ;
332336 } ;
337+ //eslint-disable-next-line react-hooks/exhaustive-deps
333338 } , [ calendarRef . current , startTime ] ) ;
334339
335340 //
@@ -408,7 +413,7 @@ const Calendar = ({
408413 const dayStartTs = weekStartTs + i * 24 * 3600 ;
409414 // get date in YYYY-MM-DD format
410415 const jsDate = new Date ( dayStartTs * 1000 ) ;
411- const date = jsDate . toISOString ( ) . slice ( 0 , 10 ) ;
416+ const date = dateToDateString ( jsDate ) ;
412417 const dayName = jsDate . toLocaleDateString ( nebula . locale , {
413418 day : 'numeric' ,
414419 month : 'short' ,
@@ -433,12 +438,12 @@ const Calendar = ({
433438 } ) ;
434439 }
435440 return dayStyles ;
436- } , [ startTime ] ) ;
441+ } , [ startTime , dayStartOffsetSeconds ] ) ;
437442
438443 // yes. this is very ugly, but i need that reference to one day
439444 // to get its width
440445 return (
441- < CalendarWrapper scrollbarWidth = { scrollbarWidth } clockWidth = { CLOCK_WIDTH } >
446+ < CalendarWrapper scrollbarwidth = { scrollbarWidth } clockwidth = { CLOCK_WIDTH } >
442447 < div className = "calendar-header" >
443448 { dstyles . map ( ( d , i ) => {
444449 const r = i === 0 ? dayRef : null ;
0 commit comments