Skip to content

Commit

Permalink
front: fix negative duration at trainrun creation in macro mode
Browse files Browse the repository at this point in the history
Signed-off-by: romainvalls <[email protected]>
  • Loading branch information
RomainValls committed Jan 23, 2025
1 parent 6b8bd15 commit 23a21ce
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ const getTimeLockDate = (
return new Date(startDate.getTime() + offset * 60 * 1000);
};

const formatDateDifference = (start: Date, stop: Date) =>
const formatDateDifferenceFrom = (start: Date, stop: Date) =>
Duration.subtractDate(stop, start).toISOString();

const createTrainSchedulePayload = async ({
Expand Down Expand Up @@ -240,8 +240,9 @@ const createTrainSchedulePayload = async ({

return {
at: `${section.targetNodeId}-${index + 1}`,
arrival: formatDateDifference(arrival, startDate),
stop_for: departure && !isNonStopTransit ? formatDateDifference(departure, arrival) : null,
arrival: formatDateDifferenceFrom(startDate, arrival),
stop_for:
departure && !isNonStopTransit ? formatDateDifferenceFrom(departure, arrival) : null,
};
});

Expand Down

0 comments on commit 23a21ce

Please sign in to comment.