Skip to content

Commit d69d60f

Browse files
committed
front: use the absolute value in useOutputData for lateness
Use the absolute value of the duration between 2 dates to determine whether a train is late or not (this duration should be inferior to 1s). Signed-off-by: Clara Ni <[email protected]>
1 parent 3f5afb8 commit d69d60f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

front/src/modules/timesStops/hooks/useOutputTableData.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type { PathfindingResultSuccess, TrainScheduleResult } from 'common/api/o
1212
import { interpolateValue } from 'modules/simulationResult/SimulationResultExport/utils';
1313
import type { TrainScheduleWithDetails } from 'modules/trainschedule/components/Timetable/types';
1414
import { dateToHHMMSS } from 'utils/date';
15+
import { msToS } from 'utils/physics';
1516
import { calculateTimeDifferenceInSeconds } from 'utils/timeManipulation';
1617

1718
import { ARRIVAL_TIME_ACCEPTABLE_ERROR_MS } from '../consts';
@@ -79,8 +80,8 @@ const useOutputTableData = (
7980
lastReferenceDate = refDate;
8081

8182
const isOnTime = theoreticalArrival
82-
? calculateTimeDifferenceInSeconds(theoreticalArrival, computedArrival) <=
83-
ARRIVAL_TIME_ACCEPTABLE_ERROR_MS / 1000
83+
? Math.abs(calculateTimeDifferenceInSeconds(theoreticalArrival, computedArrival)) <=
84+
msToS(ARRIVAL_TIME_ACCEPTABLE_ERROR_MS)
8485
: false;
8586

8687
return {

0 commit comments

Comments
 (0)