{
  "schemaVersion": 1,
  "slug": "timesheet-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "55644d9585fe95b27ff1169bffcd3746057a548ce46993ca3a6d9d0902c77d08",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/timesheet-calculator.json",
    "src/engine.js"
  ],
  "runtimeSource": "/sources/engine.txt",
  "runtimeHash": "5c888d8898afbdee36267bb9977829e1e2ac568f6677c8ee87469c139864645c",
  "scope": "The compute function records implemented equations, constants, lookup tables and custom rules. Inputs record defaults and allowed values; outputs record precision and units. Defaults are examples, not recommendations. General background references are not evidence for this specific algorithm.",
  "publishedFormula": {
    "formula": "H = max(0, ((b − a) mod 1440) − B) ÷ 60 × n; P = R × min(H,40) + R × k × max(H−40,0)",
    "vars": [
      [
        "a",
        "Start (minutes after midnight)"
      ],
      [
        "b",
        "End (minutes)"
      ],
      [
        "B",
        "Daily break (min)"
      ],
      [
        "n",
        "Workdays"
      ],
      [
        "R",
        "Hourly rate"
      ],
      [
        "k",
        "Overtime multiplier"
      ]
    ],
    "note": "Overtime threshold is fixed at 40 hours; times are parsed as HH:MM or HH.MM."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const toMin = (s)=>{ const m = String(s==null?'':s).trim().match(/^(\\d{2}):(\\d{2})$/); if(!m) return null; const h=+m[1], mi=+m[2]; if(h>23 || mi>59) return null; return h*60+mi; }; const a=toMin(startTime), b=toMin(endTime); const invalid={dailyHours:null,totalHours:null,regularHours:null,overtimeHours:null,grossPay:null,__error:'inputError'}; if(a===null || b===null) return invalid; let diff=b-a; if(diff<0) diff+=1440; if(breakMinutes>diff) return invalid; const daily=Math.max(0,diff-breakMinutes)/60; const total=daily*days; const regular=Math.min(total,40), ot=Math.max(0,total-40); return {dailyHours:daily,totalHours:total,regularHours:regular,overtimeHours:ot,grossPay:regular*hourlyRate+ot*hourlyRate*overtimeMultiplier};",
    "inputs": [
      {
        "name": "startTime",
        "type": "text",
        "default": "09:00",
        "step": 1
      },
      {
        "name": "endTime",
        "type": "text",
        "default": "17:30",
        "step": 1
      },
      {
        "name": "breakMinutes",
        "type": "number",
        "default": 30,
        "min": 0,
        "max": 480,
        "step": 5,
        "slider": true
      },
      {
        "name": "days",
        "type": "number",
        "default": 5,
        "min": 1,
        "max": 7,
        "step": 1,
        "slider": true
      },
      {
        "name": "hourlyRate",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 10000,
        "step": 0.5
      },
      {
        "name": "overtimeMultiplier",
        "type": "number",
        "default": 1.5,
        "min": 1,
        "max": 3,
        "step": 0.1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "totalHours",
        "precision": 2,
        "unit": "h"
      },
      {
        "name": "grossPay",
        "precision": 2,
        "unit": "USD"
      },
      {
        "name": "dailyHours",
        "precision": 2,
        "unit": "h"
      },
      {
        "name": "regularHours",
        "precision": 2,
        "unit": "h"
      },
      {
        "name": "overtimeHours",
        "precision": 2,
        "unit": "h"
      }
    ],
    "interpret": null
  }
}
