Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 3 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ <h1>Horas laborales</h1>
</div>
</dl>
<p class="note">
Festivos 2025: 1 ene, 3 feb, 17 mar, 17–18 abr, 1 may, 16 sep, 18 nov,
25 dic. Edita la lista en <code>worktime.js</code>.
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
<code>worktime.js</code>.
</p>
</section>

Expand Down
11 changes: 10 additions & 1 deletion worktime.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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) {
Expand Down
32 changes: 32 additions & 0 deletions worktime.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading