{
  "address": "3d77e7f4e0dfc44e663cbae03f9e76d8",
  "category": "other",
  "question": "How many days are there between 2024-01-01 and 2024-01-10, not counting either date?",
  "answer": "9",
  "askedBy": {
    "kind": "guest",
    "display": "method deck",
    "stamped": false,
    "id": null
  },
  "answeredBy": "method",
  "madeAt": "2026-09-30T22:39:30.722Z",
  "validUntil": null,
  "validityClass": "forever",
  "sources": [
    {
      "label": "chrono-Compatible Low-Level Date Algorithms",
      "url": "https://howardhinnant.github.io/date_algorithms.html"
    }
  ],
  "supersedes": null,
  "supersededBy": null,
  "isSeed": false,
  "seedSource": null,
  "seedAttribution": null,
  "duplicateOfQid": null,
  "publishedAt": null,
  "unpublishedAt": null,
  "voteCount": 0,
  "queuedForSubstrate": false,
  "answerMethod": "method",
  "unsourced": false,
  "source": {
    "kind": "url",
    "value": "https://howardhinnant.github.io/date_algorithms.html",
    "retrieved_utc": "2026-09-30T19:41:35Z"
  },
  "qsha256": "e77254b926eddcf8d4ea0a06b695f12c5cd10247fecec1d747d9d183530bf6be",
  "runOne": null,
  "cardContractVersion": "card_contract/1",
  "deck_id": "method-deck",
  "deck_title": "Method Deck",
  "method": {
    "name": "Days between two dates",
    "version": "1",
    "source_url_or_file": "methods/days-between-dates.cjs",
    "sha256_of_method_file": "f413db031783d3260f0209a36522852b6256538df83124578c6cd4d910fcc633"
  },
  "receipt": {
    "inSubstrate": false,
    "local": true,
    "modelCallsAtMint": 0,
    "tokensAtMint": 0
  },
  "method_deck": {
    "inputs": [
      {
        "name": "date_a",
        "type": "string",
        "format": "date",
        "required": true,
        "description": "Earlier ISO 8601 date, YYYY-MM-DD"
      },
      {
        "name": "date_b",
        "type": "string",
        "format": "date",
        "required": true,
        "description": "Later or equal ISO 8601 date, YYYY-MM-DD"
      },
      {
        "name": "inclusive",
        "type": "boolean",
        "required": true,
        "description": "If true, count both date_a and date_b as elapsed days; if false, count only the nights between them"
      }
    ],
    "outputs": [
      {
        "name": "days",
        "unit": "days",
        "description": "Number of days between the two dates under the chosen rule"
      }
    ],
    "steps": [
      "Parse date_a and date_b as proleptic Gregorian civil dates (year, month, day).",
      "Convert each date to a Julian Day Number (JDN) using the Fliegel and Van Flandern (1968) day-count method, implemented here via the equivalent Hinnant days_from_civil algorithm (cited above).",
      "Require date_b to be on or after date_a; otherwise the inputs are invalid.",
      "diff = JDN(date_b) - JDN(date_a). This is the exclusive count: the number of nights, or day-boundaries crossed, between the two dates.",
      "If inclusive is true, days = diff + 1 (both endpoint calendar days are counted). If inclusive is false, days = diff."
    ],
    "constants": [],
    "examples": [
      {
        "name": "worked example",
        "inputs": {
          "date_a": "2024-01-01",
          "date_b": "2024-01-10",
          "inclusive": false
        },
        "expected": {
          "answer": "9"
        },
        "check": "independently counted: Jan 2, 3, 4, 5, 6, 7, 8, 9, 10 is 9 elapsed days after Jan 1"
      },
      {
        "name": "test vector: inclusive count",
        "inputs": {
          "date_a": "2024-01-01",
          "date_b": "2024-01-10",
          "inclusive": true
        },
        "expected": {
          "answer": "10"
        },
        "check": "same span plus 1 for counting the start date itself"
      },
      {
        "name": "test vector: leap day crossing",
        "inputs": {
          "date_a": "2024-02-28",
          "date_b": "2024-03-01",
          "inclusive": false
        },
        "expected": {
          "answer": "2"
        },
        "check": "2024 is a leap year, so the span is Feb 28 -> Feb 29 -> Mar 1, which is 2 days"
      }
    ],
    "disclaimer": null,
    "deck_category": "dates"
  },
  "status": "minted",
  "kind": "method",
  "provenanceClass": "own_question",
  "provenance": {
    "schema": "card_provenance/2.0.0",
    "chain": [
      {
        "source": {
          "kind": "url",
          "value": "https://howardhinnant.github.io/date_algorithms.html",
          "retrieved_utc": "2026-09-30T19:41:35Z"
        },
        "sha256": "45311b765154988b00c30fc6a55064b248dee3949b6e69e68d234040c0c9a795",
        "supersedes": null,
        "added_utc": "2026-09-30T22:39:30.722Z",
        "added_by": "method:Days between two dates",
        "why": "the method that computed this answer",
        "check": null,
        "status_label": "pending",
        "signature": null
      }
    ]
  }
}
