Skip to content

Commit 33bef85

Browse files
committed
front: fix time display, use utc for hour conversion
1 parent d6c3524 commit 33bef85

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { describe, it, expect } from 'vitest';
2+
3+
import formatScheduleData from '../formatScheduleData';
4+
5+
describe('formatScheduleData', () => {
6+
it('should compute simple arrival time in the correct timezone', () => {
7+
const schedule = {
8+
at: 'id325',
9+
arrival: 'PT3600S',
10+
stop_for: 'PT100S',
11+
on_stop_signal: false,
12+
locked: false,
13+
};
14+
const startTime = '2024-05-14T00:00:00Z';
15+
16+
expect(formatScheduleData(schedule, startTime)).toEqual({
17+
arrival: '01:00:00',
18+
departure: '01:01:40',
19+
stopFor: '100',
20+
});
21+
});
22+
});

front/src/utils/timeManipulation.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -97,5 +97,5 @@ export function secToHoursString(sec: number | null, withSeconds = false): TimeS
9797
return '';
9898
}
9999
const format = withSeconds ? '%H:%M:%S' : '%H:%M';
100-
return d3.timeFormat(format)(new Date(sec * 1000));
100+
return d3.utcFormat(format)(new Date(sec * 1000));
101101
}

0 commit comments

Comments
 (0)