Skip to content

Rail

  • Public transport timetables in GTFS feeds, where a stop time runs past midnight and still belongs to the service day its trip began on.

Transit agencies publish timetables as GTFS feeds. A stop time there can run past midnight, because a trip that leaves late in the evening still belongs to the day it began. This layer reads, writes and checks that time without folding it back into one day.

  • A trip after midnight lands on the wrong day. parseGtfsTime returns the whole days past the service day and the seconds left over as two numbers, so a stop after midnight stays with the trip that reaches it. See guide, scenario, tool.
  • A time written back loses its service day. formatGtfsTime writes the hours past midnight as the feed wrote them, so reading its output back gives the same day and time. See guide, mistakes.
  • A clock-time check refuses a valid stop time. A time of day stops before midnight, and a stop time does not. isValidGtfsTime accepts any hour the format can hold and refuses minutes or seconds out of range. See mistakes, tool.
  • A stop time is anchored at midnight on a clock-change day. A GTFS time counts from noon minus twelve hours of the service day, which is off midnight on a day the clocks change, by the size of the change, an hour in most zones. gtfsToInstant counts from that point in the agency’s zone. See guide, scenario, tool.
  • A stop’s or a printed time is read in the wrong zone. Rail draws on the transport layer. GTFS reads every stop time against the agency’s zone, so gtfsToInstant given a stop’s own zone moves the instant by the difference between the two offsets that day, an hour from Madrid to Lisbon. scheduleDelivery reads a printed departure in the zone you name, and the timetable reader shows a repeated or skipped hour. See mistakes, tool, tool.

Start with the guide: Rail: GTFS Service Days.

convert

  • gtfsToInstant: The UTC instant a GTFS time names on its service day in the agency’s time zone.

format

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

parse

  • parseGtfsTime: Reads a GTFS Schedule Time value, keeping the days past the service day apart from the time of day.

validate

  • isValidGtfsTime: Checks a GTFS Schedule Time value, including one past 24:00:00.

Part of the Transport industry layer.

calculate

  • bestAvailable: Pick the best available timestamp for an event from its planned, estimated, requested and actual records, and say which class it is.
  • crossingTime: Measure a crossing — a canal transit, a strait passage, a border queue — and render both ends in the zone the crossing is administered in.
  • cutoffAt: Find a deadline stated as an offset before an anchor event, in the local time of the place that enforces it.
  • cutoffSchedule: Compute a whole stack of cut-offs against one anchor event, earliest first.
  • dwellTime: Measure how long something sat somewhere, and how many local calendar days it sat there.
  • estimateDrift: Measure how far an estimate moved between its first and last revision.
  • nextDeparture: Find the next departure a connection can make: the first scheduled departure at or after after plus the minimum connection time.
  • punctualityRate: The share of planned/actual pairs that were on time under one tolerance.
  • scheduleDelivery: Chain the legs of a multi-modal move into an end-to-end ETA with zone-local times at every handoff.
  • transitTime: Add a transit duration to a departure and return the arrival, in the departure’s own zone.

compare

  • classifyPunctuality: Classify an arrival as early, on time or late against the caller’s tolerance.
  • isPastCutoff: Report whether a cut-off has passed.
  • scheduleDeviation: Measure how far an actual time is from its plan: positive when late, negative when early.
  • timeToCutoff: Measure the time left until a cut-off, negative once it has passed.

convert

  • etaAtZone: Render an arrival instant as local time in the zone where it will be read.
  • Rail: GTFS Service Days: Read, write and check a GTFS stop time such as 25:35:00, which runs past midnight and stays with its service day, and turn it into an instant on a service date in the agency’s zone.
  • GTFS Service Day Clock: Type a GTFS service date, a stop time and the agency’s zone. The tool turns them into the instant GTFS means with gtfsToInstant, shows the instant a midnight anchor gives next to it, and draws both on one day rail with the clock change marked.
  • GTFS Time Reader: Paste a GTFS stop time, H:MM:SS with hours up to 999. The tool reads it with parseGtfsTime and isValidGtfsTime, shows the days past the service day, the same text put through a clock-time check, and writes a record back with formatGtfsTime.
  • GTFS Trip Board: Paste one trip’s stop_times.txt rows with each stop’s zone, a service date and the agency’s zone. The tool turns every time into an instant with gtfsToInstant, shows the clock on each platform, the reading a stop’s own zone would give, and the length of each leg.
  • A GTFS Time Folded into One Day: A feed import folds 25:35:00 into 01:35:00, and a night trip’s last stops move to the start of its service day.
  • A GTFS Trip Anchored at Midnight: A feed import adds each stop time to local midnight, and on the day the clocks go forward every stop of that service day shows an hour late.
  • Rail: Common mistakes with GTFS stop times — folding a time past midnight into one day, checking it as a clock time, writing it back, spaces and the byte-order mark, and treating seconds as a clock reading — in GMT’s Rail layer.
© 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.