{
  "schemaVersion": 1,
  "slug": "for-time-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "3168fd5773662fef69d75375580a2a008453410dbdb5993127f064eb3f5b3250",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/for-time-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": "h12 = { 12, h mod 12 = 0; h mod 12, h mod 12 ≠ 0 }; p = { AM, h < 12; PM, h ≥ 12 }; t12 = h12:m:s + p",
    "vars": [
      [
        "h",
        "hour, 0–23"
      ],
      [
        "m",
        "minute, 0–59"
      ],
      [
        "s",
        "second, 0–59"
      ],
      [
        "h12",
        "12-hour clock hour"
      ],
      [
        "p",
        "period marker (AM/PM)"
      ],
      [
        "t12",
        "12-hour time string"
      ]
    ],
    "note": "Inputs are floored and clamped before display, then zero-padded to two digits; AM applies before noon (h < 12), PM after."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const h = Math.min(23, Math.max(0, Math.floor(Number(hours))));\nconst m = Math.min(59, Math.max(0, Math.floor(Number(minutes))));\nconst s = Math.min(59, Math.max(0, Math.floor(Number(seconds))));\nconst pad = function (v) { return String(v).padStart(2, '0'); };\nconst h12 = h % 12 === 0 ? 12 : h % 12;\nreturn {\n  time24: pad(h) + ':' + pad(m) + ':' + pad(s),\n  time12: pad(h12) + ':' + pad(m) + ':' + pad(s) + ' ' + (h < 12 ? 'AM' : 'PM'),\n  period: h < 12 ? 'AM' : 'PM',\n};",
    "inputs": [
      {
        "name": "hours",
        "type": "number",
        "default": 9,
        "min": 0,
        "max": 23,
        "step": 1,
        "slider": true
      },
      {
        "name": "minutes",
        "type": "number",
        "default": 5,
        "min": 0,
        "max": 59,
        "step": 1,
        "slider": true
      },
      {
        "name": "seconds",
        "type": "number",
        "default": 0,
        "min": 0,
        "max": 59,
        "step": 1,
        "slider": true
      }
    ],
    "outputs": [
      {
        "name": "time24",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "time12",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "period",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
