diff --git a/README.md b/README.md index 3bce0b0..67421da 100644 --- a/README.md +++ b/README.md @@ -38,18 +38,14 @@ Alternative: **Deploy from a branch** → `main` → `/` (root). Asset paths are - Daily average = worked ÷ working days (`—` if there are no working days). - Time format: results use `h:mm` with two-digit minutes. Input is two numeric fields (hours and minutes), so Android can use the number keypad. -Holidays (2025, carried over from the former MAUI app): +Holidays are year-specific (Mexican federal holidays plus Holy Thursday and Good Friday): ``` -2025-01-01 -2025-02-03 -2025-03-17 -2025-04-17 -2025-04-18 -2025-05-01 -2025-09-16 -2025-11-18 -2025-12-25 +2025-01-01 2025-02-03 2025-03-17 2025-04-17 2025-04-18 +2025-05-01 2025-09-16 2025-11-18 2025-12-25 + +2026-01-01 2026-02-02 2026-03-16 2026-04-02 2026-04-03 +2026-05-01 2026-09-16 2026-11-16 2026-12-25 ``` Add more ISO dates (`YYYY-MM-DD`) to `HOLIDAYS` in `worktime.js`. Change hours per day with `HOURS_PER_DAY` in the same file. diff --git a/index.html b/index.html index a11b21d..3e6466e 100644 --- a/index.html +++ b/index.html @@ -83,8 +83,9 @@

Horas laborales

- Festivos 2025: 1 ene, 3 feb, 17 mar, 17–18 abr, 1 may, 16 sep, 18 nov, - 25 dic. Edita la lista en worktime.js. + Festivos 2026: 1 ene, 2 feb, 16 mar, 2–3 abr, 1 may, 16 sep, 16 nov, + 25 dic. También hay fechas de 2025. Edita la lista en + worktime.js.

diff --git a/worktime.js b/worktime.js index c0d5e2b..64a5b01 100644 --- a/worktime.js +++ b/worktime.js @@ -7,7 +7,7 @@ var HOURS_PER_DAY = 8; - // Full calendar dates from the MAUI holydays list (year included). + // Year-specific Mexican federal holidays plus Holy Thursday and Good Friday. var HOLIDAYS = [ "2025-01-01", "2025-02-03", @@ -18,6 +18,15 @@ "2025-09-16", "2025-11-18", "2025-12-25", + "2026-01-01", + "2026-02-02", + "2026-03-16", + "2026-04-02", + "2026-04-03", + "2026-05-01", + "2026-09-16", + "2026-11-16", + "2026-12-25", ]; function parseIsoDate(iso) { diff --git a/worktime.test.js b/worktime.test.js index 752c999..e0f271a 100644 --- a/worktime.test.js +++ b/worktime.test.js @@ -26,6 +26,38 @@ test("May 1 2025 (Thu holiday) is excluded", () => { assert.equal(W.countWorkingDays("2025-04-30", "2025-05-02"), 2); }); +test("Jan 1 2026 (Thu holiday) is 0 working days", () => { + assert.equal(W.countWorkingDays("2026-01-01", "2026-01-01"), 0); + assert.equal(W.formatHmm(W.expectedHours("2026-01-01", "2026-01-01")), "0:00"); +}); + +test("Jan 1–7 2026 excludes New Year and the weekend (4 days / 32:00)", () => { + // 1=Thu holiday, 2 work, 3–4 weekend, 5–7 work + assert.equal(W.countWorkingDays("2026-01-01", "2026-01-07"), 4); + assert.equal(W.formatHmm(W.expectedHours("2026-01-01", "2026-01-07")), "32:00"); +}); + +test("Feb 2 2026 (Mon holiday) is excluded", () => { + assert.equal(W.countWorkingDays("2026-02-02", "2026-02-02"), 0); + assert.equal(W.countWorkingDays("2026-02-02", "2026-02-03"), 1); +}); + +test("Mar 16 2026 (Mon holiday) is excluded", () => { + assert.equal(W.countWorkingDays("2026-03-16", "2026-03-16"), 0); +}); + +test("Apr 2–3 2026 (Holy Thursday and Good Friday) are excluded", () => { + assert.equal(W.countWorkingDays("2026-04-01", "2026-04-03"), 1); +}); + +test("May 1 2026 (Fri holiday) is excluded", () => { + assert.equal(W.countWorkingDays("2026-04-30", "2026-05-04"), 2); +}); + +test("Nov 16 2026 (Mon holiday) is excluded", () => { + assert.equal(W.countWorkingDays("2026-11-16", "2026-11-16"), 0); +}); + test("start after end is invalid", () => { assert.equal(W.countWorkingDays("2025-02-01", "2025-01-01"), null); const r = W.calculate("2025-02-01", "2025-01-01", "8:00");