getIsoWeekDate
Signature
Section titled “Signature”getIsoWeekDate(value: string): { year: number; week: number; weekday: number; } | nullReturn the ISO 8601 week date — week-numbering year, week and weekday — for value.
- Vessel schedules, production plans and retail reports are published by week number, and a week number alone is ambiguous: the week-numbering year is not the calendar year at either end of a year, so all three fields come back together rather than as three calls a caller could combine inconsistently.
- A week-numbering year has 53 weeks roughly every five to six years, and 52 otherwise.
valuemust be zoneless — an ISO date or datetime, asisValidIsoDateLikeaccepts. An offset, aZor a bracketed zone makes it a moment rather than a calendar date; convert it in the zone you mean first (convertUtcToZonedthenconvertZonedToPlainDateTime), or floor it withfloorToZone.- Returns null on invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | zoneless ISO 8601 date or datetime string (e.g. “2024-06-15”) |
Returns
Section titled “Returns”{ year, week, weekday }, or null on invalid input
Members
| Member | Type | Description |
|---|---|---|
year | number | The ISO 8601 week-numbering year: the calendar year that holds the Thursday of the date’s week. It differs from the date’s own calendar year for some dates in late December and early January. |
week | number | The ISO 8601 week number, 1 through 53. Week 1 is the week that holds the year’s first Thursday, and weeks start on Monday. |
weekday | number | The ISO 8601 day of the week, 1 (Monday) through 7 (Sunday). |
Examples
Section titled “Examples”import { getIsoWeekDate } from "@northguild/gmt/calendar/calculate";
getIsoWeekDate("2024-06-15") // { year: 2024, week: 24, weekday: 6 }