mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-13 05:07:43 +02:00
Events scheduled for today were appearing in tomorrow's column due to raw millisecond arithmetic not handling timezone transitions properly. Changes: - Replace MILLISECONDS_IN_DAY * day arithmetic with Date.setDate() - Fix mutation bug where date parameter was being modified - Use proper calendar day arithmetic that handles DST/timezone Tested in Brisbane timezone (GMT+10) - events now display in correct column. Signed-off-by: Dominic O'Carroll <99632940+domocarroll@users.noreply.github.com> Co-authored-by: Dom Carroll <dom@subfrac.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Dom Carroll
Claude Opus 4.5
parent
0a9c3806bc
commit
b27b511e7a
@@ -106,9 +106,12 @@
|
||||
): CalendarItem[] => {
|
||||
const result: CalendarItem[] = []
|
||||
for (let day = 0; day < days; day++) {
|
||||
const startDay = new Date(MILLISECONDS_IN_DAY * day + date.getTime()).setHours(0, 0, 0, 0)
|
||||
const startDate = new Date(MILLISECONDS_IN_DAY * day + date.getTime()).setHours(startHour, 0, 0, 0)
|
||||
const lastDate = new Date(MILLISECONDS_IN_DAY * day + date.getTime()).setHours(endHour, 0, 0, 0)
|
||||
// Use setDate() for proper day arithmetic that handles timezone transitions
|
||||
const targetDay = new Date(date)
|
||||
targetDay.setDate(targetDay.getDate() + day)
|
||||
const startDay = new Date(targetDay).setHours(0, 0, 0, 0)
|
||||
const startDate = new Date(targetDay).setHours(startHour, 0, 0, 0)
|
||||
const lastDate = new Date(targetDay).setHours(endHour, 0, 0, 0)
|
||||
events.forEach((event) => {
|
||||
const eventStart = event.allDay ? event.date + offsetTZ : event.date
|
||||
const eventEnd = event.allDay ? event.dueDate + offsetTZ : event.dueDate
|
||||
@@ -125,8 +128,11 @@
|
||||
}
|
||||
})
|
||||
}
|
||||
const sd = date.setHours(0, 0, 0, 0)
|
||||
const ld = new Date(MILLISECONDS_IN_DAY * (days - 1) + date.getTime()).setHours(23, 59, 59, 999)
|
||||
// Fix: Don't mutate the date parameter, use setDate() for proper day arithmetic
|
||||
const sd = new Date(date).setHours(0, 0, 0, 0)
|
||||
const lastDayDate = new Date(date)
|
||||
lastDayDate.setDate(lastDayDate.getDate() + days - 1)
|
||||
const ld = new Date(lastDayDate).setHours(23, 59, 59, 999)
|
||||
events
|
||||
.filter((ev) => ev.allDay)
|
||||
.sort((a, b) => b.dueDate - b.date - (a.dueDate - a.date))
|
||||
|
||||
Reference in New Issue
Block a user