# Free Time: Which Day Is Day One

Industry: Intermodal

### Free Time: Which Day Is Day One

A container is discharged at a Sydney terminal at 15:00 on Friday 14 June 2024 with three free days. When does free time end?

The usual approach:
```js
// The naive approach: three days is 72 hours
const discharged = new Date("2024-06-14T05:00:00Z");
const expires = new Date(discharged.getTime() + 3 * 86400000);
// 2024-06-17T05:00:00Z — Monday 15:00 in Sydney
// The tariff counts days, not hours: free time ended at 00:00 on Monday, or on Tuesday
```

Free days are local calendar days at the terminal, and whether the day of discharge is free day one is a term of the tariff. Under \`firstDay: "eventDay"\` Friday is day one, so Friday, Saturday and Sunday are free and free time ends at Monday 00:00 local. Under \`"nextDay"\` free time starts Saturday and ends a full day later. The two answers differ by exactly one day of charges, which is why \`freeTimeExpiry\` has no default for it and returns \`null\` when it is missing. \`expiresAt\` is the first instant of the day after the last free day, as a UTC instant: 14:00Z is midnight AEST.

With GMT:
```js
import { freeTimeExpiry } from "@northguild/gmt/intermodal";

freeTimeExpiry("2024-06-14T05:00:00Z", 3, {
  basis: "calendar",
  timeZone: "Australia/Sydney",
  firstDay: "eventDay",
});
// { freeTimeStart: "2024-06-14", lastFreeDay: "2024-06-16", expiresAt: "2024-06-16T14:00:00Z" }

freeTimeExpiry("2024-06-14T05:00:00Z", 3, {
  basis: "calendar",
  timeZone: "Australia/Sydney",
  firstDay: "nextDay",
});
// { freeTimeStart: "2024-06-15", lastFreeDay: "2024-06-17", expiresAt: "2024-06-17T14:00:00Z" }

freeTimeExpiry("2024-06-14T05:00:00Z", 3, { basis: "calendar", timeZone: "Australia/Sydney" });
// null — firstDay has no default
```

Change `basis` to `"working"` above and add
`calendar: { weekend: [6, 7], holidays: [], timeZone: "Australia/Sydney" }`: the weekend no
longer counts, the free days are Friday, Monday and Tuesday, and free time ends on Wednesday at
`2024-06-18T14:00:00Z`. Move the discharge to `2024-06-14T13:00:00Z`, which is 23:00 on Friday in
Sydney, and the whole window is unchanged: an hour of Friday is a free day. To see the window
drawn on Sydney's day grid, open it in the [Free Time
Ledger](/gmt/tools/free-time-ledger/?w=freetime&wa=%7B%22clockStart%22%3A%222024-06-14T05%3A00%3A00Z%22%2C%22clockEnd%22%3A%222024-06-16T14%3A00%3A01Z%22%2C%22freeDays%22%3A%223%22%2C%22firstDay%22%3A%22eventDay%22%2C%22basis%22%3A%22calendar%22%2C%22chargeBasis%22%3A%22calendar%22%2C%22zone%22%3A%22Australia%2FSydney%22%7D).
The full rules are in [Intermodal: Free Time and
Demurrage](/gmt/guides/industries/intermodal-free-time-and-demurrage/).
