startOfWeek
Commons
stable
Return a new Date rewound to the first day of the week containing the given date. The first day of week is derived from the locale (or from an explicit override).
API
Signature
Signature TypeScript complète, extraite du fichier util.
API
Paramètres
Paramètres d'entrée acceptés par cet util.
- daterequisDate
- The reference date. The function walks backwards until the weekday matches the first-day-of-week.
- localerequisstring
- A BCP 47 locale string used to look up the first day of week (e.g. "en-US" → Sunday, "fr-FR" → Monday).
- firstDayOfWeeknumber
- Explicit override (0 = Sunday … 6 = Saturday). When provided, the locale lookup is skipped.
API
Valeur de retour
La valeur retournée par cet util.
- A new Date at the start of the week (same time as the input date).
Usage
Exemples
Extraits de code prêts à coller.
Find Monday from any day (fr-FR locale)