fix: timezone conversion dayOffset month-boundary bug and overnight endDayIdx calculation

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-02 19:39:53 -05:00
parent 0fb0a82936
commit a480c56a54
2 changed files with 11 additions and 10 deletions

View File

@@ -140,15 +140,10 @@ function computeShowPlacement(
let startMin = convertedStart.hour * 60 + convertedStart.minute;
let endMin = convertedEnd.hour * 60 + convertedEnd.minute;
const endDayIdx = (sourceDayIdx + convertedEnd.dayOffset + 7) % 7;
if (isOvernightSource || endDayIdx !== displayDayIdx || endMin <= startMin) {
if (endDayIdx === displayDayIdx && endMin <= startMin) {
const endBaseDayIdx = isOvernightSource ? sourceDayIdx + 1 : sourceDayIdx;
const endDayIdx = (endBaseDayIdx + convertedEnd.dayOffset + 7) % 7;
if (endDayIdx !== displayDayIdx || endMin <= startMin) {
endMin += 24 * 60;
} else if (endDayIdx !== displayDayIdx) {
endMin += 24 * 60;
} else if (isOvernightSource) {
endMin += 24 * 60;
}
}
const startDisplay = formatTime12(convertedStart.hour, convertedStart.minute);

View File

@@ -60,11 +60,17 @@ export function convertTime(
const toHour = parseInt(toParts.find((p) => p.type === "hour")!.value);
const toMin = parseInt(toParts.find((p) => p.type === "minute")!.value);
const toDay = parseInt(toParts.find((p) => p.type === "day")!.value);
const toMonth = parseInt(toParts.find((p) => p.type === "month")!.value);
const toYear = parseInt(toParts.find((p) => p.type === "year")!.value);
const fromCorrectedParts = fromFormatter.formatToParts(correctedUtc);
const fromDay = parseInt(fromCorrectedParts.find((p) => p.type === "day")!.value);
const fromMonth = parseInt(fromCorrectedParts.find((p) => p.type === "month")!.value);
const fromYear = parseInt(fromCorrectedParts.find((p) => p.type === "year")!.value);
const dayOffset = toDay - fromDay;
const fromDate = Date.UTC(fromYear, fromMonth - 1, fromDay);
const toDate = Date.UTC(toYear, toMonth - 1, toDay);
const dayOffset = Math.round((toDate - fromDate) / (24 * 60 * 60 * 1000));
return { hour: toHour === 24 ? 0 : toHour, minute: toMin, dayOffset };
}