Rohit Swami
India Resume ↗

Writing · CitizenDays · 7 min read

Counting days the way the government does

Australia, Canada, the UK, the US and the Schengen area all limit how long you can be away, and no two count a day the same way. How CitizenDays reads the rules like code, and why it is a day stricter than one official calculator on purpose.

If you're on the way to citizenship somewhere, someone is counting your days. Australia wants no more than 90 days away in the twelve months before you apply. Canada wants 1,095 days in the country out of the last five years. The UK's settlement routes break if you spend more than 180 days away in any twelve months, and a visitor to the Schengen area gets 90 days in any 180. Get the count wrong by one day and the cost is an application refused, or an overstay on your record.

CitizenDays keeps that count. You log your trips, where you went and when you left and came back, and for each goal it tells you how many days you've used, the earliest date you can apply and how long you can safely be away. The adding up is easy. Knowing what to add up was the actual work.

1A trip is not a number of days

Take one trip. You leave Canada on 1 July for Spain and fly back on 15 July. How many days were you away?

Canada says 13. Its physical presence calculator is explicit that the day you leave and the day you return are days in Canada, "because you were physically in Canada for a part of the day of departure or arrival". Australia, the UK and the US use the same convention. The Schengen area uses the opposite one: under the Schengen Borders Code, the date of entry is the first day of stay and the date of exit is the last. Spain counts 15.

left Canada
back

Canada: days away –Schengen: days of stay –

Fig. 1 One trip, read by two rules. Drag either end of the trip, or use the sliders. Red days count against a limit. For Canada, Australia, the UK and the US the two travel days are days at home, in blue; for Schengen they are days of stay like any other.

So the engine never stores "days away". It turns trips into two kinds of day, whole days away and days of stay, and each rule reads the kind its own text describes. Every counting convention has a test, and the test quotes the official sentence it comes from. When someone asks why a number is what it is, the answer is a citation, not my opinion.

The rules are written for people filling in forms, not for software, so they leave gaps. If one trip ends on the day the next one begins, did you come home in between? CitizenDays reads the two as one journey, so the shared date counts as a day away. If you did come home that day, the count is one day high, never one day low. Dates are calendar dates in the traveller's own time, kept as whole numbers of days, so "the 179 days before" is a subtraction and a clock change can never move a day.

// a calendar date as a whole number of days: no hours, no time zones, no daylight saving
const dayNumber = (iso) => Date.UTC(+iso.slice(0, 4), +iso.slice(5, 7) - 1, +iso.slice(8, 10)) / 86_400_000;

// Schengen: days of stay in the window that ends on `day`, which is that day and the 179 before it
function usedOn(day, stayDays) {          // stayDays: a Set of day numbers spent in the area
  let n = 0;
  for (let d = day - 179; d <= day; d++) if (stayDays.has(d)) n++;
  return n;
}

2Windows that move

The second difference is the window. Australia and Canada look back over a fixed period that ends the day before you apply. Move the application date and the period moves with it, but there is only ever one period to check. The UK and Schengen rules roll. "No more than 90 days in any 180-day period" means every single day of a stay has its own window, that day and the 179 before it, and every one of those windows has to hold 90 days or fewer.

Rolling windows give answers that look wrong. The European Commission's manual for its own short-stay calculator has a traveller who was in the Schengen area from 1 to 10 January, 1 to 30 March and 1 May to 9 June 2024. If they come back on 7 August, they can stay 20 days. If they come back on 8 August, one day later, they can stay 50.

arrive

in the window on arrival –can stay –leave by –

Fig. 2 The European Commission's worked example, recomputed day by day. Grey blocks are the earlier stays and blue is the new one, as long as it can legally run. The bracket is the 180-day window of the stay's last day, and the line is the count in each day's window. The four buttons are the dates the manual itself uses.

The figure shows why. Days don't come back on a schedule: each one leaves the window exactly 180 days after it was spent. Arrive on 7 August, and on the 21st day of the stay the window still starts on 1 March and holds all 70 of the earlier days: 91, one too many. Arrive on 8 August, and the 21st day is 28 August, the day 1 March leaves the window. From then on every new day in Spain is matched by a day of March leaving, and the stay can run until March is used up. A day's difference in arrival is thirty days' difference in stay, which is not something anyone should have to work out on a napkin.

3A day stricter, on purpose

Australia publishes a Residence Calculator, and it was the obvious thing to test against. It runs on the Home Affairs server and turns away plain page fetchers, so I wrote a small script that drives the real page in headless Chrome, and ran test trips through it. Permanent residence from 1 January 2020, lawful residence from 1 January 2015, applying on 5 October 2026:

TripWhole days awayHome Affairs calculatorCitizenDays
1 Jun to 31 Aug 202690, all in the last 12 monthsmetmet
1 Jun to 1 Sep 202691not met, reapply 2 Jun 2027not met, earliest 3 Jun 2027
1 Jan 2024 to 1 Jan 2025365metmet
1 Jan 2024 to 2 Jan 2025366metnot met
1 Jan 2024 to 3 Jan 2025367not met, reapply 2 Jan 2028not met
4 Oct 2025 to 4 Jan 202691, the first on 5 Oct 2025metnot met
no trips, permanent resident from 1 Mar 2026not met, reapply 1 Mar 2027earliest 1 Mar 2027
no trips, living in Australia from 1 Feb 2023not met, reapply 1 Feb 2027earliest 1 Feb 2027

Checked on 5 October 2026. The first two rows confirm that travel days count as days in Australia.

In two rows CitizenDays is stricter than the government's own calculator, and that's deliberate. The calculator allows 366 days away in four years, where the written guidance says the limit is 365 days, "12 months". And it ignores a day away that falls on the first day of a look-back period, where the Citizenship Act says "the period of 12 months immediately before". When official sources disagree with each other, CitizenDays takes the reading that counts more days away. The price is that its earliest date can be a day or two later than the calculator's. It is never earlier, and a warning that comes a day early is one nobody regrets.

4Rules change

All of this rests on text that governments revise. The UK guidance page I started from turned out to cover only a few older routes, because the main ones now sit under a newer appendix of the Immigration Rules, and a longer "earned settlement" is already proposed. So every rule pack records the date its sources were last checked, and the release check fails once that date is more than 120 days old.

The tests come in three layers: one per counting convention, quoting its source; the worked examples from each rule's own official guidance, including the Commission's traveller above; and a recount of 520 random trip logs, day by day, the slow and obvious way, which the engine has to agree with on every one. The app says plainly that it isn't legal advice, and means it. But when it says you can stay until 26 September, that date comes from the same arithmetic as the European Commission's own examples, and it has been checked against them.

I'm Rohit Swami. I build the unglamorous machinery real products run on: data pipelines, real-time services, open-source tools, and products of my own. More about me, or write to me.

The figures on this page are simulations written for it. They run in your browser, and the numbers in them are illustrative unless the text says otherwise.