Functional Weave
Code in TypeScript

fleet.tachograph-rest@1.0.0

README.md

4,932 bytes · view raw

# fleet.tachograph-rest

Status: needs review by a drivers' hours / transport compliance expert before it is published.

Checks a driver's recorded activities for daily and weekly rest under
Article 8 of Regulation (EC) No 561/2006, as it applies in Great Britain
(assimilated law). It counts the daily and weekly rests taken and returns
every breach in time order. Driving and break limits are checked by
`fleet.drivers-hours`, which takes exactly the same input and whose
`DriverActivity` and `HoursBreach` types this capability uses.

## Input

`startDate` and `startTime` are when the first activity starts, and **the
records must begin straight after a weekly rest**: that is when the first
24-hour daily rest window and the six-day weekly rest window open, and the
weekly rest before it is taken to be a regular one. Activities are back to
back; neighbouring rests are merged into one uninterrupted rest. Local
wall-clock time, no time zones.

## How rests are judged

- **Daily rest, Art. 8(2).** Within each 24 hours after the end of the
  previous daily or weekly rest, the driver must have taken a new daily rest.
  Only the part of a rest inside that 24-hour window counts: 11 hours or more
  inside it is a regular daily rest, 9 to 11 hours is reduced, so an 11-hour
  rest that starts 14 hours into the window is a reduced one. A rest of at
  least 3 hours earlier in the same window followed by one with 9 hours inside
  it is a split regular rest (Art. 4(g)); 9 then 3 is a reduced rest followed
  by a break. The next window opens when the qualifying rest ends. If no rest
  of 9 hours starts in the window, that is a `daily-rest` breach at the
  window's end, and checking picks up again after the next rest of 9 hours or
  more.
- **Reduced daily rests, Art. 8(4).** At most three between two weekly rests;
  the fourth and later are `reduced-daily-rest` breaches.
- **Weekly rest, Art. 8(6).** Any rest of 24 hours or more is a weekly rest,
  regular at 45 hours or more, otherwise reduced. It must start no later than
  six 24-hour periods (144 hours) after the previous weekly rest ended, or it
  is `weekly-rest-late`. If the records run past that point with no weekly
  rest at all, the breach is reported at the deadline, unless the records end
  in a rest that began in time and may yet become one.
- **Two reduced weekly rests in a row** are a `reduced-weekly-rest` breach.
  This is a simplification of Art. 8(6) ("in any two consecutive weeks ... two
  regular weekly rest periods, or one regular and one reduced").

| rule | `actual` | `limit` |
|------|----------|---------|
| `daily-rest` | longest rest inside the window, minutes | 540 |
| `reduced-daily-rest` | reduced daily rests since the last weekly rest | 3 |
| `weekly-rest-late` | minutes from the previous weekly rest to the next one (or to the end of the records) | 8640 |
| `reduced-weekly-rest` | length of the second reduced weekly rest, minutes | 2700 |

A rest cut off by the end of the records is judged at the length recorded.

## What it does not do

- Compensation for a reduced weekly rest (Art. 8(6), 8(7)): the lost hours
  must be made up, attached to another rest of 9 hours or more, before the end
  of the third week. Not checked.
- The 2020 amendments for international goods drivers (two consecutive
  reduced weekly rests outside the member state, four-week pattern; return
  home every four weeks; no regular weekly rest in the cab). Not checked.
- Multi-manning (9 hours within 30), ferry and train interruptions (Art. 9),
  the 12-day derogation for occasional passenger services, and the
  exemptions and national derogations.
- GB domestic rules (Transport Act 1968) and AETR.

## Data

The limits are dated rows in `data/rest-limits.json`, effective from 11 April
2007 (Art. 29) and still in force. A date before that is an error.

## Sources

- Regulation (EC) No 561/2006, as it applies in the UK, legislation.gov.uk:
  Article 4(g) and (h) (regular, reduced and split daily rest; regular and
  reduced weekly rest), Article 8(2) (a new daily rest within each 24 hours;
  the portion inside the 24 hours decides whether it is reduced), 8(4) (at
  most three reduced daily rests between two weekly rests), 8(6) (two
  consecutive weeks; weekly rest to start within six 24-hour periods).
  https://www.legislation.gov.uk/eur/2006/561/article/8 and
  https://www.legislation.gov.uk/eur/2006/561/article/4
- DVSA, "Drivers' hours: Assimilated rules" (11 hours, reducible to 9 three
  times between weekly rests; 45 hours weekly, reducible to 24 every other
  week; weekly rest after six consecutive 24-hour periods):
  https://www.gov.uk/drivers-hours/eu-rules
- DVSA, "Drivers' hours and tachographs: goods vehicles", section 1.5 (the
  24-hour period runs from the end of the previous rest; split rest 3 hours
  then 9): https://www.gov.uk/guidance/drivers-hours-goods-vehicles/1-eu-and-aetr-rules-on-drivers-hours