refactor: supprime les getTime() inutiles
parent
88cc76bcce
commit
5aa6974685
|
@ -52,15 +52,13 @@ export function periodOfResistance(
|
|||
if (family.Statut !== "Résistant.e" && family.Statut !== "Ex résistant·e·s") {
|
||||
return null;
|
||||
}
|
||||
if (!family.Integration || family.Integration.getTime() > atDate.getTime()) {
|
||||
if (!family.Integration || family.Integration > atDate) {
|
||||
return null;
|
||||
}
|
||||
return {
|
||||
start: family.Integration,
|
||||
end:
|
||||
family.Sortie !== null && family.Sortie.getTime() < atDate.getTime()
|
||||
? family.Sortie
|
||||
: atDate,
|
||||
family.Sortie !== null && family.Sortie < atDate ? family.Sortie : atDate,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -77,7 +75,7 @@ export function isExResistant(
|
|||
date: Date = new Date(Date.now())
|
||||
): boolean {
|
||||
const por = periodOfResistance(family, date);
|
||||
return por !== null && por.end.getTime() < date.getTime();
|
||||
return por !== null && por.end < date;
|
||||
}
|
||||
|
||||
export function isResistantOverPeriod(
|
||||
|
|
|
@ -39,7 +39,7 @@ function checkFamilyDataConsistency(family: Famille) {
|
|||
issueType: "Ex résistant.e.s without endResistant",
|
||||
});
|
||||
}
|
||||
if (family.Integration!.getTime() > family.Sortie!.getTime()) {
|
||||
if (family.Integration! > family.Sortie!) {
|
||||
consistencyIssues.push({
|
||||
familyId: family.Titre,
|
||||
issueType: "startResistsant > endResistant ",
|
||||
|
|
|
@ -11,20 +11,20 @@ export default function generateConsecutivePeriods({
|
|||
end?: Date;
|
||||
}): Period[] {
|
||||
const periods: Period[] = [];
|
||||
if (start.getTime() < end.getTime()) {
|
||||
if (start < end) {
|
||||
let nextPeriodStart = start;
|
||||
do {
|
||||
const periodStart = nextPeriodStart;
|
||||
nextPeriodStart = incrementStart(periodStart);
|
||||
const periodEnd = addMilliseconds(nextPeriodStart, -1);
|
||||
if (periodEnd.getTime() < periodStart.getTime()) {
|
||||
if (periodEnd < periodStart) {
|
||||
throw new Error("incrementStart call decremented date!!!");
|
||||
}
|
||||
periods.push({
|
||||
start: periodStart,
|
||||
end: periodEnd,
|
||||
});
|
||||
} while (nextPeriodStart.getTime() < end.getTime());
|
||||
} while (nextPeriodStart < end);
|
||||
}
|
||||
return periods;
|
||||
}
|
||||
|
|
|
@ -5,14 +5,8 @@ export function isPeriodContaining(
|
|||
dateOrPeriod: Date | Period
|
||||
): boolean {
|
||||
if (dateOrPeriod instanceof Date) {
|
||||
return (
|
||||
period.start.getTime() <= dateOrPeriod.getTime() &&
|
||||
dateOrPeriod.getTime() <= period.end.getTime()
|
||||
);
|
||||
return period.start <= dateOrPeriod && dateOrPeriod <= period.end;
|
||||
} else {
|
||||
return (
|
||||
period.start.getTime() >= dateOrPeriod.start.getTime() &&
|
||||
dateOrPeriod.end.getTime() <= period.end.getTime()
|
||||
);
|
||||
return period.start >= dateOrPeriod.start && dateOrPeriod.end <= period.end;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue