getWeek

Commons
stable

Returns the ISO-like week number (1–53) of a date, computed via the configured DateAdapter. The algorithm aligns with the ISO 8601 definition: weeks start on Monday and week 1 contains the first Thursday of the year.

API

Signature

Full TypeScript signature sourced from the util file.

typescript

API

Parameters

Input parameters accepted by this util.

adapter
required
DateAdapter
The active date adapter instance. Provides the toJsDate() conversion so the function is date-library agnostic.
value
required
any
A date value in the format understood by the adapter (native Date, ISO string, or library-specific object).

API

Return value

The value returned by this util.

The week number (1–53) of the given date.

Usage

Examples

Ready-to-paste usage snippets.

Get week number with the native adapter

typescript