---
title: "Working Days"
description: "WorkCalendar, an immutable calendar of working days with the weekend and the holidays that are given to it"
type: "docs"
category: "doc"
tags: []
authors: [Anonymous]
date: "2026-11-05"
last_update: "2026-11-05"
time_minutes: 2
draft: false
unlisted: false
url: "https://www.derafu.dev/docs/core/date/working-days"
---

# Working Days

```php
use Derafu\Date\ValueObject\WorkCalendar;
```

A `WorkCalendar` knows which days are not working days: the days of the week that are weekend and the holidays. It does not change: the `with*()` methods give another calendar.

The holidays depend on the country and the year, so the package does not bring them: whoever uses the calendar gives them.

```php
use Derafu\Date\Enum\Weekday;

$calendar = new WorkCalendar(
    holidays: ['2025-01-01', '2025-05-01'],
    weekend: [Weekday::SATURDAY, Weekday::SUNDAY],   // the default
);
```

The holidays are dates or texts written as `Y-m-d` (another text is an `InvalidDateException`). They are kept sorted and without repeating.

## Ask

| Method | What it does |
| --- | --- |
| `isHoliday($date)` | Whether the date is a holiday. |
| `isWorkingDay($date)` | Whether it is not weekend and not a holiday. |
| `addWorkingDays($date, $days)` | The date some working days later (earlier, if negative). The time is kept. |
| `subtractWorkingDays($date, $days)` | The date some working days earlier. |
| `getWorkingDayNumber($date)` | The number of a working day in its month (the first is 1), or `null` if the date is not a working day. |
| `getNthWorkingDay($month, $number)` | The date of the working day of a [month](months) with a number, or `null` if the month does not have so many. A number less than 1 is an `InvalidDateException`. |
| `isLastWorkingDay($date)` | Whether it is the last working day of its month. |
| `countWorkingDays($from, $to)` | The working days of a range, both ends included. |
| `getHolidays()`, `getWeekend()` | What the calendar was given. |

```php
$calendar->addWorkingDays('2025-01-03', 1);               // 2025-01-06 (Monday)
$calendar->getNthWorkingDay(Month::of(2025, 3), 1);       // 2025-03-03 (March 1 is a Saturday)
$calendar->getWorkingDayNumber('2025-03-03');             // 1
```

## Other calendars

```php
$calendar->withHolidays(['2026-01-01']);                      // other holidays, same weekend
$calendar->withWeekend([Weekday::FRIDAY, Weekday::SATURDAY]); // other weekend, same holidays
```



---
Last updated on 05/11/2026

