jrshikoku/lib/getTrainDelayStatus.js
2023-07-06 16:47:08 +09:00

19 lines
443 B
JavaScript

export const getTrainDelayStatus = (current, Station_JP) => {
if (!current) return () => {};
const delay = current.delay;
switch (true) {
case delay === "入線":
if (current.Pos === Station_JP) {
return "当駅始発";
} else {
return "発車前";
}
case isNaN(delay):
return delay;
case delay === 0:
return "定刻通り";
default:
return delay + "分遅れ";
}
};