{
  "address": "ba61dd5e94e9a11e09edcd2c2a586080",
  "category": "other",
  "question": "What is the ISO 8601 week number for 2024-01-01?",
  "answer": "2024-W01",
  "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": "Data elements and interchange formats -- Information interchange -- Representation of dates and times",
      "url": null
    },
    {
      "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": "standard",
    "value": "ISO 8601:2004",
    "retrieved_utc": "2026-09-30T19:41:35Z"
  },
  "qsha256": "dbb4ef316004cfed3526d77fe0a3013c82392ec91e1f5c3062090338bd104a2b",
  "runOne": null,
  "cardContractVersion": "card_contract/1",
  "deck_id": "method-deck",
  "deck_title": "Method Deck",
  "method": {
    "name": "ISO week number",
    "version": "1",
    "source_url_or_file": "methods/iso-week-number.cjs",
    "sha256_of_method_file": "9ce6bb2d01774de5e101abdc48014d2a5a7629ed433f89c8db84b2c91bf95f72"
  },
  "receipt": {
    "inSubstrate": false,
    "local": true,
    "modelCallsAtMint": 0,
    "tokensAtMint": 0
  },
  "method_deck": {
    "inputs": [
      {
        "name": "date",
        "type": "string",
        "format": "date",
        "required": true,
        "description": "ISO 8601 date, YYYY-MM-DD"
      }
    ],
    "outputs": [
      {
        "name": "iso_year",
        "description": "ISO week-numbering year (may differ from the calendar year near year boundaries)"
      },
      {
        "name": "iso_week",
        "unit": "week",
        "description": "ISO week number, 1 to 53"
      }
    ],
    "steps": [
      "Parse the date as a proleptic Gregorian civil date and find its ISO weekday (Monday=1 .. Sunday=7) from the day-number modulo 7 (Hinnant days_from_civil, cited above), calibrated against 1970-01-01 being a Thursday.",
      "Find the Thursday of the same ISO week: subtract (iso_weekday - 4) days from the date's day-number.",
      "The ISO week-numbering year is the calendar year that Thursday falls in.",
      "iso_week = floor((Thursday's day-number - day-number of January 1 of the ISO week-numbering year) / 7) + 1."
    ],
    "constants": [],
    "examples": [
      {
        "name": "worked example",
        "inputs": {
          "date": "2024-01-01"
        },
        "expected": {
          "answer": "2024-W01"
        },
        "check": "2024-01-01 is a Monday, so it starts the ISO week containing the year's first Thursday (Jan 4), which is week 1"
      },
      {
        "name": "test vector: date belongs to prior ISO year",
        "inputs": {
          "date": "2016-01-01"
        },
        "expected": {
          "answer": "2015-W53"
        },
        "check": "2016-01-01 is a Friday; its week's Thursday (Dec 31, 2015) falls in 2015, and 2015 has 53 ISO weeks"
      },
      {
        "name": "test vector: year with 53 ISO weeks",
        "inputs": {
          "date": "2020-12-31"
        },
        "expected": {
          "answer": "2020-W53"
        },
        "check": "2020-12-31 is a Thursday, so it is the anchor day of its own ISO week; 2020 is a 53-week ISO year"
      }
    ],
    "disclaimer": null,
    "deck_category": "dates"
  },
  "status": "minted",
  "kind": "method",
  "provenanceClass": "own_question",
  "provenance": {
    "schema": "card_provenance/2.0.0",
    "chain": [
      {
        "source": {
          "kind": "standard",
          "value": "ISO 8601:2004",
          "retrieved_utc": "2026-09-30T19:41:35Z"
        },
        "sha256": "9bc3caa12448b8499cc05944576414581209723274dab31cc35b06722457d99f",
        "supersedes": null,
        "added_utc": "2026-09-30T22:39:30.722Z",
        "added_by": "method:ISO week number",
        "why": "the method that computed this answer",
        "check": null,
        "status_label": "pending",
        "signature": null
      }
    ]
  }
}
