<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[My Awesome Publication]]></title><description><![CDATA[My Awesome Publication]]></description><link>https://javediqbal-blog.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Sat, 28 Nov 2026 01:10:25 GMT</lastBuildDate><atom:link href="https://javediqbal-blog.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[The Schengen 90/180 Rule Is a Rolling Window — Here's the JavaScript]]></title><description><![CDATA[Every traveller to Europe's Schengen area meets the same rule: you may stay at most 90 days within any 180-day period. The part that trips people up — and…]]></description><link>https://javediqbal-blog.hashnode.dev/the-schengen-90-180-rule-is-a-rolling-window-here-s-the-javascript</link><guid isPermaLink="true">https://javediqbal-blog.hashnode.dev/the-schengen-90-180-rule-is-a-rolling-window-here-s-the-javascript</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Travel]]></category><category><![CDATA[webdev]]></category><dc:creator><![CDATA[javed iqbal]]></dc:creator><pubDate>Thu, 26 Nov 2026 15:38:48 GMT</pubDate><content:encoded><![CDATA[<p>Every traveller to Europe's Schengen area meets the same rule: you may stay at most 90 days within any 180-day period. The part that trips people up — and breaks naive calculators — is that the 180 days are not a fixed block. The window rolls: it is always the 180 days ending today.</p>
<h2>Why fixed blocks give wrong answers</h2>
<p>If you split the year into two fixed halves, a traveller can look legal in both halves while actually overstaying — for example, 80 days at the end of one block plus 80 days at the start of the next is 160 days inside a single rolling window. Border officers count the rolling window, so your code must too.</p>
<h2>The check, in one function</h2>
<p>For any date, count the days of presence that fall inside the 180 days ending on that date:</p>
<pre><code class="language-js">function daysUsed(trips, onDate) {
  const DAY = 86400000;
  const windowStart = onDate - 179 * DAY;
  let days = 0;
  for (const [entry, exit] of trips) {
    const start = Math.max(entry, windowStart);
    const end = Math.min(exit, onDate);
    if (end &gt;= start) days += (end - start) / DAY + 1;
  }
  return days; // must stay &lt;= 90
}
</code></pre>
<p>Run it for today to know your current usage, and run it for each planned future date to find the latest day you may legally stay. Entry and exit days both count as days of presence — that final +1 is where most home-made calculators go wrong.</p>
<h2>A finished version</h2>
<p>If you just need the answer instead of the algorithm, the free <a href="https://schengencalculator.online">Schengen calculator</a> does exactly this: add your trips and it shows your used days, your remaining days, and the last legal day of your next visit.</p>
<p>Edge cases worth testing in your own code: trips stored in milliseconds vs. local dates, and travellers whose trip is still open (no exit date yet). Both have bitten me.</p>
]]></content:encoded></item></channel></rss>