time_week_number
Calculate week numbers for any date or find start and end dates of a week under ISO, US, simple, or CDC epi week numbering schemes. Supports week number to date conversion and week count per year.
Instructions
Week Number Calculator. Pure deterministic week-numbering over UTC with no clock/now dependency — every date or week is supplied by the caller. operation "fromDate" returns the week number and week-year of a calendar date under all four schemes at once (ISO 8601 = Monday-start, week 1 holds Jan 4 / the first Thursday; US = Sunday-start, week 1 holds Jan 1; simple = Jan 1-7 is week 1; epi/MMWR CDC = Sunday-start, week 1 has at least 4 days in the new year). operation "toDate" maps a (scheme, year, week) back to that week's start and end dates; "weeksInYear" returns 52/53/54 for a scheme+year; "weekRange" returns the full list of dates in a week. Use this for ISO week numbers or week-to-date conversion; use time_day_of_week for the weekday name of a date and time_date_calculator for adding/subtracting durations or business days. Read-only, non-destructive, idempotent, offline-capable, rate-limited (60 req/min anonymous), no auth. Result is wrapped as operation plus data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | Yes | "fromDate": week numbers for a date (needs year/month/day). "toDate": start/end dates of a week (needs scheme/year/week). "weeksInYear": week count for a scheme+year (needs scheme/year). "weekRange": every date in a week (needs scheme/year/week). | |
| scheme | No | Week-numbering scheme. Required for toDate, weeksInYear, and weekRange; ignored by fromDate (which returns all four). iso = ISO 8601 Monday-start; us = Sunday-start week 1 holds Jan 1; simple = Jan 1-7 is week 1; epi = MMWR/CDC. | iso |
| year | No | Calendar year in the proleptic Gregorian calendar. Required for every operation. | |
| month | No | Month 1-12. Required when operation is fromDate. | |
| day | No | Day 1-31; must be a real calendar date. Required when operation is fromDate. | |
| week | No | Week number 1-54; must not exceed the scheme/year week count. Required when operation is toDate or weekRange. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| operation | No | The operation that was run, echoed back (fromDate, toDate, weeksInYear, or weekRange). | |
| data | No | Result payload; shape depends on operation. |