UNPKG

minotor

Version:

A lightweight client-side transit routing library.

67 lines (66 loc) 2.44 kB
/** * A Time represented as minutes since midnight. * Note that this value can go beyond 1440 (24*60) to model services overlapping with the next day. */ export type Time = number; /** * A Duration represented as minutes. */ export type Duration = number; export declare const TIME_INFINITY: Time; export declare const TIME_ORIGIN: Time; export declare const DURATION_ZERO: Duration; /** * Creates a Time from hours, minutes, and seconds. * Rounds to the closest minute as times are represented in minutes from midnight. * * @param hours - The hours component of the time. * @param minutes - The minutes component of the time. * @param seconds - The seconds component of the time. * @returns A Time representing the specified time. */ export declare const timeFromHMS: (hours: number, minutes: number, seconds: number) => Time; /** * Creates a Time from hours and minutes. * * @param hours - The hours component of the time. * @param minutes - The minutes component of the time. * @returns A Time representing the specified time. */ export declare const timeFromHM: (hours: number, minutes: number) => Time; /** * Parses a JavaScript Date object and creates a Time. * * @param date - A JavaScript Date object representing the time. * @returns A Time representing the parsed time. */ export declare const timeFromDate: (date: Date) => Time; /** * Parses a time string in the format "HH:MM:SS" or "HH:MM" and creates a Time. * * @param timeStr - A string representing the time in "HH:MM:SS" or "HH:MM" format. * @returns A Time representing the parsed time. */ export declare const timeFromString: (timeStr: string) => Time; /** * Converts a Time to a string in "HH:MM" format. * Hours wrap around at 24 (e.g., 25:30 becomes 01:30). * * @param time - The Time to convert. * @returns A string representing the time. */ export declare const timeToString: (time: Time) => string; /** * Creates a Duration from a given number of seconds. * * @param seconds - The number of seconds for the duration. * @returns A Duration representing the specified duration in minutes. */ export declare const durationFromSeconds: (seconds: number) => Duration; /** * Converts a Duration to a string in "HH:MM" or "(M)Mmin" format. * * @param duration - The Duration to convert (in minutes). * @returns A string representing the duration. */ export declare const durationToString: (duration: Duration) => string;