Skip to content

Industries

The core of GMT is a set of general primitives: zoned arithmetic, real day boundaries, half-open intervals, business calendars. Each industry layer is a small set of functions that name the operation an industry actually performs, built on those primitives so every layer agrees about what a midnight, a day or an elapsed hour is.

Three things hold across every industry layer:

  • Facts come from the caller. A port, airport, terminal or station code is not resolved to a time zone, and a contract term is not looked up by carrier. You pass the IANA zone and the terms; GMT does the time arithmetic. That keeps the library free of registries that go stale.
  • Elapsed time and calendar days are different answers. A leg is elapsed hours across whatever DST transition it crosses. A charge is counted in local calendar days at the place the thing sat. The industry functions return both where both matter, and never derive one from the other.
  • Every result is a standard string. The same ISO 8601 and RFC 9557 strings as the rest of the library, so an industry result feeds straight back into interval/, zoned/ or a business calendar.
  • Transport: legs and dwell — add a leg’s transit time to a departure, show an arrival where it lands, and measure dwell in exact hours and local calendar days. Shared by road, rail, sea and air. Its deadlines from an anchor find a cut-off counted back from a departure, a loading or an arrival, pinned to a local time of day and rolled off closures, and tell you whether it has passed.
  • Transport: multi-leg scheduling — chain truck, ship and rail legs into one ETA with every handoff an exact instant, check a scheduled connection against the minimum connect time, and time a crossing on the clock that administers it. Built on the legs-and-dwell layer.
  • Transport: punctuality and timestamps — measure how late an arrival was in exact time, judge it against a tolerance you state, count a rate, pick the best of planned, estimated, requested and actual timestamps, measure how far an estimate moved, and find the next departure a connection can make. Built on the legs-and-dwell layer.
  • Intermodal: free time and demurrage — which clock a charge runs on, which day is free day one, calendar or working days, and the chargeable days and dates behind every count. Built on the transport layer’s day count.
  • Intermodal: billing deadlines — the last date to issue, dispute and resolve a demurrage or detention invoice, counted in calendar days from a date you name, with every window a number you pass. Built on the free-time layer’s charged dates.
  • Intermodal: B/L dates and multimodal ETA — a bill of lading’s issue, receipt and shipped-on-board dates on the local calendar of the place each happened, and an end-to-end ETA with transit and dwell reported apart. Built on the multi-leg scheduling layer.
  • Intermodal: EDI timestamps — read and write the dates and times in UN/EDIFACT DTM segments, X12 elements and EPCIS events, and know for each one whether its offset is stated. An offsetless value stays a local time until you name the zone.

Each layer comes with real-world scenarios that show the naive approach breaking beside the GMT approach working, on the same live widget:

The mistakes that have hurt people in these layers are collected under Transport mistakes and Intermodal mistakes.