{
  "schemaVersion": 1,
  "slug": "days-until-christmas-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "a3777fe13d9a323c1029377ed10d350ea1b4760b1b76c6c2881539ca356a8126",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/days-until-christmas-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 = (Dec 25 − today) ÷ 86400000 + e",
    "vars": [
      [
        "D",
        "Days until Christmas"
      ],
      [
        "e",
        "Include-today flag (0/1)"
      ]
    ],
    "note": "If Dec 25 has passed this year, next year’s date is used. Weeks = D÷7, months = D÷30.4375; shopping days are counted day by day excluding Sundays only."
  },
  "externalEvidence": null,
  "contract": {
    "compute": "const DAY=86400000; const now=new Date(); now.setUTCHours(0,0,0,0); let year=now.getUTCFullYear(); let xmas=new Date(Date.UTC(year,11,25)); if(xmas < now){ year++; xmas=new Date(Date.UTC(year,11,25)); } let days = Math.round((xmas-now)/DAY); if(includeToday) days += 1; let shopping=0; const cur=new Date(now.getTime()); while(cur < xmas){ const d=cur.getUTCDay(); if(d!==0) shopping++; cur.setUTCDate(cur.getUTCDate()+1); } return { days, weeks: days/7, months: days/30.4375, shoppingDays: shopping };",
    "inputs": [
      {
        "name": "includeToday",
        "type": "select",
        "default": 0,
        "options": [
          {
            "value": 0
          },
          {
            "value": 1
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "days",
        "precision": 0,
        "unit": "days"
      },
      {
        "name": "weeks",
        "precision": 1,
        "unit": "weeks"
      },
      {
        "name": "months",
        "precision": 1,
        "unit": "months"
      },
      {
        "name": "shoppingDays",
        "precision": 0,
        "unit": "days"
      }
    ],
    "interpret": null
  }
}
