# A Connection Missed at the Spring-Forward Handoff

Industry: Transport

### A Connection Missed at the Spring-Forward Handoff

A truck leaves Amsterdam at 08:00 on 29 March 2024 on a 46-hour run to the London port. Handling there takes two hours. The ship to Tokyo is published to sail at 07:30 on 31 March. Is the connection made?

The usual approach:
```js
// The naive approach: one UTC offset per place, from a table
const OFFSET_HOURS = { "Europe/London": 0 }; // London, as the table was built in winter
const departed = Date.parse("2024-03-29T08:00:00+01:00"); // Amsterdam, 08:00
const arrived = departed + 46 * 36e5; // 2024-03-31T05:00:00.000Z
const toLocal = (ms) => new Date(ms + OFFSET_HOURS["Europe/London"] * 36e5).toISOString().slice(0, 16);
toLocal(arrived); // "2024-03-31T05:00"
const ready = arrived + 2 * 36e5; // two hours of handling: "2024-03-31T07:00" local
const sails = Date.parse("2024-03-31T07:30:00Z") - OFFSET_HOURS["Europe/London"] * 36e5; // 07:30 local, by the table
ready <= sails; // true — "made, with 30 minutes to spare"
```

A fixed offset is a place's offset at one moment. The table's +00:00 was London's offset when the truck left. Clocks sprang forward at 01:00 on 31 March, and the truck arrived at 05:00Z, which is 06:00 BST. The naive code reads the arrival and the ship's published 07:30 through that same stale offset, so the handoff looks 30 minutes early. In fact the cargo is ready at 08:00, and the ship sailed at 07:30. \`scheduleDelivery\` keeps every handoff an exact instant. It reads the ship's published time in the port's own zone. It treats a departure before the arrival plus the handling time as a missed connection, and returns \`null\` rather than a negative wait.

With GMT:
```js
import { scheduleDelivery } from "@northguild/gmt/transport";

const truck = { departure: "2024-03-29T08:00:00+01:00[Europe/Amsterdam]", duration: "PT46H", timeZone: "Europe/London", dwellAfter: "PT2H", mode: "truck" };
const ship = { departure: "2024-03-31T07:30:00[Europe/London]", duration: "P11D", timeZone: "Asia/Tokyo", mode: "ship" };
const laterShip = { departure: "2024-03-31T08:30:00[Europe/London]", duration: "P11D", timeZone: "Asia/Tokyo", mode: "ship" };

scheduleDelivery([truck]);
// { eta: "2024-03-31T06:00:00+01:00[Europe/London]", legTimes: [{ arrival: "2024-03-31T05:00:00Z", localArrival: "2024-03-31T06:00:00+01:00[Europe/London]", dwellAfter: "PT2H", mode: "truck" }] } — 06:00, not 05:00

scheduleDelivery([truck, ship]);
// null — the ship sails inside the two-hour handoff: a missed connection

scheduleDelivery([truck, laterShip]);
// { eta: "2024-04-11T16:30:00+09:00[Asia/Tokyo]",
//   legTimes: [{ arrival: "2024-03-31T05:00:00Z", localArrival: "2024-03-31T06:00:00+01:00[Europe/London]", dwellAfter: "PT2H", mode: "truck" },
//     { arrival: "2024-04-11T07:30:00Z", localArrival: "2024-04-11T16:30:00+09:00[Asia/Tokyo]", dwellAfter: "PT0S", mode: "ship" }] } — a half hour later, the connection holds
```

Open the handoff in the [Connection
Checker](/gmt/tools/connection-checker/?w=connection&wa=%7B%22inboundDeparture%22%3A%222024-03-29T08%3A00%3A00%2B01%3A00%5BEurope%2FAmsterdam%5D%22%2C%22inboundDuration%22%3A%22PT46H%22%2C%22portZone%22%3A%22Europe%2FLondon%22%2C%22handlingMinutes%22%3A%22120%22%2C%22onwardDeparture%22%3A%222024-03-31T07%3A30%3A00%5BEurope%2FLondon%5D%22%2C%22onwardDuration%22%3A%22P11D%22%2C%22onwardZone%22%3A%22Asia%2FTokyo%22%7D)
and slide the handling time down: at 90 minutes the ship sails exactly when the cargo is
ready, and equal passes. At 91 it is missed. Or open the whole journey in the [Delivery
Scheduler](/gmt/tools/delivery-scheduler/?w=delivery&wa=%7B%22legCount%22%3A%223%22%2C%22departure1%22%3A%222024-03-29T08%3A00%3A00%2B01%3A00%5BEurope%2FAmsterdam%5D%22%2C%22duration1%22%3A%22PT46H%22%2C%22timeZone1%22%3A%22Europe%2FLondon%22%2C%22dwellAfter1%22%3A%22PT2H%22%2C%22mode1%22%3A%22truck%22%2C%22duration2%22%3A%22P11D%22%2C%22timeZone2%22%3A%22Asia%2FTokyo%22%2C%22dwellAfter2%22%3A%22PT24H%22%2C%22mode2%22%3A%22ship%22%2C%22duration3%22%3A%22PT2H30M%22%2C%22timeZone3%22%3A%22Asia%2FTokyo%22%2C%22mode3%22%3A%22rail%22%2C%22departure2%22%3A%222024-03-31T07%3A30%3A00%5BEurope%2FLondon%5D%22%7D)
and change the ship's departure to 07:30. The full rules are in [Transport: Multi-leg
Scheduling](/gmt/guides/industries/transport-multi-leg-scheduling/#a-scheduled-departure-is-a-connection-and-dwell-is-the-minimum-connect-time).
