Skip to content

formatGtfsTime

  • Public transport timetables in GTFS feeds, where a stop time runs past midnight and still belongs to the service day its trip began on.
formatGtfsTime(value: GtfsTime): string

Writes a GTFS Schedule Time value, keeping the days past the service day in the hour.

  • Writes HH:MM:SS with at least two hour digits: 08:05:00, not 8:05:00; 110:29:00.
  • dayOverflow adds 24 hours a day, so { seconds: 5700, dayOverflow: 1 } is 25:35:00, never 01:35:00.
  • A value over 999:59:59 cannot be written in three digits and returns "".
  • The argument is read like a property bag: any object, a function included; each member is read once, inherited members are read and extra members are ignored. Source: GTFS Schedule Reference § Field Types, Time.
ParameterTypeDescription
valueGtfsTimeThe written time less whole 24-hour blocks (seconds, 0–86399) and the whole days past the service day (dayOverflow, 0 or more).

The GTFS Time string, or "" on invalid input (not a GtfsTime, or past 999:59:59)

import { formatGtfsTime } from "@northguild/gmt/rail/format";
formatGtfsTime({ seconds: 5700, dayOverflow: 1 }) // "25:35:00"
output 

rail/format/formatGtfsTime.ts

© 2026 NorthGuild · Licences

Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.