Sub topic 6
Account for working days and holidays
A Gantt chart plots time on a calendar, but people only work on some calendar days. This chapter shows how to make the schedule respect weekends and holidays, in Mermaid and in Python.
It assumes you can read a Gantt chart and have followed the earlier chapters on durations, dependencies and the forward pass. You also need basic Python (functions, loops, datetime).
Why the calendar matters
Earlier you worked with durations as plain numbers. In the forward pass, "Mockups takes 7 days" meant seven units after Wireframes finished. A real calendar breaks that assumption in three ways:
- A task that starts on Thursday and needs three days does not finish on Saturday. It finishes the following Monday.
- A public holiday in the middle of a task pushes its finish date out by a day, and every task after it moves too.
- Two people can read "10 days" differently. It may mean ten working days or ten elapsed days.
Pick one meaning and state it. The usual convention is that duration is measured in working days. A working day is a day on which the team can do work. Weekends, public holidays and company shutdowns are non-working days. The same task then takes longer on the calendar than its duration suggests.
| Term | Meaning | Example |
|---|---|---|
| Working days (duration) | Days the team works on the task | 7 working days |
| Elapsed (calendar) days | Days from start to finish on the calendar, including days off | 10 calendar days |
| Calendar | The rule that says which days are working days | Monday to Friday, minus listed holidays |
Define the calendar
A calendar has two parts:
- A weekly pattern, usually Monday to Friday.
- A list of exceptions: holidays, shutdown weeks, or extra working Saturdays.
Keep the weekly pattern and the exceptions separate. The weekly pattern rarely changes, but the exception list changes every year.
Some teams do not work Monday to Friday. Many Middle Eastern countries use Sunday to Thursday, and a factory might run six days a week. Treat the weekly pattern as a setting, not a hard-coded assumption.
Use the calendar in Mermaid
Mermaid's Gantt syntax has an excludes setting for non-working days. You can list weekends, named weekdays, or specific dates in YYYY-MM-DD format, separated by commas. Mermaid then skips those days when it lays out bars. A task's duration counts only the days that are not excluded.
gantt
title Website Launch with Calendar
dateFormat YYYY-MM-DD
excludes weekends, 2026-01-19
section Design
Wireframes :done, des1, 2026-01-05, 5d
Mockups :active, des2, after des1, 7d
section Build
Frontend :crit, dev1, after des2, 10d
Launch :milestone, m1, after dev1, 0dThe chart has three points to note:
- Wireframes starts on Monday 5 January and covers five working days, so it ends Friday 9 January.
- Mockups needs seven working days. Monday 19 January is excluded, so the bar stretches across that day and ends on Wednesday 21 January.
- Frontend starts on Thursday 22 January. Its ten working days stretch over two weekends and end on Wednesday 4 February.
On the chart, the bars are wider than their durations suggest because they span the days off.
Some limits to keep in mind:
- Mermaid has a single calendar for the whole chart. You cannot give one task a different weekly pattern.
- Newer Mermaid versions add a
weekendsetting, for exampleweekend fridayfor a Friday and Saturday weekend. Check that your renderer supports it before relying on it. - A task that starts on an excluded day is moved to the next working day. If you type a start date that falls on a Saturday, the bar will not start where you wrote it.
Calculate with the calendar in Python
For a schedule you calculate yourself, you need three small functions. They use only the standard library.
from datetime import date, timedelta
HOLIDAYS = {date(2026, 1, 1), date(2026, 1, 19)}
def is_workday(day, holidays=HOLIDAYS):
"""Monday to Friday, and not a listed holiday."""
return day.weekday() < 5 and day not in holidays
def next_workday(day, holidays=HOLIDAYS):
"""The given day if it is a working day, otherwise the next one."""
while not is_workday(day, holidays):
day += timedelta(days=1)
return day
def finish_date(start, duration, holidays=HOLIDAYS):
"""Last working day of a task that needs `duration` working days."""
day = next_workday(start, holidays)
remaining = duration - 1
while remaining > 0:
day += timedelta(days=1)
if is_workday(day, holidays):
remaining -= 1
return day
start = date(2026, 1, 12)
print(finish_date(start, 7)) # 2026-01-21
print(finish_date(start, 7, holidays=set())) # 2026-01-20The last two lines show the effect of a single holiday. The same seven-day task finishes one day later when 19 January is a day off.
The function counts the start day as day one, so a one-day task starts and finishes on the same date. This is an inclusive finish: the finish date is the last day on which work happens.
The diagram below shows the loop inside finish_date.
The loop steps through calendar days, not working days, and counts only the ones that pass the is_workday test. This is simple and fast enough for any project schedule. A project with thousands of tasks still needs only a few hundred thousand iterations.
Run the forward pass on a calendar
Now apply the calendar to the forward pass from the earlier chapter. The structure stays the same: list predecessors before successors, and start each task after its latest predecessor finishes. Two things change:
- Dates replace integer days.
- The earliest start is the day after the latest predecessor's finish, moved to a working day if needed.
from datetime import date, timedelta
HOLIDAYS = {date(2026, 1, 1), date(2026, 1, 19)}
def is_workday(day, holidays=HOLIDAYS):
return day.weekday() < 5 and day not in holidays
def next_workday(day, holidays=HOLIDAYS):
while not is_workday(day, holidays):
day += timedelta(days=1)
return day
def finish_date(start, duration, holidays=HOLIDAYS):
day = next_workday(start, holidays)
remaining = duration - 1
while remaining > 0:
day += timedelta(days=1)
if is_workday(day, holidays):
remaining -= 1
return day
tasks = {
"Wireframes": (5, []),
"Mockups": (7, ["Wireframes"]),
"Backend": (12, ["Wireframes"]),
"Frontend": (10, ["Mockups"]),
"Integration": (4, ["Frontend", "Backend"]),
}
project_start = date(2026, 1, 5)
start, finish = {}, {}
for name, (duration, preds) in tasks.items():
earliest = max(
(finish[p] + timedelta(days=1) for p in preds),
default=project_start,
)
start[name] = next_workday(earliest)
finish[name] = finish_date(start[name], duration)
print(f"{name:<12}{start[name]} to {finish[name]}")
# Wireframes 2026-01-05 to 2026-01-09
# Mockups 2026-01-12 to 2026-01-21
# Backend 2026-01-12 to 2026-01-28
# Frontend 2026-01-22 to 2026-02-04
# Integration 2026-02-05 to 2026-02-10The critical path is still Wireframes, Mockups, Frontend, Integration, for 26 working days. On the calendar, the project runs from Monday 5 January to Tuesday 10 February, which is 37 calendar days. Weekends and the 19 January holiday account for the difference.
Handle special cases
Durations that run on calendar time
Some waiting periods ignore the working calendar. Concrete cures over a weekend, a vendor ships in five calendar days, and a legal notice period runs on calendar days. For these tasks, add calendar days directly, as in start + timedelta(days=5), and then move the result to the next working day if the next task needs people. Label these tasks clearly on the chart so readers do not assume they follow the team calendar.
Holidays that differ by person or country
One calendar is enough for a team in one place. A team spread across countries has different holidays, and a task assigned to one person can follow that person's calendar. The simplest approach is to give each task a holidays argument. Your finish_date function already accepts one.
Milestones on days off
A milestone has zero duration, so it has no work to place. Decide whether it falls on the last working day of its predecessor or on the next working day after it. A launch milestone on a Saturday is usually a mistake in the schedule, not a real plan.
Part-time and half days
Whole working days are the standard unit. Half days complicate the loop and rarely change a schedule by more than a day. If your team works part-time, change the duration (a 10-hour task for someone working 5 hours a day is 2 days) and keep the calendar in whole days.
Common mistakes with calendars
| Mistake | Effect | Fix |
|---|---|---|
| Adding durations as calendar days | Finish dates land on weekends | Count working days with a calendar function |
| Forgetting a holiday | Every task after it is one day too early | Keep one shared holiday list and review it yearly |
| Start date typed on a weekend | Mermaid shifts it silently | Start tasks on working days |
| Mixing inclusive and exclusive finishes | One-day gaps or overlaps between tasks | Choose one convention for the whole schedule |
| One calendar for a distributed team | Wrong dates for people in other countries | Use a per-task or per-person holiday set |
Check the result
After you apply the calendar, run these checks on every schedule:
- No task starts or finishes on a non-working day, except milestones you placed on purpose.
- Every task's finish is at least its duration in working days after its start.
- The project finish is later than a plain sum along the critical path, whenever the path crosses a weekend or holiday.
- Changing the holiday set moves only the tasks that follow it.
Exercise
Using the HOLIDAYS set from this chapter (1 January and 19 January 2026) and a Monday to Friday week, a 3-day task starts on Friday 16 January 2026. On which date does it finish?
Show answer
It finishes on Wednesday 21 January 2026. Friday 16 January is day one. Saturday 17, Sunday 18 and the holiday on Monday 19 are skipped. Tuesday 20 is day two and Wednesday 21 is day three.
Exercise
A task needs a 4-day paint drying period that runs on calendar days, starting Thursday 22 January 2026, and the next task needs people to work. When can the next task start, and why can you not use finish_date for the drying period?
Show answer
Drying ends after Sunday 25 January (Thursday 22 plus 4 calendar days is Monday 26 January, so the next day the work can begin is Monday 26 January, a working day). finish_date counts only working days, so it would stretch the drying across the weekend and give a later date than reality. Add the calendar days directly and then move to the next working day.
Exercise
Why does the Mermaid chart in this chapter show Mockups as a wider bar than Wireframes even though Mockups is only 2 days longer?
Show answer
Mockups spans a weekend and the excluded holiday on 19 January, so its bar covers 10 calendar days for 7 working days. Wireframes fits inside one working week and covers only its own 5 days.