{
  "schemaVersion": 1,
  "slug": "military-time-converter",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "0c07a8a44e56be1700fe7d545c420d44570f99f3148cb2e841d73d9950b04d21",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/military-time-converter.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": "min = 60h₂₄ + m; h₁₂ = {12, h₂₄ mod 12 = 0; h₂₄ mod 12, h₂₄ mod 12 ≠ 0}; L = {AM, h₂₄ < 12; PM, h₂₄ ≥ 12}",
    "vars": [
      [
        "h₂₄",
        "hour 0–23"
      ],
      [
        "h₁₂",
        "hour 1–12"
      ],
      [
        "m",
        "minute 0–59"
      ],
      [
        "min",
        "minutes from midnight"
      ],
      [
        "L",
        "AM/PM label"
      ]
    ],
    "note": "Rules: PM adds 12 when h < 12; AM at 12 becomes 0. Output is zero-padded hh:mm."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "MDN — Date and UTC calendar operations",
        "url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date"
      }
    ],
    "referenceRole": "definition",
    "implementationHash": "0c07a8a44e56be1700fe7d545c420d44570f99f3148cb2e841d73d9950b04d21",
    "basis": "min = 60h₂₄ + m; h₁₂ = {12, h₂₄ mod 12 = 0; h₂₄ mod 12, h₂₄ mod 12 ≠ 0}; L = {AM, h₂₄ < 12; PM, h₂₄ ≥ 12}",
    "limitations": "The references explain definitions and methods; any extra preset must be checked against the assumptions on this page."
  },
  "contract": {
    "compute": "const raw=String(time).trim().toUpperCase();const m=raw.match(/^(\\d{1,2}):(\\d{2})(?:\\s*(AM|PM))?$/);if(!m)return{result:null,military:null,standard:null,minutesFromMidnight:null,__error:'inputError'};let h=Number(m[1]),min=Number(m[2]);const mer=m[3];if(min>59||(mer?(h<1||h>12):(h>23)))return{result:null,military:null,standard:null,minutesFromMidnight:null,__error:'inputError'};if(mer){if(mer==='PM'&&h<12)h+=12;if(mer==='AM'&&h===12)h=0}const pad=n=>String(n).padStart(2,'0'),mil=pad(h)+':'+pad(min),std=(h%12||12)+':'+pad(min)+(h<12?' AM':' PM');return{result:direction==='to12'?std:mil,military:mil,standard:std,minutesFromMidnight:h*60+min}",
    "inputs": [
      {
        "name": "time",
        "type": "text",
        "default": "14:30",
        "step": 1
      },
      {
        "name": "direction",
        "type": "select",
        "default": "to12",
        "options": [
          {
            "value": "to12"
          },
          {
            "value": "to24"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "result",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "military",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "standard",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "minutesFromMidnight",
        "precision": 0,
        "unit": "min"
      }
    ],
    "interpret": null
  }
}
