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