@golemio/pid
Version:
Golemio PID Module
73 lines (72 loc) • 4.22 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 toLocalTimeFormat(stopTime: Date): string;
/**
* Check whether a formatted time-of-day falls within a daily repeat time window.
*
* When start < end the window is a normal daytime range (e.g. 08:00–20:00).
* When start ≥ end the window wraps around midnight (e.g. 23:00–04:30).
* Special case: when start > end and end is "00:00:00", the window runs from start
* to end-of-day (e.g. 23:00–00:00:00 means 23:00 until midnight, never past it).
*
* @param start Window start in HH:mm:ss (Europe/Prague); returns true when null/undefined
* @param end Window end in HH:mm:ss (Europe/Prague); returns true when null/undefined
* @param currentTime Current time of day in HH:mm:ss — obtain once via {@link toLocalTimeFormat}
*/
static isInRepeatTimeWindow(start: string | null | undefined, end: string | null | undefined, currentTime: string): boolean;
/**
* 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;
}