@northguild/gmt
Version:
Date and time library for JavaScript and TypeScript, built on TC39 Temporal: time zones, DST, business days, ISO 8601 strings in and out. Never throws.
34 lines • 1.46 kB
TypeScript
import { GtfsTime } from "../types/gtfs.js";
import "../types/index.js";
/**
* The fields of an `H:MM:SS`, `HH:MM:SS` or `HHH:MM:SS` value, as numbers: hours 0-999, minutes
* and seconds 0-99.
*/
export interface GtfsTimeFields {
hours: number;
minutes: number;
seconds: number;
}
/** Read the fields of a GTFS time, or null when the shape does not match. Checks shape only. */
export declare function readGtfsTimeFields(value: string): GtfsTimeFields | null;
/**
* Read a GTFS time as the whole days past the service day and the seconds left over, or null. The
* core of `parseGtfsTime` and `isValidGtfsTime`, so the two cannot disagree.
*
* @example readGtfsTime("25:35:00") // { seconds: 5700, dayOverflow: 1 }
* @example readGtfsTime("25:60:00") // null
*/
export declare function readGtfsTime(value: string): GtfsTime | null;
/**
* Write a GTFS time from the written time less whole 24-hour blocks and the whole days past the
* service day, or `""`. The core of `formatGtfsTime`.
*
* - `seconds` is an integer from 0 to 86399 and `dayOverflow` a non-negative integer; anything
* else, a fraction or `NaN` included, gives `""`.
* - The hour is written with at least two digits; an hour past 999 gives `""`.
*
* @example writeGtfsTime(5700, 1) // "25:35:00"
* @example writeGtfsTime(29100, 0) // "08:05:00"
* @example writeGtfsTime(0, 42) // ""
*/
export declare function writeGtfsTime(seconds: number, dayOverflow: number): string;