# Working time

> Shade non-working hours and days on the timeline, mark weekends, show the current time and enforce business hours when users edit.

Planners make better decisions when the timeline shows when people are actually available. The scheduler shades time outside working hours, can shade weekends on their own, and draws a line at the current time.

## Working hours and days

`workingTime` describes the working week:

| Field | Type | Description |
| --- | --- | --- |
| `days` | `number[]` | Working weekdays, using JavaScript's numbering: `0` is Sunday, `1` Monday, through `6` Saturday. |
| `startHour` | `number` | Start of the working day, from `0` to `24`. Fractions are minutes: `7.5` is 07:30. |
| `endHour` | `number` | End of the working day. `17.25` is 17:15, and `24` means the day runs to midnight. |

**`WorkingTime`** (interface from `@birchui/scheduler`, full reference: https://docs.birchui.com/api/scheduler.md)

```ts
interface WorkingTime
```

| Property | Type | Description |
| --- | --- | --- |
| `days` | `number[]` |  |
| `startHour` | `number` |  |
| `endHour` | `number` |  |

```ts
import { createScheduler } from '@birchui/scheduler';

createScheduler(container, {
  resources: technicians,
  events: jobs,
  start: '2026-12-07T05:00',
  end: '2026-12-07T21:00',
  viewPreset: 'hourAndDay',
  workingTime: { days: [1, 2, 3, 4, 5], startHour: 7.5, endHour: 17 },
});
```

With this configuration:

- On Monday to Friday, time before 07:30 and after 17:00 is shaded.
- Saturday and Sunday are shaded completely.
- Hours are read on the scheduler's clock, in its `timeZone`, so the shading stays at 07:30 to 17:00 local time even across a daylight saving change. See [Time zones](https://docs.birchui.com/scheduler/time-zones.md#daylight-saving-time).

Some common working weeks:

```ts
const officeWeek = { days: [1, 2, 3, 4, 5], startHour: 9, endHour: 17.5 };
const retailWeek = { days: [1, 2, 3, 4, 5, 6], startHour: 8, endHour: 20 };
const middleEastWeek = { days: [0, 1, 2, 3, 4], startHour: 8, endHour: 16 };
const roundTheClock = { days: [0, 1, 2, 3, 4, 5, 6], startHour: 0, endHour: 24 };
```

> **Warning**
>
> The working window lies within a single day: `startHour` must be at least 0, `endHour` at most 24, and `startHour` lower than `endHour`. An overnight window such as `startHour: 22, endHour: 6` is rejected with a console warning and shading is turned off. For night shifts, use `roundTheClock` and show the shifts as events.

## Weekends only

Without `workingTime`, the scheduler shades weekends: `weekendDays` defaults to `[0, 6]`, Sunday and Saturday. To shade other days, such as Friday and Saturday, list them yourself:

```ts
createScheduler(container, {
  resources: meetingRooms,
  events: bookings,
  start: '2026-12-01',
  end: '2027-01-01',
  viewPreset: 'dayAndMonth',
  weekendDays: [5, 6],
});
```

`weekendDays` applies only when `workingTime` is not set. When both are given, `workingTime.days` decides which days are shaded. Pass `weekendDays: []` to turn weekend shading off.

Hour-level shading needs room: it is drawn only while an hour is at least 2 pixels wide. In `'weekAndMonth'` and `'monthAndYear'` you see whole non-working days only.

## Change working time at runtime

Both options can be updated without recreating the scheduler:

```ts
seasonSelect.addEventListener('change', () => {
  scheduler.update({
    workingTime:
      seasonSelect.value === 'winter'
        ? { days: [1, 2, 3, 4, 5, 6], startHour: 7, endHour: 19 }
        : { days: [1, 2, 3, 4, 5], startHour: 8, endHour: 17 },
  });
});

scheduler.update({ workingTime: null, weekendDays: [] });
```

The second call turns shading off entirely.

## Enforce working hours

Shading is visual. Users can still drop an event onto shaded time. To prevent that, check proposed times in `validateDrop` and `validateResize`. [Keep jobs inside working hours](https://docs.birchui.com/scheduler/interactions.md#keep-jobs-inside-working-hours) has a complete example that reads the local weekday and hour in the scheduler's time zone.

Working time is the same for every resource. If people have individual availability, such as part-time technicians or rooms that close early on Fridays, store it on the resource and check it in the validators:

```ts
import { createScheduler, type SchedulerResource } from '@birchui/scheduler';

interface Technician extends SchedulerResource {
  availableDays: number[];
}

const ZONE = 'America/Chicago';
const WEEKDAYS = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const weekdayFormat = new Intl.DateTimeFormat('en-US', { timeZone: ZONE, weekday: 'short' });
const localWeekday = (date: Date) => WEEKDAYS.indexOf(weekdayFormat.format(date));

const technicians: Technician[] = [
  { id: 'tech-amira', name: 'Amira Haddad', availableDays: [1, 2, 3, 4, 5] },
  { id: 'tech-priya', name: 'Priya Natarajan', availableDays: [1, 3, 5] },
];

createScheduler(container, {
  resources: technicians,
  events: jobs,
  start: '2026-12-07',
  end: '2026-12-12',
  viewPreset: 'dayAndWeek',
  timeZone: ZONE,
  workingTime: { days: [1, 2, 3, 4, 5], startHour: 8, endHour: 17 },
  validateDrop: ({ start, resource }) => !resource || resource.availableDays.includes(localWeekday(start)),
});
```

## The "now" line

A line marks the current time whenever it falls inside the visible range. Set `showNowLine: false` to hide it. Pass `now` to pin the marker to a fixed time, which is useful for demos, screenshots and visual tests:

```ts
createScheduler(container, {
  resources,
  events,
  start: '2026-12-07T05:00',
  end: '2026-12-07T21:00',
  viewPreset: 'hourAndDay',
  workingTime: { days: [1, 2, 3, 4, 5], startHour: 7.5, endHour: 17 },
  now: '2026-12-07T11:40',
});
```

## Styling

Shading and the now line use the theme's custom properties, so they follow the light and dark themes automatically. Override them on the scheduler or any ancestor:

```css
.dispatch-board {
  --lq-sched-nonworking-bg: rgb(15 23 42 / 0.06);
  --lq-sched-now-color: #c2410c;
}
```

Shaded spans are `.lq-sched-shade` elements and the now line is `.lq-sched-now`. [Event rendering](https://docs.birchui.com/scheduler/event-rendering.md#theming) lists every scheduler token.

## Next steps

- [Drag, drop, resize and create](https://docs.birchui.com/scheduler/interactions.md#validation) for validation.
- [Time zones](https://docs.birchui.com/scheduler/time-zones.md) for how local hours are computed.
