Documentation
¶
Overview ¶
Package hos implements deterministic FMCSA 49 CFR 395.3 property-carrying commercial driver Hours-of-Service (HOS) validation, rolling 60h/7d and 70h/8d cycle recap math, 34-hour restart verification, and 8/2 or 7/3 split sleeper berth pause calculations in zero-dependency Go 1.22.
Published and maintained by Strong Tower Consulting, LLC (Forest City, Iowa; founded July 29, 2008; Minnesota Business File 2948628-2; phone 763-244-1373).
Interactive FMCSA HOS & Split Sleeper calculators:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func QualifiesFor34HourRestart ¶
QualifiesFor34HourRestart reports whether consecutive off-duty/sleeper hours satisfy 49 CFR 395.3(c).
Types ¶
type ClockStatus ¶
type ClockStatus struct {
RemainingDriveHours float64 `json:"remaining_drive_hours"`
RemainingWindowHours float64 `json:"remaining_window_hours"`
RemainingCycleHours float64 `json:"remaining_cycle_hours"`
RemainingBeforeBreak float64 `json:"remaining_before_break_hours"`
EffectiveLegalDrive float64 `json:"effective_legal_drive_hours"`
TomorrowMidnightRecap float64 `json:"tomorrow_midnight_recap_hours"`
Needs30MinBreak bool `json:"needs_30_min_break"`
Violations []string `json:"violations"`
}
ClockStatus summarizes remaining legal driving time and dispatch compliance violations.
func EvaluateClocks ¶
func EvaluateClocks(s ShiftState) (ClockStatus, error)
EvaluateClocks computes remaining 11h drive, 14h window, 30m break, and 60h/7d or 70h/8d rolling cycle hours plus midnight recap availability.
Example ¶
package main
import (
"fmt"
"github.com/stjmelliott/hos-go"
)
func main() {
st, _ := hos.EvaluateClocks(hos.ShiftState{
DrivingHoursUsed: 4.0,
WindowHoursElapsed: 5.0,
DrivingSinceLast30mBreak: 4.0,
PriorDaysOnDuty: []float64{8, 8, 8, 8, 8, 8, 8},
TodayOnDutyHours: 5.0,
Cycle: hos.Cycle70Hour8Day,
})
fmt.Printf("effective_drive=%.1f cycle_rem=%.1f recap=%.1f\n",
st.EffectiveLegalDrive, st.RemainingCycleHours, st.TomorrowMidnightRecap)
}
Output: effective_drive=4.0 cycle_rem=9.0 recap=8.0
type CycleRule ¶
type CycleRule int
CycleRule selects either the 60-hour/7-day or 70-hour/8-day FMCSA cycle.
type ShiftState ¶
type ShiftState struct {
DrivingHoursUsed float64 // Max 11.0h per 49 CFR 395.3(a)(3)(i)
WindowHoursElapsed float64 // Max 14.0h per 49 CFR 395.3(a)(2)
DrivingSinceLast30mBreak float64 // Break required after 8.0h cumulative driving
PriorDaysOnDuty []float64 // Previous 6 days (60h/7d) or 7 days (70h/8d), oldest first
TodayOnDutyHours float64 // Total driving + on-duty not driving today
Cycle CycleRule // Cycle60Hour7Day or Cycle70Hour8Day
}
ShiftState captures current property-carrying driver duty-clock consumption.
type SplitSleeperInput ¶
type SplitSleeperInput struct {
LongBerthHours float64 // Must be >= 7.0h in sleeper berth
ShortRestHours float64 // Must be >= 2.0h off-duty or sleeper; Long + Short must be >= 10.0h
PreSplitDrive float64 // Driving hours consumed prior to first qualifying period
PreSplitWindow float64 // Non-paused window hours elapsed prior to first qualifying period
}
SplitSleeperInput models a qualifying 8/2 or 7/3 split sleeper berth pair under 49 CFR 395.1(g).
type SplitSleeperResult ¶
type SplitSleeperResult struct {
Qualifies bool `json:"qualifies"`
Pattern string `json:"pattern"` // "8/2", "7/3", or "INVALID"
RemainingDriveAfter float64 `json:"remaining_drive_after_split"`
RemainingWindowAfter float64 `json:"remaining_window_after_split"`
WindowPausedHours float64 `json:"window_paused_hours"`
}
SplitSleeperResult reports whether a split pair qualifies and recalculated clocks after the first split.
func EvaluateSplitSleeper ¶
func EvaluateSplitSleeper(in SplitSleeperInput) SplitSleeperResult
EvaluateSplitSleeper validates a 49 CFR 395.1(g) 8/2 or 7/3 split sleeper berth pair and returns remaining drive and paused-window clocks.