{
  "schemaVersion": 1,
  "slug": "deadline-calculator",
  "category": "productivity",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "7fbd3b7ffabd7fd060885c4c904abb3696b9e75b31dcbf20a5ce95db742e545c",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/deadline-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 = E(1 + b ÷ 100)(1 + 0.15R); d_w = ⌈H ÷ h⌉; L = due − (d_w + v)d",
    "vars": [
      [
        "E",
        "Estimated hours"
      ],
      [
        "b",
        "Buffer percent"
      ],
      [
        "R",
        "Revision rounds"
      ],
      [
        "H",
        "Total hours"
      ],
      [
        "h",
        "Hours per workday"
      ],
      [
        "d_w",
        "Working days needed"
      ],
      [
        "v",
        "Review days"
      ],
      [
        "d",
        "One day in milliseconds (86400000)"
      ],
      [
        "due",
        "Due date"
      ],
      [
        "L",
        "Latest start date"
      ]
    ],
    "note": "Required days are rounded up after buffer and revision adjustments. Weekday-only mode counts backward while skipping Saturdays and Sundays for work and review; holidays are not modeled."
  },
  "externalEvidence": {
    "reviewedAt": "2026-10-12",
    "sources": [
      {
        "name": "GAO — Schedule estimating, contingency and risk",
        "url": "https://www.gao.gov/products/gao-16-89g"
      }
    ],
    "referenceRole": "context",
    "implementationHash": "7fbd3b7ffabd7fd060885c4c904abb3696b9e75b31dcbf20a5ce95db742e545c",
    "basis": "H = E(1 + b ÷ 100)(1 + 0.15R); d_w = ⌈H ÷ h⌉; L = due − (d_w + v)d",
    "limitations": "The references provide context and limitations. They do not validate this page’s illustrative multipliers, lookup values or predictions."
  },
  "contract": {
    "compute": "const validDate=s=>/^\\d{4}-\\d{2}-\\d{2}$/.test(s)&&!Number.isNaN(new Date(s+'T00:00:00Z').getTime())&&new Date(s+'T00:00:00Z').toISOString().slice(0,10)===s;const vals=[estimatedHours,hoursPerDay,buffer,revisionRounds,reviewDays];if(vals.some(v=>!Number.isFinite(v))||estimatedHours<0.5||estimatedHours>5000||hoursPerDay<0.5||hoursPerDay>24||buffer<0||buffer>100||revisionRounds<0||revisionRounds>10||!Number.isInteger(revisionRounds)||reviewDays<0||reviewDays>60||!Number.isInteger(reviewDays)||!['yes','no'].includes(workingDaysOnly)||!validDate(dueDate))return {totalHours:null,workDays:null,latestStart:null,calendarDays:null,feasible:null,note:null,__error:'inputError'};const totalHours=estimatedHours*(1+buffer/100)*(1+revisionRounds*0.15),workDays=Math.ceil(totalHours/hoursPerDay),day=86400000,latest=new Date(dueDate+'T00:00:00Z');let remaining=workDays+reviewDays;while(remaining>0){latest.setUTCDate(latest.getUTCDate()-1);const dow=latest.getUTCDay();if(workingDaysOnly!=='yes'||(dow!==0&&dow!==6))remaining--;}const fmt=d=>d.toISOString().slice(0,10),today=new Date();today.setUTCHours(0,0,0,0);const calendarDays=Math.floor((latest-today)/day);return {totalHours,workDays,latestStart:fmt(latest),calendarDays,feasible:calendarDays>=0?'Yes — you have '+calendarDays+' days before the latest start':'Tight — the latest start has already passed, so start now',note:workingDaysOnly==='yes'?'Weekends are skipped when counting work and review days':'Every calendar day counts, including weekends'};",
    "inputs": [
      {
        "name": "dueDate",
        "type": "date",
        "default": "@today+3m",
        "step": 1
      },
      {
        "name": "estimatedHours",
        "type": "number",
        "default": 20,
        "min": 0.5,
        "max": 5000,
        "step": 0.5
      },
      {
        "name": "hoursPerDay",
        "type": "number",
        "default": 3,
        "min": 0.5,
        "max": 24,
        "step": 0.5,
        "slider": true
      },
      {
        "name": "buffer",
        "type": "number",
        "default": 20,
        "min": 0,
        "max": 100,
        "step": 5,
        "slider": true
      },
      {
        "name": "revisionRounds",
        "type": "number",
        "default": 1,
        "min": 0,
        "max": 10,
        "step": 1,
        "slider": true
      },
      {
        "name": "reviewDays",
        "type": "number",
        "default": 2,
        "min": 0,
        "max": 60,
        "step": 1,
        "slider": true
      },
      {
        "name": "workingDaysOnly",
        "type": "select",
        "default": "yes",
        "options": [
          {
            "value": "no"
          },
          {
            "value": "yes"
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "totalHours",
        "precision": 1,
        "unit": "h"
      },
      {
        "name": "workDays",
        "precision": 1,
        "unit": "days"
      },
      {
        "name": "latestStart",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "calendarDays",
        "precision": 0,
        "unit": "days"
      },
      {
        "name": "feasible",
        "precision": 0,
        "unit": "",
        "type": "text"
      },
      {
        "name": "note",
        "precision": 0,
        "unit": "",
        "type": "text"
      }
    ],
    "interpret": null
  }
}
