{
  "schemaVersion": 1,
  "slug": "birthday-countdown-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "72492770ada235e454e2c517960fac064e80960ef8456f9f16f3b24baec67ce0",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/birthday-countdown-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": "d = (t_next − t_today) ÷ 86 400 000 ms; weeks = d/7; hours = 24d; months = d/30.4375",
    "vars": [
      [
        "t_today",
        "Today at UTC midnight"
      ],
      [
        "t_next",
        "Next birthday on/after today"
      ],
      [
        "d",
        "Whole days remaining"
      ],
      [
        "weeks",
        "Weeks remaining"
      ],
      [
        "hours",
        "Hours remaining"
      ],
      [
        "months",
        "Approximate months (30.4375 d)"
      ]
    ]
  },
  "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": "72492770ada235e454e2c517960fac064e80960ef8456f9f16f3b24baec67ce0",
    "basis": "d = (t_next − t_today) ÷ 86 400 000 ms; weeks = d/7; hours = 24d; months = d/30.4375",
    "limitations": "The references explain definitions and methods; any extra preset must be checked against the assumptions on this page."
  },
  "contract": {
    "compute": "const valid=s=>{const m=/^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(String(s));if(!m)return false;const x=new Date(s+'T00:00:00Z');return Number.isFinite(x.getTime())&&x.getUTCFullYear()===+m[1]&&x.getUTCMonth()+1===+m[2]&&x.getUTCDate()===+m[3]};const bad={days:null,weeks:null,hours:null,weekends:null,months:null,__error:'inputError'};if(!valid(birthDate))return bad;const b=new Date(birthDate+'T00:00:00Z'),now=new Date();now.setUTCHours(0,0,0,0);if(b>now)return bad;const birthday=y=>b.getUTCMonth()===1&&b.getUTCDate()===29&&new Date(Date.UTC(y,1,29)).getUTCMonth()!==1?new Date(Date.UTC(y,2,1)):new Date(Date.UTC(y,b.getUTCMonth(),b.getUTCDate()));let y=now.getUTCFullYear(),next=birthday(y);if(next<now)y++;next=birthday(y);const days=Math.round((next-now)/86400000);let weekends=0;for(let t=now.getTime()+86400000;t+86400000<next.getTime();t+=86400000)if(new Date(t).getUTCDay()===6)weekends++;return{days,weeks:days/7,hours:days*24,weekends,months:days/30.4375};",
    "inputs": [
      {
        "name": "birthDate",
        "type": "date",
        "default": "1990-06-15",
        "step": 1
      }
    ],
    "outputs": [
      {
        "name": "days",
        "precision": 0,
        "unit": "days"
      },
      {
        "name": "weeks",
        "precision": 1,
        "unit": "weeks"
      },
      {
        "name": "hours",
        "precision": 0,
        "unit": "h"
      },
      {
        "name": "weekends",
        "precision": 1,
        "unit": "weekends"
      },
      {
        "name": "months",
        "precision": 1,
        "unit": "months"
      }
    ],
    "interpret": null
  }
}
