Method Deck / timezones

Flight duration across time zones

Computes elapsed travel time from a departure local date/time/offset to an arrival local date/time/offset.

Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.

Try it

Inputs

Outputs

Steps

  1. Parse the departure date, time and offset into a single UTC instant, in seconds: day-number (Hinnant days_from_civil, cited above) times 86400, plus local seconds-since-midnight, minus the offset in seconds.
  2. Do the same for the arrival date, time and offset to get the arrival UTC instant.
  3. elapsed_seconds = arrival_utc_instant - departure_utc_instant; require this to be positive.
  4. hours = floor(elapsed_seconds / 3600); minutes = floor((elapsed_seconds mod 3600) / 60).

Constants

None.

Sources

Worked example and test vectors

NameInputsAnswer
worked example{"departure_date":"2026-09-30","departure_time":"08:00:00","departure_offset":"-05:00","arrival_date":"2026-09-30","arrival_time":"21:35:00","arrival_offset":"+01:00"}7h 35m
test vector: overnight, crosses a calendar date{"departure_date":"2026-03-01","departure_time":"22:00:00","departure_offset":"-05:00","arrival_date":"2026-03-02","arrival_time":"11:30:00","arrival_offset":"+01:00"}7h 30m
test vector: both local times identical but different offsets{"departure_date":"2026-05-01","departure_time":"09:00:00","departure_offset":"+09:00","arrival_date":"2026-05-01","arrival_time":"09:00:00","arrival_offset":"-08:00"}17h 0m

Published card