parseWeekFromUnix
Signature
Section titled “Signature”parseWeekFromUnix(value: string | number, options?: { epochUnit?: UnixUnit; timeZone?: string; weekStartsOn?: "monday" | "sunday"; }): numberimport { parseWeekFromUnix } from "@northguild/gmt/unix/parse";Return the week number from a unix epoch value.
- By default uses ISO weeks (Monday-based).
- Returns null for invalid input.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
value |
string | number |
unix epoch in milliseconds or seconds (number or string) |
Options
Section titled “Options”options
| Option | Type | Default |
|---|---|---|
epochUnit? |
UnixUnit |
— |
timeZone? |
string |
— |
weekStartsOn? |
"monday" | "sunday" |
— |
Returns
Section titled “Returns”Week number (1-53) or null on invalid input
Related types
Section titled “Related types”Examples
Section titled “Examples”parseWeekFromUnix(1704067200000) // 1parseWeekFromUnix(1704067200000, { weekStartsOn: "sunday" }) // 1parseWeekFromUnix(-86400, { epochUnit: "seconds" }) // 1