Notifications corrections
This commit is contained in:
parent
5ac295f3b7
commit
28fe97edd9
@ -99,20 +99,38 @@ export function useTaskNotifications() {
|
||||
if (task.dateToFinish) {
|
||||
const dateStr = task.dateToFinish;
|
||||
|
||||
console.log('[useTaskNotifications] 📅 Parsing date', {
|
||||
id: task.id,
|
||||
title: task.headline,
|
||||
source: task.source,
|
||||
rawDate: dateStr,
|
||||
dateFormat: dateStr.includes('T') ? 'ISO' : dateStr.includes(' ') ? 'MySQL' : 'unknown',
|
||||
});
|
||||
|
||||
// Leantime dates are often in format with 'Z' (UTC marker) but actually represent local time
|
||||
// We need to parse them correctly. If it ends with Z, remove it and treat as local time
|
||||
// Leantime dates with 'Z' are actually local time stored as UTC
|
||||
// We need to extract the time components and create a local date
|
||||
if (dateStr.endsWith('Z')) {
|
||||
// Remove Z and parse as local time (Leantime dates with Z are actually local time, not UTC)
|
||||
const withoutZ = dateStr.slice(0, -1);
|
||||
notificationDate = new Date(withoutZ);
|
||||
// Parse as UTC first to get the components, then create local date
|
||||
// Example: "2026-01-16T01:13:00.000Z" -> treat 01:13 as local time, not UTC
|
||||
const utcDate = new Date(dateStr);
|
||||
// Extract components from UTC date and create local date
|
||||
// This assumes the UTC date actually represents local time
|
||||
notificationDate = new Date(
|
||||
utcDate.getUTCFullYear(),
|
||||
utcDate.getUTCMonth(),
|
||||
utcDate.getUTCDate(),
|
||||
utcDate.getUTCHours(),
|
||||
utcDate.getUTCMinutes(),
|
||||
utcDate.getUTCSeconds(),
|
||||
utcDate.getUTCMilliseconds()
|
||||
);
|
||||
|
||||
console.log('[useTaskNotifications] 📅 Parsing Leantime date (Z -> local)', {
|
||||
id: task.id,
|
||||
title: task.headline,
|
||||
rawDate: dateStr,
|
||||
utcComponents: {
|
||||
year: utcDate.getUTCFullYear(),
|
||||
month: utcDate.getUTCMonth(),
|
||||
day: utcDate.getUTCDate(),
|
||||
hour: utcDate.getUTCHours(),
|
||||
minute: utcDate.getUTCMinutes(),
|
||||
},
|
||||
localDate: notificationDate.toLocaleString('fr-FR'),
|
||||
localISO: notificationDate.toISOString(),
|
||||
});
|
||||
} else if (dateStr.includes('T')) {
|
||||
// ISO format without Z - treat as local time
|
||||
notificationDate = new Date(dateStr);
|
||||
@ -125,13 +143,13 @@ export function useTaskNotifications() {
|
||||
notificationDate = new Date(dateStr);
|
||||
}
|
||||
|
||||
console.log('[useTaskNotifications] 📅 Parsed date', {
|
||||
id: task.id,
|
||||
rawDate: dateStr,
|
||||
parsedDate: notificationDate.toISOString(),
|
||||
localDate: notificationDate.toLocaleString('fr-FR'),
|
||||
isValid: !isNaN(notificationDate.getTime()),
|
||||
});
|
||||
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
||||
console.error('[useTaskNotifications] ❌ Invalid date', {
|
||||
id: task.id,
|
||||
rawDate: dateStr,
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
||||
@ -154,8 +172,11 @@ export function useTaskNotifications() {
|
||||
id: task.id,
|
||||
title: task.headline,
|
||||
source: task.source,
|
||||
notificationDate: notificationDate.toISOString(),
|
||||
now: now.toISOString(),
|
||||
rawDate: task.dateToFinish,
|
||||
notificationDateLocal: notificationDate.toLocaleString('fr-FR'),
|
||||
notificationDateISO: notificationDate.toISOString(),
|
||||
nowLocal: now.toLocaleString('fr-FR'),
|
||||
nowISO: now.toISOString(),
|
||||
timeUntilNotificationMinutes,
|
||||
timeUntilNotificationSeconds,
|
||||
inWindow: inNotificationWindow,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user