Notifications corrections
This commit is contained in:
parent
5ac295f3b7
commit
28fe97edd9
@ -99,20 +99,38 @@ export function useTaskNotifications() {
|
|||||||
if (task.dateToFinish) {
|
if (task.dateToFinish) {
|
||||||
const dateStr = task.dateToFinish;
|
const dateStr = task.dateToFinish;
|
||||||
|
|
||||||
console.log('[useTaskNotifications] 📅 Parsing date', {
|
// Leantime dates with 'Z' are actually local time stored as UTC
|
||||||
id: task.id,
|
// We need to extract the time components and create a local date
|
||||||
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
|
|
||||||
if (dateStr.endsWith('Z')) {
|
if (dateStr.endsWith('Z')) {
|
||||||
// Remove Z and parse as local time (Leantime dates with Z are actually local time, not UTC)
|
// Parse as UTC first to get the components, then create local date
|
||||||
const withoutZ = dateStr.slice(0, -1);
|
// Example: "2026-01-16T01:13:00.000Z" -> treat 01:13 as local time, not UTC
|
||||||
notificationDate = new Date(withoutZ);
|
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')) {
|
} else if (dateStr.includes('T')) {
|
||||||
// ISO format without Z - treat as local time
|
// ISO format without Z - treat as local time
|
||||||
notificationDate = new Date(dateStr);
|
notificationDate = new Date(dateStr);
|
||||||
@ -125,13 +143,13 @@ export function useTaskNotifications() {
|
|||||||
notificationDate = new Date(dateStr);
|
notificationDate = new Date(dateStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[useTaskNotifications] 📅 Parsed date', {
|
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
||||||
id: task.id,
|
console.error('[useTaskNotifications] ❌ Invalid date', {
|
||||||
rawDate: dateStr,
|
id: task.id,
|
||||||
parsedDate: notificationDate.toISOString(),
|
rawDate: dateStr,
|
||||||
localDate: notificationDate.toLocaleString('fr-FR'),
|
});
|
||||||
isValid: !isNaN(notificationDate.getTime()),
|
return false;
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
if (!notificationDate || isNaN(notificationDate.getTime())) {
|
||||||
@ -154,8 +172,11 @@ export function useTaskNotifications() {
|
|||||||
id: task.id,
|
id: task.id,
|
||||||
title: task.headline,
|
title: task.headline,
|
||||||
source: task.source,
|
source: task.source,
|
||||||
notificationDate: notificationDate.toISOString(),
|
rawDate: task.dateToFinish,
|
||||||
now: now.toISOString(),
|
notificationDateLocal: notificationDate.toLocaleString('fr-FR'),
|
||||||
|
notificationDateISO: notificationDate.toISOString(),
|
||||||
|
nowLocal: now.toLocaleString('fr-FR'),
|
||||||
|
nowISO: now.toISOString(),
|
||||||
timeUntilNotificationMinutes,
|
timeUntilNotificationMinutes,
|
||||||
timeUntilNotificationSeconds,
|
timeUntilNotificationSeconds,
|
||||||
inWindow: inNotificationWindow,
|
inWindow: inNotificationWindow,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user