Workforce
Workforce is people’s working time, for any crew, shift or rota. It is counted in duty days that need not start at midnight, in rolling windows that slide across the log, and in rests that may be split in two. A working-time regime is a set of numbers, and the caller states every one of them. This layer reads a duty log against those numbers, and holds none of its own.
What these functions solve
Section titled “What these functions solve”- A duty day does not start at midnight. An operator names the time its day starts and the zone it is read in.
dutyDayForreturns the day an instant falls in, so a log is grouped by the operator’s day and never by the calendar’s. See guide, scenario. - A sliding window is not a calendar day. A rule that asks for a rest in any stretch of a given length looks at every such stretch, not at each day on its own.
evaluateDutyLogchecks every rule at one instant, anddutyTotalsadds up the time spent in the statuses you name inside a window. See guide, scenario, mistakes. - Two short rests may count as one, or may not. A regime that lets a rest be split sets a floor for each part and for the two together.
qualifyingRestPairsfinds the pairs that meet all of the floors you state, so a pair that meets only two of them is not counted. See scenario, mistakes. - A log has to be checked before it is counted. A log with overlapping entries, or an entry that ends before it starts, gives a total that looks right and is not.
isValidDutyLogtells whether every function in this layer accepts the log. See guide, mistakes.
Start with the guide: Workforce: Hours of Work.
Its own functions
Section titled “Its own functions”dutyDayFor: Return the operator-designated day an instant falls in: from the most recentdayStartTimeintimeZoneat or before the instant, up to (not including) the next one.dutyTotals: Return the time a duty log spends in any ofstatusesinside a window, as an exact ISO 8601 duration.dutyViolations: Return every violation of a set of hours-of-work rules inside a range, each with the window that failed it: the record over a month, not the check before dispatch.evaluateDutyLog: Evaluate every hours-of-work rule over a duty log at one instant, and report each one whether or not it binds.longestRun: Return the longest unbroken stretch a duty log spends in any ofstatusesinside a window.qualifyingRestPairs: Return every paired rest in a duty log: two separate rests that together count as one, because they meet all three floors ofspec.pair.qualifyingRests: Return every rest of at leastminimumin a duty log: the runs of touching entries in any ofspec.statusesthat last that long.
isValidDutyLog: Validate whether a value is a duty log everyworkforce/function accepts.
Guides
Section titled “Guides”- Workforce: Hours of Work: Evaluate hours-of-work rules over a duty log with the workforce layer — caps, windows, breaks, rests, quotas and patterns, every number yours — and read the day the operator designates, not local midnight.
Scenarios
Section titled “Scenarios”- A Paired Rest That Does Not Qualify: Two rests may count as one when each is at least 2 hours, one at least 7 and both together at least 10. Checking two whole numbers passes 6 + 4 and fails 7.5 + 2.5 — both wrong.
- A Sliding Window Is Not a Calendar Day: A rule asks for 10 hours of rest in any 24. Each calendar day of the log holds 10, so a per-day check passes, but the 24 hours ending at 06:00 hold 4.
- The Duty Day Is Not Midnight: An operator’s day starts at 04:00 in São Paulo. Grouping a driver’s log by local midnight puts a 03:30 entry in the wrong day, and an entry logged in Tokyo in the wrong day again.
Mistakes
Section titled “Mistakes”- Workforce: Common mistakes when checking a duty log against hours-of-work rules with GMT’s workforce/ namespace.
Accessibility
© 2026 NorthGuild · Licences
Code examples: MIT-0. Packages: MIT. Third-party data and components: their own licences, credited where they appear. Everything else: © 2026 NorthGuild, all rights reserved.