longweekend.my ๐ŸŒด

How we compute long weekends

The methodology behind the planner, the holiday data, and the editorial choices. Published 16 August 2026 by the longweekend.my team.

If a long weekend is "a Saturday-Sunday that's already off plus either a Friday or Monday holiday, or a holiday falling on Tuesday/Thursday with one bridge day off," then computing the "best" stack for a given annual-leave budget sounds easy. It isn't, because the candidate space explodes once you allow 1, 2, or 3 AL days to be glued onto a sequence of adjacent holidays and weekends. This page documents how we do it.

1. Data sources

Federal public holidays come from the Akta Hari Kelepasan Persekutuan 1951 (Holidays Act 1951), the same statute the Prime Minister's Department references when declaring the year's gazetted dates. Each year's official schedule is published as a Warta Kerajaan Persekutuan notice and is also available in summary form from the PM's Department portal at the start of each year.

State-level holidays are aggregated from each of the 13 states' own annual gazetted schedules, then mapped back to the federal Holiday Act for cross-consistency. Where states diverge from federal gazetted dates (a real occurrence โ€” some states observe a holiday on different dates or in different ways), we record both and surface the relevant one per the user's "state holidays" filter. We re-verify every calendar year, normally in the second week of January once the Warta has been uploaded.

Verification status โ€” the holiday data backing the planner was last cross-referenced against the 2026 federal gazette and all 13 state schedules on 14 August 2026. No discrepancies reported since. If you spot one, the feedback form on the main page routes directly to the editor.

2. What counts as "a weekend"

Malaysia has three different practical definitions of "the weekend" depending on which state you work in:

This matters because a "long weekend" on one side of the causeway isn't always a long weekend on the other. If you're planning around Thaipusam, for example, the Sat-Mon stack that works for KL/Putrajaya/Selangor employees does not exist for a typical KB or TGG worker.

3. The optimisation algorithm

For each (year, AL budget, state-filter, weekend-rule) combination, the planner does three things:

  1. Build the set of non-working dates for that combination: federal holidays โˆช selected state holidays โˆช weekend days (Sat+Sun, or Fri+Sat where applicable).
  2. Find contiguous "runs" โ€” maximal sequences of non-working dates. These are the natural vacation windows. A run starts on the first non-working day after a working day and ends on the last non-working day before a working day.
  3. For each run, evaluate every possible AL bridge that extends the run into the surrounding working days, up to the user's AL budget. A bridge of k AL days is a set of k working days adjacent to (or inside) the run that, if taken as leave, extend the run by k days.

We then rank candidates across all runs by a composite score: days off per AL used (efficiency), then total days off, then least AL used. The top results are returned to the user with the exact leave dates highlighted on the calendar.

The combinatorics are bounded โ€” at any reasonable AL budget (โ‰ค30 days) the candidate space stays well under 10โต for a single calendar year, so this runs entirely in the browser in under 50ms on commodity hardware. No server round-trip is needed once the holiday data has loaded.

Why a knapsack-style approach, not greedy

An earlier version of this planner used a greedy algorithm (always pick the most efficient bridge first). That was provably wrong โ€” it over-spent AL on small 3-day bridges and missed cases where bridging two 3-day stacks separately gives 8 days for 2 AL, while bridging one of them only gives 4 days for 1 AL. The current approach exhaustively evaluates small candidates and ranks them, which is correct even when no single bridge dominates.

4. Replacement days and "cuti bersama"

Malaysia uses replacement days โ€” when a gazetted holiday falls on a Sunday, the Monday or following workday is declared a replacement holiday. We track these explicitly because the order changes: e.g. Thaipusam 2026 falls Sunday 1 Feb, replacement day is Mon 2 Feb, so the Selangor stretch runs Sat 31 Jan โ€“ Mon 2 Feb, not Sat 1 Feb โ€“ Sun 1 Feb.

"Cuti bersama" (bridge days sometimes declared by the PM mid-year) are not predicted by this tool. They are policy calls, not gazetted holidays, and the declaration cadence varies year to year. We add them into the planner only after they appear in the official Warta or a public PM announcement โ€” never speculatively.

5. What we deliberately don't do

6. How we keep this honest

The full holiday dataset is curated annually by the longweekend.my team (see the about page) against the published federal and state gazettes, then cross-checked against at least one secondary source (typically a major Malaysian newsroom's annual holiday summary, which surfaces replacement days we may have missed). Edits to the dataset go through a build-time check that flags any holiday older than its gazetted date, and any future-dated entry that hasn't yet been published in the Warta is marked provisional until the gazette lands.

Suggested corrections from users are reviewed within 1โ€“3 days. Where a correction invalidates a stretch already shown to visitors, the affected page is re-checked and the correction flag is recorded publicly in the contact log on the about page.

7. Reproducibility

The full site is statically built from a single Python build script (build.py) and a JSON-encoded holiday dataset. The build is deterministic โ€” running it twice produces identical HTML. The output is a set of plain HTML files plus JSON endpoints (/api/holidays.json, /llm.txt) that any user can save, diff against the next build, and submit corrections against. There is no proprietary data, no paywall, and no analytics ID that can't be cleared with a browser cookie reset.

8. Future work

Open methodological improvements we plan to publish once the data and editorial process stabilise: