minotor 2.0.1 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,9 +1,9 @@
1
1
  import { Duration } from './duration.js';
2
2
  /**
3
- * A class representing a time in hours, minutes, and seconds.
3
+ * A class representing a time as minutes since midnight.
4
4
  */
5
5
  export declare class Time {
6
- private secondsSinceMidnight;
6
+ private minutesSinceMidnight;
7
7
  /**
8
8
  * Gets the infinity time as a Time instance.
9
9
  * This represents a time that is conceptually beyond any real possible time.
@@ -14,19 +14,20 @@ export declare class Time {
14
14
  /**
15
15
  * Gets the midnight time as a Time instance.
16
16
  *
17
- * @returns A Time instance representing midnight (00:00:00).
17
+ * @returns A Time instance representing midnight.
18
18
  */
19
19
  static origin(): Time;
20
20
  private constructor();
21
21
  /**
22
- * Creates a Time instance from the number of seconds since midnight.
22
+ * Creates a Time instance from the number of minutes since midnight.
23
23
  *
24
- * @param seconds - The number of seconds since midnight.
24
+ * @param minutes - The number of minutes since midnight.
25
25
  * @returns A Time instance representing the specified time.
26
26
  */
27
- static fromSeconds(seconds: number): Time;
27
+ static fromMinutes(minutes: number): Time;
28
28
  /**
29
29
  * Creates a Time instance from hours, minutes, and seconds.
30
+ * Rounds to the closest minute as times are represented in minutes from midnight.
30
31
  *
31
32
  * @param hours - The hours component of the time.
32
33
  * @param minutes - The minutes component of the time.
@@ -34,6 +35,14 @@ export declare class Time {
34
35
  * @returns A Time instance representing the specified time.
35
36
  */
36
37
  static fromHMS(hours: number, minutes: number, seconds: number): Time;
38
+ /**
39
+ * Creates a Time instance from hours, minutes.
40
+ *
41
+ * @param hours - The hours component of the time.
42
+ * @param minutes - The minutes component of the time.
43
+ * @returns A Time instance representing the specified time.
44
+ */
45
+ static fromHM(hours: number, minutes: number): Time;
37
46
  /**
38
47
  * Parses a JavaScript Date object and creates a Time instance.
39
48
  *
@@ -55,11 +64,11 @@ export declare class Time {
55
64
  */
56
65
  toString(): string;
57
66
  /**
58
- * Gets the time as the number of seconds since midnight.
67
+ * Converts the Time instance to the total number of minutes since midnight, rounded to the closest minute.
59
68
  *
60
- * @returns The time in seconds since midnight.
69
+ * @returns The time in minutes since midnight.
61
70
  */
62
- toSeconds(): number;
71
+ toMinutes(): number;
63
72
  /**
64
73
  * Adds a Duration to the current Time instance and returns a new Time instance.
65
74
  *
@@ -9,10 +9,10 @@ export declare const MUST_COORDINATE_WITH_DRIVER = 3;
9
9
  export type PickUpDropOffType = 0 | 1 | 2 | 3;
10
10
  export type Route = {
11
11
  /**
12
- * Arrivals and departures encoded as a binary array.
12
+ * Arrivals and departures encoded as minutes from midnight.
13
13
  * Format: [arrival1, departure1, arrival2, departure2, etc.]
14
14
  */
15
- stopTimes: Uint32Array;
15
+ stopTimes: Uint16Array;
16
16
  /**
17
17
  * PickUp and DropOff types represented as a binary Uint8Array.
18
18
  * Values:
@@ -62,7 +62,7 @@ export type ServiceRoute = {
62
62
  export type ServiceRoutesMap = Map<ServiceRouteId, ServiceRoute>;
63
63
  type TripIndex = number;
64
64
  export declare const ALL_TRANSPORT_MODES: RouteType[];
65
- export declare const CURRENT_VERSION = "0.0.2";
65
+ export declare const CURRENT_VERSION = "0.0.3";
66
66
  /**
67
67
  * The internal transit timetable format
68
68
  * reuses some GTFS concepts for the sake of simplicity for now.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "minotor",
3
- "version": "2.0.1",
3
+ "version": "3.0.0",
4
4
  "description": "A lightweight client-side transit routing library.",
5
5
  "keywords": [
6
6
  "minotor",
@@ -44,10 +44,10 @@ describe('GTFS parser', () => {
44
44
  ]);
45
45
  assert.strictEqual(route.stopTimes.length, 4);
46
46
  assert.strictEqual(route.pickUpDropOffTypes.length, 4);
47
- assert.strictEqual(route.stopTimes[0], Time.fromHMS(8, 0, 0).toSeconds());
48
- assert.strictEqual(route.stopTimes[1], Time.fromHMS(8, 0, 0).toSeconds());
49
- assert.strictEqual(route.stopTimes[2], Time.fromHMS(8, 10, 0).toSeconds());
50
- assert.strictEqual(route.stopTimes[3], Time.fromHMS(8, 15, 0).toSeconds());
47
+ assert.strictEqual(route.stopTimes[0], Time.fromHMS(8, 0, 0).toMinutes());
48
+ assert.strictEqual(route.stopTimes[1], Time.fromHMS(8, 0, 0).toMinutes());
49
+ assert.strictEqual(route.stopTimes[2], Time.fromHMS(8, 10, 0).toMinutes());
50
+ assert.strictEqual(route.stopTimes[3], Time.fromHMS(8, 15, 0).toMinutes());
51
51
 
52
52
  const routes = timetable.getRoutesThroughStop(furCreekResId);
53
53
  assert.strictEqual(routes.length, 2);
@@ -16,10 +16,10 @@ describe('Date converter', () => {
16
16
 
17
17
  describe('Time converter', () => {
18
18
  it('should convert a valid service time to numerical format', () => {
19
- assert.equal(toTime('10:23:54').toSeconds(), 37434);
19
+ assert.equal(toTime('10:23:00').toMinutes(), 623);
20
20
  });
21
21
  it('should convert a valid service time after midnight to numerical format', () => {
22
- assert.equal(toTime('25:13:31').toSeconds(), 90811);
22
+ assert.equal(toTime('25:13:00').toMinutes(), 1513);
23
23
  });
24
24
  it('should throw when trying to convert an invalid time', () => {
25
25
  assert.throws(() => toTime('2513:31'));
@@ -31,7 +31,7 @@ describe('buildStopsAdjacencyStructure', () => {
31
31
  [0, 0],
32
32
  [1, 1],
33
33
  ]),
34
- stopTimes: new Uint32Array(),
34
+ stopTimes: new Uint16Array(),
35
35
  pickUpDropOffTypes: new Uint8Array(),
36
36
  },
37
37
  ],
@@ -69,7 +69,7 @@ describe('buildStopsAdjacencyStructure', () => {
69
69
  [0, 0],
70
70
  [1, 1],
71
71
  ]),
72
- stopTimes: new Uint32Array(),
72
+ stopTimes: new Uint16Array(),
73
73
  pickUpDropOffTypes: new Uint8Array(),
74
74
  },
75
75
  ],
@@ -229,11 +229,11 @@ describe('GTFS stop times parser', () => {
229
229
  [0, 0],
230
230
  [1, 1],
231
231
  ]),
232
- stopTimes: new Uint32Array([
233
- Time.fromHMS(8, 0, 0).toSeconds(),
234
- Time.fromHMS(8, 5, 0).toSeconds(),
235
- Time.fromHMS(8, 10, 0).toSeconds(),
236
- Time.fromHMS(8, 15, 0).toSeconds(),
232
+ stopTimes: new Uint16Array([
233
+ Time.fromHMS(8, 0, 0).toMinutes(),
234
+ Time.fromHMS(8, 5, 0).toMinutes(),
235
+ Time.fromHMS(8, 10, 0).toMinutes(),
236
+ Time.fromHMS(8, 15, 0).toMinutes(),
237
237
  ]),
238
238
  pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0]),
239
239
  },
@@ -299,15 +299,15 @@ describe('GTFS stop times parser', () => {
299
299
  [0, 0],
300
300
  [1, 1],
301
301
  ]),
302
- stopTimes: new Uint32Array([
303
- Time.fromHMS(8, 0, 0).toSeconds(),
304
- Time.fromHMS(8, 5, 0).toSeconds(),
305
- Time.fromHMS(8, 10, 0).toSeconds(),
306
- Time.fromHMS(8, 15, 0).toSeconds(),
307
- Time.fromHMS(9, 0, 0).toSeconds(),
308
- Time.fromHMS(9, 5, 0).toSeconds(),
309
- Time.fromHMS(9, 10, 0).toSeconds(),
310
- Time.fromHMS(9, 15, 0).toSeconds(),
302
+ stopTimes: new Uint16Array([
303
+ Time.fromHMS(8, 0, 0).toMinutes(),
304
+ Time.fromHMS(8, 5, 0).toMinutes(),
305
+ Time.fromHMS(8, 10, 0).toMinutes(),
306
+ Time.fromHMS(8, 15, 0).toMinutes(),
307
+ Time.fromHMS(9, 0, 0).toMinutes(),
308
+ Time.fromHMS(9, 5, 0).toMinutes(),
309
+ Time.fromHMS(9, 10, 0).toMinutes(),
310
+ Time.fromHMS(9, 15, 0).toMinutes(),
311
311
  ]),
312
312
  pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]),
313
313
  },
@@ -373,15 +373,15 @@ describe('GTFS stop times parser', () => {
373
373
  [0, 0],
374
374
  [1, 1],
375
375
  ]),
376
- stopTimes: new Uint32Array([
377
- Time.fromHMS(8, 0, 0).toSeconds(),
378
- Time.fromHMS(8, 5, 0).toSeconds(),
379
- Time.fromHMS(8, 10, 0).toSeconds(),
380
- Time.fromHMS(8, 15, 0).toSeconds(),
381
- Time.fromHMS(9, 0, 0).toSeconds(),
382
- Time.fromHMS(9, 5, 0).toSeconds(),
383
- Time.fromHMS(9, 10, 0).toSeconds(),
384
- Time.fromHMS(9, 15, 0).toSeconds(),
376
+ stopTimes: new Uint16Array([
377
+ Time.fromHMS(8, 0, 0).toMinutes(),
378
+ Time.fromHMS(8, 5, 0).toMinutes(),
379
+ Time.fromHMS(8, 10, 0).toMinutes(),
380
+ Time.fromHMS(8, 15, 0).toMinutes(),
381
+ Time.fromHMS(9, 0, 0).toMinutes(),
382
+ Time.fromHMS(9, 5, 0).toMinutes(),
383
+ Time.fromHMS(9, 10, 0).toMinutes(),
384
+ Time.fromHMS(9, 15, 0).toMinutes(),
385
385
  ]),
386
386
  pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0]),
387
387
  },
@@ -446,11 +446,11 @@ describe('GTFS stop times parser', () => {
446
446
  [0, 0],
447
447
  [1, 1],
448
448
  ]),
449
- stopTimes: new Uint32Array([
450
- Time.fromHMS(8, 0, 0).toSeconds(),
451
- Time.fromHMS(8, 5, 0).toSeconds(),
452
- Time.fromHMS(8, 10, 0).toSeconds(),
453
- Time.fromHMS(8, 15, 0).toSeconds(),
449
+ stopTimes: new Uint16Array([
450
+ Time.fromHMS(8, 0, 0).toMinutes(),
451
+ Time.fromHMS(8, 5, 0).toMinutes(),
452
+ Time.fromHMS(8, 10, 0).toMinutes(),
453
+ Time.fromHMS(8, 15, 0).toMinutes(),
454
454
  ]),
455
455
  pickUpDropOffTypes: new Uint8Array([0, 0, 0, 0]),
456
456
  },
@@ -461,9 +461,9 @@ describe('GTFS stop times parser', () => {
461
461
  serviceRouteId: 'routeA',
462
462
  stops: new Uint32Array([0]),
463
463
  stopIndices: new Map([[0, 0]]),
464
- stopTimes: new Uint32Array([
465
- Time.fromHMS(9, 0, 0).toSeconds(),
466
- Time.fromHMS(9, 15, 0).toSeconds(),
464
+ stopTimes: new Uint16Array([
465
+ Time.fromHMS(9, 0, 0).toMinutes(),
466
+ Time.fromHMS(9, 15, 0).toMinutes(),
467
467
  ]),
468
468
  pickUpDropOffTypes: new Uint8Array([0, 0]),
469
469
  },
@@ -521,9 +521,9 @@ describe('GTFS stop times parser', () => {
521
521
  serviceRouteId: 'routeA',
522
522
  stops: new Uint32Array([0]),
523
523
  stopIndices: new Map([[0, 0]]),
524
- stopTimes: new Uint32Array([
525
- Time.fromHMS(8, 0, 0).toSeconds(),
526
- Time.fromHMS(8, 5, 0).toSeconds(),
524
+ stopTimes: new Uint16Array([
525
+ Time.fromHMS(8, 0, 0).toMinutes(),
526
+ Time.fromHMS(8, 5, 0).toMinutes(),
527
527
  ]),
528
528
  pickUpDropOffTypes: new Uint8Array([0, 0]),
529
529
  },
package/src/gtfs/trips.ts CHANGED
@@ -137,7 +137,7 @@ export const parseStopTimes = async (
137
137
  if (!route) {
138
138
  const stopsCount = stops.length;
139
139
  const stopsArray = new Uint32Array(stops);
140
- const stopTimesArray = new Uint32Array(stopsCount * 2);
140
+ const stopTimesArray = new Uint16Array(stopsCount * 2);
141
141
  for (let i = 0; i < stopsCount; i++) {
142
142
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
143
143
  stopTimesArray[i * 2] = arrivalTimes[i]!;
@@ -185,7 +185,7 @@ export const parseStopTimes = async (
185
185
 
186
186
  // insert data for the new trip at the right place
187
187
  const newStopTimesLength = route.stopTimes.length + stopsCount * 2;
188
- const newStopTimes = new Uint32Array(newStopTimesLength);
188
+ const newStopTimes = new Uint16Array(newStopTimesLength);
189
189
  const newPickUpDropOffTypes = new Uint8Array(newStopTimesLength);
190
190
 
191
191
  newStopTimes.set(route.stopTimes.slice(0, insertPosition * 2), 0);
@@ -257,9 +257,9 @@ export const parseStopTimes = async (
257
257
  const departure = line.departure_time ?? line.arrival_time;
258
258
  const arrival = line.arrival_time ?? line.departure_time;
259
259
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
260
- arrivalTimes.push(toTime(arrival!).toSeconds());
260
+ arrivalTimes.push(toTime(arrival!).toMinutes());
261
261
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
262
- departureTimes.push(toTime(departure!).toSeconds());
262
+ departureTimes.push(toTime(departure!).toMinutes());
263
263
  pickUpTypes.push(parsePickupDropOffType(line.pickup_type));
264
264
  dropOffTypes.push(parsePickupDropOffType(line.drop_off_type));
265
265
 
@@ -77,8 +77,8 @@ describe('Route', () => {
77
77
  const route = new Route([vehicleLeg, transferLeg, secondVehicleLeg]);
78
78
  const departureTime = route.departureTime();
79
79
  assert.strictEqual(
80
- departureTime.toSeconds(),
81
- Time.fromHMS(8, 0, 0).toSeconds(),
80
+ departureTime.toMinutes(),
81
+ Time.fromHMS(8, 0, 0).toMinutes(),
82
82
  );
83
83
  });
84
84
 
@@ -86,8 +86,8 @@ describe('Route', () => {
86
86
  const route = new Route([vehicleLeg, transferLeg, secondVehicleLeg]);
87
87
  const arrivalTime = route.arrivalTime();
88
88
  assert.strictEqual(
89
- arrivalTime.toSeconds(),
90
- Time.fromHMS(9, 0, 0).toSeconds(),
89
+ arrivalTime.toMinutes(),
90
+ Time.fromHMS(9, 0, 0).toMinutes(),
91
91
  );
92
92
  });
93
93
 
@@ -31,13 +31,13 @@ describe('Router', () => {
31
31
  [
32
32
  'route1',
33
33
  {
34
- stopTimes: new Uint32Array([
35
- Time.fromString('08:00:00').toSeconds(),
36
- Time.fromString('08:10:00').toSeconds(),
37
- Time.fromString('08:15:00').toSeconds(),
38
- Time.fromString('08:25:00').toSeconds(),
39
- Time.fromString('08:35:00').toSeconds(),
40
- Time.fromString('08:45:00').toSeconds(),
34
+ stopTimes: new Uint16Array([
35
+ Time.fromString('08:00:00').toMinutes(),
36
+ Time.fromString('08:10:00').toMinutes(),
37
+ Time.fromString('08:15:00').toMinutes(),
38
+ Time.fromString('08:25:00').toMinutes(),
39
+ Time.fromString('08:35:00').toMinutes(),
40
+ Time.fromString('08:45:00').toMinutes(),
41
41
  ]),
42
42
  pickUpDropOffTypes: new Uint8Array([
43
43
  0,
@@ -147,8 +147,8 @@ describe('Router', () => {
147
147
 
148
148
  const timeToStop3 = result.arrivalAt('stop3');
149
149
  assert.strictEqual(
150
- timeToStop3?.time.toSeconds(),
151
- Time.fromString('08:35:00').toSeconds(),
150
+ timeToStop3?.time.toMinutes(),
151
+ Time.fromString('08:35:00').toMinutes(),
152
152
  );
153
153
  });
154
154
  });
@@ -168,13 +168,13 @@ describe('Router', () => {
168
168
  [
169
169
  'route1',
170
170
  {
171
- stopTimes: new Uint32Array([
172
- Time.fromString('08:00:00').toSeconds(),
173
- Time.fromString('08:15:00').toSeconds(),
174
- Time.fromString('08:30:00').toSeconds(),
175
- Time.fromString('08:45:00').toSeconds(),
176
- Time.fromString('09:00:00').toSeconds(),
177
- Time.fromString('09:10:00').toSeconds(),
171
+ stopTimes: new Uint16Array([
172
+ Time.fromString('08:00:00').toMinutes(),
173
+ Time.fromString('08:15:00').toMinutes(),
174
+ Time.fromString('08:30:00').toMinutes(),
175
+ Time.fromString('08:45:00').toMinutes(),
176
+ Time.fromString('09:00:00').toMinutes(),
177
+ Time.fromString('09:10:00').toMinutes(),
178
178
  ]),
179
179
  pickUpDropOffTypes: new Uint8Array([
180
180
  0, // REGULAR
@@ -196,13 +196,13 @@ describe('Router', () => {
196
196
  [
197
197
  'route2',
198
198
  {
199
- stopTimes: new Uint32Array([
200
- Time.fromString('08:05:00').toSeconds(),
201
- Time.fromString('08:20:00').toSeconds(),
202
- Time.fromString('09:00:00').toSeconds(),
203
- Time.fromString('09:15:00').toSeconds(),
204
- Time.fromString('09:20:00').toSeconds(),
205
- Time.fromString('09:35:00').toSeconds(),
199
+ stopTimes: new Uint16Array([
200
+ Time.fromString('08:05:00').toMinutes(),
201
+ Time.fromString('08:20:00').toMinutes(),
202
+ Time.fromString('09:00:00').toMinutes(),
203
+ Time.fromString('09:15:00').toMinutes(),
204
+ Time.fromString('09:20:00').toMinutes(),
205
+ Time.fromString('09:35:00').toMinutes(),
206
206
  ]),
207
207
  pickUpDropOffTypes: new Uint8Array([
208
208
  0, // REGULAR
@@ -333,8 +333,8 @@ describe('Router', () => {
333
333
 
334
334
  const timeToStop5 = result.arrivalAt('stop5');
335
335
  assert.strictEqual(
336
- timeToStop5?.time.toSeconds(),
337
- Time.fromString('09:20:00').toSeconds(),
336
+ timeToStop5?.time.toMinutes(),
337
+ Time.fromString('09:20:00').toMinutes(),
338
338
  );
339
339
  });
340
340
  });
@@ -368,13 +368,13 @@ describe('Router', () => {
368
368
  [
369
369
  'route1',
370
370
  {
371
- stopTimes: new Uint32Array([
372
- Time.fromString('08:00:00').toSeconds(),
373
- Time.fromString('08:15:00').toSeconds(),
374
- Time.fromString('08:25:00').toSeconds(),
375
- Time.fromString('08:35:00').toSeconds(),
376
- Time.fromString('08:45:00').toSeconds(),
377
- Time.fromString('08:55:00').toSeconds(),
371
+ stopTimes: new Uint16Array([
372
+ Time.fromString('08:00:00').toMinutes(),
373
+ Time.fromString('08:15:00').toMinutes(),
374
+ Time.fromString('08:25:00').toMinutes(),
375
+ Time.fromString('08:35:00').toMinutes(),
376
+ Time.fromString('08:45:00').toMinutes(),
377
+ Time.fromString('08:55:00').toMinutes(),
378
378
  ]),
379
379
  pickUpDropOffTypes: new Uint8Array([
380
380
  0, // REGULAR
@@ -396,13 +396,13 @@ describe('Router', () => {
396
396
  [
397
397
  'route2',
398
398
  {
399
- stopTimes: new Uint32Array([
400
- Time.fromString('08:10:00').toSeconds(),
401
- Time.fromString('08:20:00').toSeconds(),
402
- Time.fromString('08:40:00').toSeconds(),
403
- Time.fromString('08:50:00').toSeconds(),
404
- Time.fromString('09:00:00').toSeconds(),
405
- Time.fromString('09:10:00').toSeconds(),
399
+ stopTimes: new Uint16Array([
400
+ Time.fromString('08:10:00').toMinutes(),
401
+ Time.fromString('08:20:00').toMinutes(),
402
+ Time.fromString('08:40:00').toMinutes(),
403
+ Time.fromString('08:50:00').toMinutes(),
404
+ Time.fromString('09:00:00').toMinutes(),
405
+ Time.fromString('09:10:00').toMinutes(),
406
406
  ]),
407
407
  pickUpDropOffTypes: new Uint8Array([
408
408
  0, // REGULAR
@@ -543,8 +543,8 @@ describe('Router', () => {
543
543
 
544
544
  const timeToStop5 = result.arrivalAt('stop5');
545
545
  assert.strictEqual(
546
- timeToStop5?.time.toSeconds(),
547
- Time.fromString('08:30:00').toSeconds(),
546
+ timeToStop5?.time.toMinutes(),
547
+ Time.fromString('08:30:00').toMinutes(),
548
548
  );
549
549
  });
550
550
  });
@@ -565,13 +565,13 @@ describe('Router', () => {
565
565
  [
566
566
  'route1',
567
567
  {
568
- stopTimes: new Uint32Array([
569
- Time.fromString('08:00:00').toSeconds(),
570
- Time.fromString('08:15:00').toSeconds(),
571
- Time.fromString('08:30:00').toSeconds(),
572
- Time.fromString('08:45:00').toSeconds(),
573
- Time.fromString('09:00:00').toSeconds(),
574
- Time.fromString('09:15:00').toSeconds(),
568
+ stopTimes: new Uint16Array([
569
+ Time.fromString('08:00:00').toMinutes(),
570
+ Time.fromString('08:15:00').toMinutes(),
571
+ Time.fromString('08:30:00').toMinutes(),
572
+ Time.fromString('08:45:00').toMinutes(),
573
+ Time.fromString('09:00:00').toMinutes(),
574
+ Time.fromString('09:15:00').toMinutes(),
575
575
  ]),
576
576
  pickUpDropOffTypes: new Uint8Array([
577
577
  0, // REGULAR
@@ -593,13 +593,13 @@ describe('Router', () => {
593
593
  [
594
594
  'route2',
595
595
  {
596
- stopTimes: new Uint32Array([
597
- Time.fromString('08:10:00').toSeconds(),
598
- Time.fromString('08:25:00').toSeconds(),
599
- Time.fromString('08:50:00').toSeconds(),
600
- Time.fromString('09:05:00').toSeconds(),
601
- Time.fromString('09:10:00').toSeconds(),
602
- Time.fromString('09:25:00').toSeconds(),
596
+ stopTimes: new Uint16Array([
597
+ Time.fromString('08:10:00').toMinutes(),
598
+ Time.fromString('08:25:00').toMinutes(),
599
+ Time.fromString('08:50:00').toMinutes(),
600
+ Time.fromString('09:05:00').toMinutes(),
601
+ Time.fromString('09:10:00').toMinutes(),
602
+ Time.fromString('09:25:00').toMinutes(),
603
603
  ]),
604
604
  pickUpDropOffTypes: new Uint8Array([
605
605
  0, // REGULAR
@@ -621,11 +621,11 @@ describe('Router', () => {
621
621
  [
622
622
  'route3',
623
623
  {
624
- stopTimes: new Uint32Array([
625
- Time.fromString('08:00:00').toSeconds(),
626
- Time.fromString('08:15:00').toSeconds(),
627
- Time.fromString('09:45:00').toSeconds(),
628
- Time.fromString('10:00:00').toSeconds(),
624
+ stopTimes: new Uint16Array([
625
+ Time.fromString('08:00:00').toMinutes(),
626
+ Time.fromString('08:15:00').toMinutes(),
627
+ Time.fromString('09:45:00').toMinutes(),
628
+ Time.fromString('10:00:00').toMinutes(),
629
629
  ]),
630
630
  pickUpDropOffTypes: new Uint8Array([
631
631
  0, // REGULAR
@@ -42,7 +42,7 @@ export class Result {
42
42
  if (arrivalTime !== undefined) {
43
43
  if (
44
44
  fastestTime === undefined ||
45
- arrivalTime.time.toSeconds() < fastestTime.time.toSeconds()
45
+ arrivalTime.time.toMinutes() < fastestTime.time.toMinutes()
46
46
  ) {
47
47
  fastestDestination = destination.id;
48
48
  fastestTime = arrivalTime;
@@ -99,7 +99,7 @@ export class Result {
99
99
  if (arrivalTime !== undefined) {
100
100
  if (
101
101
  earliestArrival === undefined ||
102
- arrivalTime.time.toSeconds() < earliestArrival.time.toSeconds()
102
+ arrivalTime.time.toMinutes() < earliestArrival.time.toMinutes()
103
103
  ) {
104
104
  earliestArrival = arrivalTime;
105
105
  }
@@ -64,7 +64,7 @@ export class Router {
64
64
  .time.plus(transferTime);
65
65
  const originalArrival =
66
66
  arrivalsAtCurrentRound.get(transfer.destination)?.time ?? UNREACHED;
67
- if (arrivalAfterTransfer.toSeconds() < originalArrival.toSeconds()) {
67
+ if (arrivalAfterTransfer.toMinutes() < originalArrival.toMinutes()) {
68
68
  const origin = arrivalsAtCurrentRound.get(stop)?.origin ?? stop;
69
69
  arrivalsAtCurrentRound.set(transfer.destination, {
70
70
  time: arrivalAfterTransfer,
@@ -157,7 +157,7 @@ export class Router {
157
157
  if (currentTrip !== undefined) {
158
158
  const currentArrivalIndex =
159
159
  (currentTrip.trip * stopNumbers + i) * 2;
160
- const currentArrivalTime = Time.fromSeconds(
160
+ const currentArrivalTime = Time.fromMinutes(
161
161
  route.stopTimes[currentArrivalIndex]!,
162
162
  );
163
163
  const currentDropOffType = route.pickUpDropOffTypes[i * 2 + 1];
@@ -185,14 +185,14 @@ export class Router {
185
185
  }
186
186
  if (
187
187
  currentDropOffType !== NOT_AVAILABLE &&
188
- currentArrivalTime.toSeconds() < arrivalToImprove.toSeconds()
188
+ currentArrivalTime.toMinutes() < arrivalToImprove.toMinutes()
189
189
  ) {
190
190
  const bestHopOnStopIndex = route.stopIndices.get(
191
191
  currentTrip.bestHopOnStop,
192
192
  )!;
193
193
  const bestHopOnStopDepartureIndex =
194
194
  currentTrip.trip * stopNumbers * 2 + bestHopOnStopIndex * 2 + 1;
195
- const bestHopOnDepartureTime = Time.fromSeconds(
195
+ const bestHopOnDepartureTime = Time.fromMinutes(
196
196
  route.stopTimes[bestHopOnStopDepartureIndex]!,
197
197
  );
198
198
  arrivalsAtCurrentRound.set(currentStop, {
@@ -224,7 +224,7 @@ export class Router {
224
224
  if (
225
225
  earliestArrivalOnPreviousRound !== undefined &&
226
226
  (currentTrip === undefined ||
227
- earliestArrivalOnPreviousRound.toSeconds() <=
227
+ earliestArrivalOnPreviousRound.toMinutes() <=
228
228
  route.stopTimes[(currentTrip.trip * stopNumbers + i) * 2]!)
229
229
  ) {
230
230
  const earliestTrip = this.timetable.findEarliestTrip(
@@ -44,9 +44,9 @@ describe('timetable io', () => {
44
44
  [
45
45
  'route1',
46
46
  {
47
- stopTimes: new Uint32Array([
48
- Time.fromHMS(0, 16, 40).toSeconds(),
49
- Time.fromHMS(0, 16, 50).toSeconds(),
47
+ stopTimes: new Uint16Array([
48
+ Time.fromHMS(16, 40, 0).toMinutes(),
49
+ Time.fromHMS(16, 50, 0).toMinutes(),
50
50
  ]),
51
51
  pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
52
52
  stops: new Uint32Array([1, 2]),
@@ -60,9 +60,9 @@ describe('timetable io', () => {
60
60
  [
61
61
  'route2',
62
62
  {
63
- stopTimes: new Uint32Array([
64
- Time.fromHMS(0, 33, 20).toSeconds(),
65
- Time.fromHMS(0, 33, 30).toSeconds(),
63
+ stopTimes: new Uint16Array([
64
+ Time.fromHMS(15, 20, 0).toMinutes(),
65
+ Time.fromHMS(15, 30, 0).toMinutes(),
66
66
  ]),
67
67
  pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
68
68
  stops: new Uint32Array([2, 1]),
@@ -101,9 +101,9 @@ describe('timetable io', () => {
101
101
  routes: {
102
102
  route1: {
103
103
  stopTimes: new Uint8Array(
104
- new Uint32Array([
105
- Time.fromHMS(0, 16, 40).toSeconds(),
106
- Time.fromHMS(0, 16, 50).toSeconds(),
104
+ new Uint16Array([
105
+ Time.fromHMS(16, 40, 0).toMinutes(),
106
+ Time.fromHMS(16, 50, 0).toMinutes(),
107
107
  ]).buffer,
108
108
  ),
109
109
  pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR
@@ -112,9 +112,9 @@ describe('timetable io', () => {
112
112
  },
113
113
  route2: {
114
114
  stopTimes: new Uint8Array(
115
- new Uint32Array([
116
- Time.fromHMS(0, 33, 20).toSeconds(),
117
- Time.fromHMS(0, 33, 30).toSeconds(),
115
+ new Uint16Array([
116
+ Time.fromHMS(15, 20, 0).toMinutes(),
117
+ Time.fromHMS(15, 30, 0).toMinutes(),
118
118
  ]).buffer,
119
119
  ),
120
120
  pickUpDropOffTypes: new Uint8Array([0, 0]), // REGULAR