@tmlmobilidade/utils 20260916.1655.43 → 20260916.1720.37
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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/package.json +1 -1
- package/dist/gtfs/gtfs-time-string.d.ts +0 -13
- package/dist/gtfs/gtfs-time-string.js +0 -44
- package/dist/gtfs/index.d.ts +0 -1
- package/dist/gtfs/index.js +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { type OperationalTime } from '@tmlmobilidade/go-types-shared';
|
|
2
|
-
import { type OperationalDate, OperationalDateInt, type UnixMilliseconds } from '@tmlmobilidade/go-types-shared';
|
|
3
|
-
/**
|
|
4
|
-
* @deprecated Use `fromOperationalTimeAndOperationalDateToUnixMilliseconds()` instead.
|
|
5
|
-
*/
|
|
6
|
-
export declare function convertGTFSTimeStringAndOperationalDateToUnixMilliseconds(timeString: string, operationalDate: OperationalDate): UnixMilliseconds;
|
|
7
|
-
/**
|
|
8
|
-
* Convert the combination of a GTFS time and a GTFS date to a Unix timestamp.
|
|
9
|
-
* @param gtfsTime The GTFS time to be converted.
|
|
10
|
-
* @param gtfsDate The GTFS date to be converted.
|
|
11
|
-
* @returns The given time and date as a Unix timestamp.
|
|
12
|
-
*/
|
|
13
|
-
export declare function fromOperationalTimeAndOperationalDateToUnixMilliseconds(gtfsTime: OperationalTime, gtfsDate: OperationalDateInt): UnixMilliseconds;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
/* * */
|
|
2
|
-
import { OperationalTimeSchema } from '@tmlmobilidade/go-types-shared';
|
|
3
|
-
import { OperationalDateIntSchema } from '@tmlmobilidade/go-types-shared';
|
|
4
|
-
import { Dates } from '@tmlmobilidade/go-utils-dates';
|
|
5
|
-
/**
|
|
6
|
-
* @deprecated Use `fromOperationalTimeAndOperationalDateToUnixMilliseconds()` instead.
|
|
7
|
-
*/
|
|
8
|
-
export function convertGTFSTimeStringAndOperationalDateToUnixMilliseconds(timeString, operationalDate) {
|
|
9
|
-
// Return early if no time string is provided
|
|
10
|
-
if (!timeString || !operationalDate)
|
|
11
|
-
throw new Error(`✖︎ No time string or operational date provided. timeString: ${timeString}, operationalDate: ${operationalDate}`);
|
|
12
|
-
// Check if the timestring is in the format HH:MM:SS
|
|
13
|
-
if (!/^\d{2}:\d{2}:\d{2}$/.test(timeString))
|
|
14
|
-
throw new Error(`✖︎ Invalid time string format. timeString: ${timeString}`);
|
|
15
|
-
// Extract the individual components of the time string (HH:MM:SS)
|
|
16
|
-
const [hoursOperation, minutesOperation, secondsOperation] = timeString.split(':').map(Number);
|
|
17
|
-
return Dates
|
|
18
|
-
.fromOperationalDateInt(operationalDate, 'Europe/Lisbon')
|
|
19
|
-
.set({ hour: hoursOperation, minute: minutesOperation, second: secondsOperation })
|
|
20
|
-
.unix_milliseconds;
|
|
21
|
-
}
|
|
22
|
-
;
|
|
23
|
-
/**
|
|
24
|
-
* Convert the combination of a GTFS time and a GTFS date to a Unix timestamp.
|
|
25
|
-
* @param gtfsTime The GTFS time to be converted.
|
|
26
|
-
* @param gtfsDate The GTFS date to be converted.
|
|
27
|
-
* @returns The given time and date as a Unix timestamp.
|
|
28
|
-
*/
|
|
29
|
-
export function fromOperationalTimeAndOperationalDateToUnixMilliseconds(gtfsTime, gtfsDate) {
|
|
30
|
-
// Return early if no time string is provided
|
|
31
|
-
if (!gtfsTime || !gtfsDate)
|
|
32
|
-
throw new Error(`✖︎ No GTFS Time string or GTFS date string provided. gtfsTime: ${gtfsTime}, gtfsDate: ${gtfsDate}`);
|
|
33
|
-
// Check if both params are valid
|
|
34
|
-
const validatedGtfsTime = OperationalTimeSchema.parse(gtfsTime);
|
|
35
|
-
const validatedGtfsDate = OperationalDateIntSchema.parse(gtfsDate);
|
|
36
|
-
// Extract the individual components of the time string (HH:MM:SS)
|
|
37
|
-
const [hours, minutes, seconds] = validatedGtfsTime.split(':').map(Number);
|
|
38
|
-
// Convert the combination of the time and date to a Unix timestamp
|
|
39
|
-
return Dates
|
|
40
|
-
.fromOperationalDateInt(validatedGtfsDate, 'Europe/Lisbon')
|
|
41
|
-
.set({ hour: hours, minute: minutes, second: seconds })
|
|
42
|
-
.unix_milliseconds;
|
|
43
|
-
}
|
|
44
|
-
;
|
package/dist/gtfs/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './gtfs-time-string.js';
|
package/dist/gtfs/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './gtfs-time-string.js';
|