All problems

Breaks Outside a Shift Deducted from Paid Time

Level 2 · node · Correctness · Break time outside the shift incorrectly deducted

Scenario

A fictional event staffing system calculates paid minutes from shift start and end times. Breaks are supplied as separate time intervals, and only the portion overlapping the shift should be deducted. The current calculation subtracts the entire break even if part or all of it falls before or after the shift, underpaying workers.

Requirements

Calculate paid minutes as shift duration minus the intersection of the break and shift intervals. A break entirely outside the shift deducts nothing; a partially overlapping break deducts only the overlap. Valid intervals use integer minutes with end greater than start.

Acceptance criteria

  • A break fully inside the shift is deducted completely.
  • A break after the shift is not deducted.
  • A break starting before the shift deducts only the overlapping minutes.
  • Without a break, the entire shift is paid.