Soon fixing timeone in wakeup plot

This commit is contained in:
2026-05-27 17:58:22 +02:00
parent 3e8a2092cd
commit fb709b4a2c
8 changed files with 340 additions and 45 deletions
+14 -17
View File
@@ -28,25 +28,22 @@ const WakeupPlot: React.FC<WakeupBedtimeProps> = ({ from_date, to_date, wakeup_r
return;
}
const data = wakeupBedtime.days.map((day) => {
const daysAgo = Math.floor(
(new Date(getToday()).getTime() - new Date(day.date).getTime()) / (1000 * 60 * 60 * 24)
);
const data = wakeupBedtime.days.map((day) => {
const daysAgo = Math.floor(
(new Date(getToday()).getTime() - new Date(day.date).getTime()) / (1000 * 60 * 60 * 24)
);
let offsetFromRef = 0;
if (day.wakeup_minutes !== null) {
offsetFromRef = getLocalOffsetFromReference(day.wakeup_minutes, wakeup_ref);
}
const offsetFromRef = day.wakeup_minutes ?? 0;
return {
date: daysAgo === 0 ? 'Today' : `${daysAgo}d ago`,
minutes: offsetFromRef,
time:
day.wakeup_minutes !== null
? formatMinutesAfter(offsetFromRef, wakeup_ref)
: 'N/A',
};
}).reverse();
return {
date: daysAgo === 0 ? 'Today' : `${daysAgo}d ago`,
minutes: offsetFromRef,
time:
day.wakeup_minutes !== null
? formatMinutesAfter(offsetFromRef, wakeup_ref)
: 'N/A',
};
}).reverse();
setChartData(data);
}, [wakeupBedtime, wakeup_ref]);