Skip to content

Leg

One leg of a multi-modal journey: a departure, how long it takes, and where it lands.

import type { Leg } from "@northguild/gmt";
MemberTypeDescription
departure?stringThe departure: an instant (Z/offset) or a zoned string, always exact; on any leg but the first, a zoneless wall time is also accepted and is read in the previous leg’s timeZone (the first leg’s equivalent is ScheduleDeliveryOptions.startTimeZone). Required on the first leg; on later legs it is the scheduled connection the cargo waits for.
durationstringThe ISO 8601 duration of the leg; time units and 24-hour days only (transitTime’s rule).
timeZonestringThe time zone of the destination, the caller’s fact: an IANA name or a UTC offset to the minute (what isValidTimeZone accepts).
dwellAfter?stringThe handling time at the handoff after this leg; the minimum connect time.
mode?stringAn opaque tag echoed back on the LegTime; GMT does not interpret transport modes.
origin?stringAn opaque tag echoed back on the LegTime; never resolved to a zone.
destination?stringAn opaque tag echoed back on the LegTime; never resolved to a zone.
interface Leg {
/**
* The departure: an instant (`Z`/offset) or a zoned string, always exact; on any leg but the
* first, a zoneless wall time is also accepted and is read in the previous leg's `timeZone`
* (the first leg's equivalent is `ScheduleDeliveryOptions.startTimeZone`). Required on the
* first leg; on later legs it is the scheduled connection the cargo waits for.
*
* @defaultValue None. The leg leaves as soon as the previous leg's arrival plus its
* `dwellAfter` allows; a first leg without it is invalid input.
*/
departure?: string;
/** The ISO 8601 duration of the leg; time units and 24-hour days only (`transitTime`'s rule). */
duration: string;
/**
* The time zone of the destination, the caller's fact: an IANA name or a UTC offset to the minute
* (what `isValidTimeZone` accepts).
*/
timeZone: string;
/**
* The handling time at the handoff after this leg; the minimum connect time.
*
* @defaultValue `"PT0S"`
*/
dwellAfter?: string;
/**
* An opaque tag echoed back on the LegTime; GMT does not interpret transport modes.
*
* @defaultValue None. The LegTime carries no `mode`.
*/
mode?: string;
/**
* An opaque tag echoed back on the LegTime; never resolved to a zone.
*
* @defaultValue None. The LegTime carries no `origin`.
*/
origin?: string;
/**
* An opaque tag echoed back on the LegTime; never resolved to a zone.
*
* @defaultValue None. The LegTime carries no `destination`.
*/
destination?: string;
}

transport/calculate/scheduleDelivery.ts