How Do You Represent a Schedule Time Beyond Midnight?
From the earlier reference collection. Read the current software blog.
Some transit service days extend past midnight, so schedule times need to remain attached to the service day that defines them.
Clock time and service time
A schedule entry after midnight can belong to the previous day's service pattern. Writing it only as 02:00 may make it appear to be an early-morning event on the next calendar date, even when the schedule groups it with a trip that began before midnight. The data needs a way to preserve that relationship.
In GTFS, schedule times can extend beyond 24:00:00. A service-day time of 26:00:00 represents two hours after midnight on the calendar day following the service day's date. This notation keeps the trip within one service-day context instead of silently shifting it to a new service date.
Keep the service date explicit
A time beyond midnight is not a complete timestamp by itself. It must be interpreted with the service date and the calendar rules that determine whether service runs on that date. Readers should distinguish the service day from the ordinary calendar date shown on a clock after midnight.
For example, a trip with a 23:30 departure and a 26:00 arrival can be understood as starting on the service date and ending early the next morning. If the later time is rewritten as 02:00 without carrying the next-day relationship, sorting or joining it against the wrong date can produce an apparent reversal.
Avoid lossy conversion
Do not convert an extended schedule time into a time-of-day field that permits only values from 00:00 through 23:59 unless the next-day offset is preserved separately. A robust representation might store service date plus elapsed seconds from the service-day origin, or retain the schedule notation and define its parsing rule.
When creating a display, compute the calendar date and clock time from the service date and extended time. Keep the original service-day value available for matching trips and validating the feed. The display can say “2:00 AM next day,” while the underlying schedule remains tied to its service context.
Validate with examples
Test a trip that crosses midnight, a trip that ends exactly at a boundary, and a service date whose calendar rules differ from another day. Confirm that trip order remains correct and that calendar-day displays are derived consistently. GTFS field definitions and service-day conventions should guide the interpretation.
Document the notation next to the field, including what happens above 24 hours and how the service date is determined. Preserving both the service-day time and its calendar relationship avoids confusing an overnight trip with a separate early-morning service.