parseWeekFromDateTime
Signature
Section titled “Signature”parseWeekFromDateTime(value: string, optionsArg?: { weekStartsOn?: "monday" | "sunday"; }): number | nullReturn the week number for a given ISO 8601 datetime string.
- The week is the week of the week-year, 1–53, under either numbering — see
getWeekNumber. - Returns null for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value | string | ISO 8601 datetime string |
Options
Section titled “Options”optionsArg
How weeks are numbered
| Option | Type | Default | Description |
|---|---|---|---|
weekStartsOn? | "monday" | "sunday" | "monday" | The first day of the week, which sets how the week is numbered. "monday" gives the ISO 8601 week number, where week 1 holds the year’s first Thursday; "sunday" gives the UTS #35 week number with a Sunday first day and one minimal day, where week 1 holds 1 January. Any other value returns null. |
Returns
Section titled “Returns”Week number (1-53) or null on invalid input
Examples
Section titled “Examples”import { parseWeekFromDateTime } from "@northguild/gmt/plain/parse";
parseWeekFromDateTime("2024-01-01T12:00:00") // 1