@golemio/pid
Version:
Golemio PID Module
60 lines (59 loc) • 3.33 kB
TypeScript
export declare class DateTimeUtils {
static LOCALE: string;
static TIMEZONE: string;
private static FORMAT_DATE_TIME;
private static FORMAT_TIME;
private static stopTimeFormatter;
/**
* @example 2022-10-26 08:55:10+01 -> 2022-10-26T09:55:10+02:00
*/
static formatSQLTimestamp(sqlTimestamp: string): string;
/**
* @example 2022-10-26T08:55:10+01:00 -> 09:55:10
*/
static parseUTCTimeFromISO(isoTimestamp?: string): string;
/**
* Get a `Date` object corresponding to a given GTFS stop time and a given trip origin timestamp
*
* @param stopTime Time in the HH:MM:SS format (H:MM:SS is also accepted). The time is measured from "noon minus 12h" of the
* service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after
* midnight on the service day, enter the time as a value greater than 24:00:00 in HH:MM:SS. See also
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
* @param tripOriginTimestamp The ISO 8601 timestamp of the trip origin
*/
static getStopDateTimeForTripOrigin(stopTime: string, tripOriginTimestamp: string): Date;
/**
* Get a `Date` object corresponding to a given GTFS stop time and a given trip origin timestamp
*
* @param stopTime Time in seconds. The time is measured from "noon minus 12h" of the
* service day (effectively midnight except for days on which daylight savings time changes occur). For times occurring after
* midnight on the service day, enter the time as a value greater than 24:00:00 in HH:MM:SS. See also
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
* @param tripOriginTimestamp The ISO 8601 timestamp of the trip origin
*/
static getStopDateTimeForTripOrigin(stopTime: number, tripOriginTimestamp: string): Date;
/**
* Get a `Date` object corresponding to a given GTFS stop time and a given start of the trip service day
*
* @param stopTimeInSeconds GTFS stop time in seconds. The time is measured from "noon minus 12h" of the service day
* (effectively midnight except for days on which daylight savings time changes occur). For times occurring after midnight on
* the service day, enter the time as a value greater than 24:00:00 in HH:MM:SS. See also
* <https://gtfs.org/schedule/reference/#:~:text=A%20phone%20number.-,Time,-%2D%20Time%20in%20the>.
* @param startDayTimestamp Unix timestamp of the local time start of the service day (that is, the midnight before the trip
* starts) **in milliseconds**. If not provided, the start of the current day is used.
*/
static getStopDateTimeForDayStart(stopTimeInSeconds: number, startDayTimestamp?: number): Date;
/**
* Get a localized, time-zone aware stop time formatted to `HH:mm:ss`
*
* @param stopTime The stop time to format
*/
static formatStopTime(stopTime: Date): string;
/**
* Get hours, minutes, and seconds from a given time
*
* @param time The time to get the segments from. Either a number in seconds, or a string in the HH:MM:SS format
* (H:MM:SS is also accepted)
*/
private static getTimeSegments;
}