Menu

A tiny vanilla JS calculator for Bali visa overstays (and the off-by-one that trips everyone)
πŸ“°

A tiny vanilla JS calculator for Bali visa overstays (and the off-by-one that trips everyone)

DEV Community: javascriptΒ·Dell Alimov | Visio BaliΒ·about 2 hours ago
#oRk3m5wk
#devtojavascript#devto#dev#date#visa
Reading 0:00
15s threshold

Every week someone in a Bali expat chat asks the same thing: "My visa says 30 days, I landed on the 1st, when exactly do I have to leave?" The answer is not the 31st. That off-by-one is how a lot of people end up paying overstay fines.

So I wrote a tiny, dependency-free calculator and put it on GitHub Pages:

Live: https://dellalimov.github.io/bali-visa-calculator/

Code: https://github.com/dellalimov/bali-visa-calculator

The rule

Indonesian immigration counts the day of entry as day 1 . So a 30-day e-VOA starting on 1 Nov ends on 30 Nov , not 1 Dec. A 60-day C1 visa works the same way.

Extensions are different: they are added to the current end date, so there is no -1 .

The core logic

function lastDay ( start , days , isExtension ) { const d = new Date ( start + 'T00:00:00' ) ; // avoid UTC shifting the date d . setDate ( d . getDate ( ) + ( isExtension ? days : days - 1 ) ) ; return d ; }

const today = new Date ( ) ; today . setHours ( 0 , 0 , 0 , 0 ) ; const left = Math .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.