{
  "schemaVersion": 1,
  "slug": "days-until-new-year-calculator",
  "category": "date-time",
  "kind": "implementation",
  "independentValidation": false,
  "implementationHash": "521cfa08300334a953bbda1f4c32e1e9426586268c3c951b52da207c8813e943",
  "provenance": "Generated from the calculation contract used by the published page. Publication is not external validation.",
  "sourceFiles": [
    "data/calculators/days-until-new-year-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 = (Jan 1(Y+1) − today) ÷ 86400000 + e",
    "vars": [
      [
        "Y",
        "Current calendar year"
      ],
      [
        "D",
        "Days left in year"
      ],
      [
        "e",
        "Include-today flag (0/1)"
      ]
    ],
    "note": "Weeks = D÷7; complete weekends counts full Saturday–Sunday pairs in the selected remaining range; “days left in year” follows the include-today setting."
  },
  "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": "521cfa08300334a953bbda1f4c32e1e9426586268c3c951b52da207c8813e943",
    "basis": "D = (Jan 1(Y+1) − today) ÷ 86400000 + e",
    "limitations": "The references explain definitions and methods; any extra preset must be checked against the assumptions on this page."
  },
  "contract": {
    "compute": "const DAY=86400000;const now=new Date();now.setUTCHours(0,0,0,0);const ny=new Date(Date.UTC(now.getUTCFullYear()+1,0,1));const base=Math.round((ny-now)/DAY);const days=base+(includeToday?1:0);const start=new Date(now.getTime()+(includeToday?0:DAY));let weekends=0;for(let d=new Date(start.getTime());d<ny;d.setUTCDate(d.getUTCDate()+1)){if(d.getUTCDay()===6&&new Date(d.getTime()+DAY)<ny)weekends++;}return {days,weeks:days/7,weekends,daysLeftInYear:days};",
    "inputs": [
      {
        "name": "includeToday",
        "type": "select",
        "default": 0,
        "options": [
          {
            "value": 0
          },
          {
            "value": 1
          }
        ]
      }
    ],
    "outputs": [
      {
        "name": "days",
        "precision": 0,
        "unit": "days"
      },
      {
        "name": "weeks",
        "precision": 0,
        "unit": "weeks"
      },
      {
        "name": "weekends",
        "precision": 1,
        "unit": "weekends"
      },
      {
        "name": "daysLeftInYear",
        "precision": 0,
        "unit": "days"
      }
    ],
    "interpret": null
  }
}
