From 0a3d4e2960c5c16616f16c9c71e884b7f4c7f999 Mon Sep 17 00:00:00 2001 From: Matthieu Haineault Date: Tue, 4 Nov 2025 14:50:07 -0500 Subject: [PATCH] fix(shifts): changed date format to UTC --- .../time-tracker/shifts/services/shifts-upsert.service.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service.ts b/src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service.ts index 46e89b9..74c441d 100644 --- a/src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service.ts +++ b/src/time-and-attendance/time-tracker/shifts/services/shifts-upsert.service.ts @@ -71,7 +71,7 @@ export class ShiftsUpsertService { const regroup_by_date = new Map(); ok_items.forEach(({ index, normed, timesheet_id }) => { - const day = new Date(normed.date.getFullYear(), normed.date.getMonth(), normed.date.getDate()).getTime(); + const day = new Date(normed.date.getUTCFullYear(), normed.date.getUTCMonth(), normed.date.getUTCDate()).getTime(); const key = `${timesheet_id}|${day}`; if (!regroup_by_date.has(key)) regroup_by_date.set(key, []); regroup_by_date.get(key)!.push(index); @@ -150,7 +150,7 @@ export class ShiftsUpsertService { for (const item of ok_items) { const { index, dto, normed, timesheet_id } = item; - const day_key = new Date(normed.date.getFullYear(), normed.date.getMonth(), normed.date.getDate()).getTime(); + const day_key = new Date(normed.date.getUTCFullYear(), normed.date.getUTCMonth(), normed.date.getUTCDate()).getTime(); const map_key = `${timesheet_id}|${day_key}`; let existing = existing_map.get(map_key); if (!existing) { @@ -293,7 +293,7 @@ export class ShiftsUpsertService { const groups = new Map(); function key(timesheet: number, d: Date) { - const day_date = new Date(d.getFullYear(), d.getMonth(), d.getDate()); + const day_date = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()); return `${timesheet}|${day_date.getTime()}`; } @@ -304,7 +304,7 @@ export class ShiftsUpsertService { } for (const group of unique_pairs.values()) { - const day_date = new Date(group.date.getFullYear(), group.date.getMonth(), group.date.getDate()); + const day_date = new Date(group.date.getUTCFullYear(), group.date.getUTCMonth(), group.date.getUTCDate()); const existing = await tx.shifts.findMany({ where: { timesheet_id: group.timesheet_id, date: day_date }, select: { id: true, start_time: true, end_time: true },