Skip to content

scheduleDeviation

  • Legs, dwell, cut-offs and punctuality, shared by road, rail, sea and air.
scheduleDeviation(planned: string, actual: string): string

Measure how far an actual time is from its plan: positive when late, negative when early.

  • Every mode publishes a plan and records what happened, and measures the gap the same way. This is that gap; classifyPunctuality judges it against a tolerance.
  • Exact elapsed time, as an ISO 8601 duration with hours as the largest unit, so the value never depends on a calendar or a wall clock. A delay across a fall-back night is PT1H, never the PT0S a wall-clock subtraction reads; across a spring-forward it is PT1H, never PT2H. Two days late is PT48H, not P2D.
  • Signed: actual after planned is positive (late), before it negative ("-PT5M", early), and equal is "PT0S".
  • Both arguments are exact instants (Z/offset) with no annotation of any kind. The offset each is written in does not matter. To show a schedule’s local time, use etaAtZone.
  • Returns "" on invalid input, including a zoneless wall time, which is not a moment.
ParameterTypeDescription
plannedstringISO 8601 instant string of the planned time
actualstringISO 8601 instant string of the actual (or compared) time

ISO 8601 duration from planned to actual, negative when early, or "" on invalid input

import { scheduleDeviation } from "@northguild/gmt/transport/compare";
scheduleDeviation("2024-06-15T10:00:00Z", "2024-06-15T10:14:00Z") // "PT14M"
output 

transport/compare/scheduleDeviation.ts

Accessibility
© 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.