Update table display on board page, in preparation for offering different 'table' styles.
This commit is contained in:
@@ -102,3 +102,27 @@ export function calculateDelay(loc: DelayInput): {
|
||||
return { val: `${absDiff}E`, type: 'early' };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Accepts a pair of times (string or Date) and outputs a delay class 'delay-early', 'delay-late' or 'delay-rt'
|
||||
* @param sched Scheduled Time (string, Date)
|
||||
* @param act Actual Time (string, Date)
|
||||
*/
|
||||
export function delayClassFromTimePair(sched: any, act: any): string {
|
||||
if (!sched || !act) return '';
|
||||
|
||||
const s = new Date(sched).getTime();
|
||||
const a = new Date(act).getTime();
|
||||
|
||||
if (isNaN(s) || isNaN(a)) return '';
|
||||
|
||||
const diff = a - s;
|
||||
const oneMinute = 60000;
|
||||
|
||||
// on-time if within one minute
|
||||
if (Math.abs(diff) < oneMinute) {
|
||||
return 'delay-rt';
|
||||
}
|
||||
|
||||
return diff > 0 ? 'delay-late' : 'delay-early';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user