Skip to content

Commit f8bea30

Browse files
committed
update delay calculation
1 parent 31698da commit f8bea30

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/js/map_vehicles.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,13 @@ function generate_vehicle_popup_text(vehicle, cache) {
149149
const scheduled_time_hh_mm = typeof scheduled_time == 'number' ? [(Math.floor(scheduled_time / 60)) % 24, scheduled_time % 60] : null;
150150
const now_mins = (now_hh_mm[0] * 60 + now_hh_mm[1]) % (24 * 60);
151151
const scheduled_mins = scheduled_time_hh_mm ? (scheduled_time_hh_mm[0] * 60 + scheduled_time_hh_mm[1]) % (24 * 60) : null;
152-
const delay = scheduled_mins ? (now_mins - scheduled_mins) % (24 * 60) : null;
152+
let delay = scheduled_mins ? (now_mins - scheduled_mins) % (24 * 60) : null;
153+
if(1000 < delay) {
154+
delay -= 24 * 60;
155+
}
156+
else if(delay < -1000) {
157+
delay += 24 * 60;
158+
}
153159

154160
const delay_class = -1 <= delay && delay <= 3 ? 'text-success' : 'text-danger fw-bold';
155161
const delayText = `${delay > 0 ? '+' : ''}${delay} мин.`;

0 commit comments

Comments
 (0)