fix(shifts): changed date format to UTC
This commit is contained in:
parent
457757a066
commit
0a3d4e2960
|
|
@ -71,7 +71,7 @@ export class ShiftsUpsertService {
|
||||||
|
|
||||||
const regroup_by_date = new Map<string, number[]>();
|
const regroup_by_date = new Map<string, number[]>();
|
||||||
ok_items.forEach(({ index, normed, timesheet_id }) => {
|
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}`;
|
const key = `${timesheet_id}|${day}`;
|
||||||
if (!regroup_by_date.has(key)) regroup_by_date.set(key, []);
|
if (!regroup_by_date.has(key)) regroup_by_date.set(key, []);
|
||||||
regroup_by_date.get(key)!.push(index);
|
regroup_by_date.get(key)!.push(index);
|
||||||
|
|
@ -150,7 +150,7 @@ export class ShiftsUpsertService {
|
||||||
|
|
||||||
for (const item of ok_items) {
|
for (const item of ok_items) {
|
||||||
const { index, dto, normed, timesheet_id } = item;
|
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}`;
|
const map_key = `${timesheet_id}|${day_key}`;
|
||||||
let existing = existing_map.get(map_key);
|
let existing = existing_map.get(map_key);
|
||||||
if (!existing) {
|
if (!existing) {
|
||||||
|
|
@ -293,7 +293,7 @@ export class ShiftsUpsertService {
|
||||||
|
|
||||||
const groups = new Map<string, { existing: { start: Date; end: Date; id: number }[], incoming: typeof planned_updates }>();
|
const groups = new Map<string, { existing: { start: Date; end: Date; id: number }[], incoming: typeof planned_updates }>();
|
||||||
function key(timesheet: number, d: Date) {
|
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()}`;
|
return `${timesheet}|${day_date.getTime()}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -304,7 +304,7 @@ export class ShiftsUpsertService {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const group of unique_pairs.values()) {
|
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({
|
const existing = await tx.shifts.findMany({
|
||||||
where: { timesheet_id: group.timesheet_id, date: day_date },
|
where: { timesheet_id: group.timesheet_id, date: day_date },
|
||||||
select: { id: true, start_time: true, end_time: true },
|
select: { id: true, start_time: true, end_time: true },
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user