StaffLDB-Minify #1

Merged
fred.boniface merged 27 commits from StaffLDB-Minify into main 2023-10-03 21:37:00 +01:00
Showing only changes of commit ef7d965523 - Show all commits

View File

@ -37,47 +37,20 @@
platArr.push('nonPass'); platArr.push('nonPass');
} }
if (service.sta !== undefined) { function checkLateEarly(originalTime: Date | undefined, comparedTime: Date | undefined, arr: string[]) {
if (service.eta !== undefined) { if (originalTime !== undefined && comparedTime instanceof Date) {
if (service.sta < service.eta) { if (originalTime < comparedTime) {
arrArr.push('late'); arr.push('late');
} } else if (originalTime > comparedTime) {
} else if (service.ata !== undefined) { arr.push('early');
if (service.sta < service.ata) {
arrArr.push('late');
}
}
if (service.eta !== undefined) {
if (service.sta > service.eta) {
arrArr.push('early');
}
} else if (service.ata !== undefined) {
if (service.sta > service.ata) {
arrArr.push('early');
} }
} }
} }
if (service.std !== undefined) { checkLateEarly(service.sta, service.eta, arrArr);
if (service.etd !== undefined) { checkLateEarly(service.sta, service.ata, arrArr);
if (service.std < service.etd) { checkLateEarly(service.std, service.etd, depArr);
depArr.push('late'); checkLateEarly(service.std, service.atd, depArr);
}
} else if (service.atd !== undefined) {
if (service.std < service.atd) {
depArr.push('late');
}
}
if (service.etd !== undefined) {
if (service.std > service.etd) {
depArr.push('early');
}
} else if (service.atd !== undefined) {
if (service.std > service.atd) {
depArr.push('early');
}
}
}
return { return {
other: otherArr.join(' '), other: otherArr.join(' '),
@ -88,7 +61,7 @@
} }
function fmtTime(date: Date | string | undefined): string | false { function fmtTime(date: Date | string | undefined): string | false {
if (date === 'RT' || date === "CANC" || date === "LATE") return date; if (typeof date === 'string') return date;
if (date instanceof Date) { if (date instanceof Date) {
const hours = date.getHours().toString().padStart(2, '0'); const hours = date.getHours().toString().padStart(2, '0');
const minutes = date.getMinutes().toString().padStart(2, '0'); const minutes = date.getMinutes().toString().padStart(2, '0');