@tmlmobilidade/utils 20260609.1823.50 → 20260609.2354.26
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.
- package/dist/gtfs/gtfs-time-string.d.ts +2 -0
- package/dist/gtfs/gtfs-time-string.js +20 -0
- package/dist/gtfs/index.d.ts +1 -0
- package/dist/gtfs/index.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/* * */
|
|
2
|
+
import { Dates } from '@tmlmobilidade/dates';
|
|
3
|
+
/* * */
|
|
4
|
+
export function convertGTFSTimeStringAndOperationalDateToUnixTimestamp(timeString, operationalDate) {
|
|
5
|
+
//
|
|
6
|
+
// Return early if no time string is provided
|
|
7
|
+
if (!timeString || !operationalDate)
|
|
8
|
+
throw new Error(`✖︎ No time string or operational date provided. timeString: ${timeString}, operationalDate: ${operationalDate}`);
|
|
9
|
+
// Check if the timestring is in the format HH:MM:SS
|
|
10
|
+
if (!/^\d{2}:\d{2}:\d{2}$/.test(timeString))
|
|
11
|
+
throw new Error(`✖︎ Invalid time string format. timeString: ${timeString}`);
|
|
12
|
+
// Extract the individual components of the time string (HH:MM:SS)
|
|
13
|
+
const [hoursOperation, minutesOperation, secondsOperation] = timeString.split(':').map(Number);
|
|
14
|
+
return Dates
|
|
15
|
+
.fromOperationalDate(operationalDate, 'Europe/Lisbon')
|
|
16
|
+
.set({ hour: hoursOperation, minute: minutesOperation, second: secondsOperation })
|
|
17
|
+
.unix_timestamp;
|
|
18
|
+
//
|
|
19
|
+
}
|
|
20
|
+
;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gtfs-time-string.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './gtfs-time-string.js';
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './batching/index.js';
|
|
|
2
2
|
export * from './caching/index.js';
|
|
3
3
|
export * from './generic/index.js';
|
|
4
4
|
export * from './get-public-trip-id.js';
|
|
5
|
+
export * from './gtfs/index.js';
|
|
5
6
|
export * from './http/index.js';
|
|
6
7
|
export * from './maps/index.js';
|
|
7
8
|
export * from './numbers/index.js';
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './batching/index.js';
|
|
|
2
2
|
export * from './caching/index.js';
|
|
3
3
|
export * from './generic/index.js';
|
|
4
4
|
export * from './get-public-trip-id.js';
|
|
5
|
+
export * from './gtfs/index.js';
|
|
5
6
|
export * from './http/index.js';
|
|
6
7
|
export * from './maps/index.js';
|
|
7
8
|
export * from './numbers/index.js';
|