{
  "schemaVersion": 1,
  "slug": "hours-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "f2dd08e798dc83dd458922b4079fde7440e8b4f05a76be3676c14dfc4e33e3af",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/hours-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": "M = (E − S ≤ 0 → E − S + 1440 ; E − S) − B ; H = max(0, M) ÷ 60",
    "vars": [
      [
        "S",
        "start time (minutes after midnight)"
      ],
      [
        "E",
        "end time (minutes after midnight)"
      ],
      [
        "B",
        "unpaid break (minutes)"
      ]
    ],
    "note": "Enter valid 24-hour HH:MM times. An end time before or equal to the start is treated as crossing midnight. The unpaid break must be shorter than the elapsed shift, leaving positive work time."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const parse=(s)=>{ const m=String(s).trim().match(/^(\\d{1,2}):(\\d{2})$/); if(!m) return null; const h=Number(m[1]), min=Number(m[2]); return h <= 23 && min <= 59 ? h*60+min : null; }; const start=parse(startTime), end=parse(endTime); if(start === null || end === null) return { hours: null, minutes: null, decimalHours: null, duration: null, __error: 'inputError' }; let mins=end-start; if(mins <= 0) mins += 1440; mins -= breakMinutes; if(mins <= 0) return { hours: null, minutes: null, decimalHours: null, duration: null, __error: 'inputError' }; return { hours: mins/60, minutes: mins, decimalHours: mins/60, duration: Math.floor(mins/60) + 'h ' + (mins%60) + 'm' };",
    "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": 600,
        "step": 5,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "hours",
        "precision": 2,
        "unit": "h"
      },
      {
        "name": "minutes",
        "precision": 0,
        "unit": "min"
      },
      {
        "name": "decimalHours",
        "precision": 4,
        "unit": "h"
      },
      {
        "name": "duration",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
