API reference
getWeek
API index · Input types and conventions · Installation
getWeek(value, options?) → number
Return the 1-based week number within the week-year selected by weekStartsOn and firstWeekContainsDate. Week 1 contains January's firstWeekContainsDate. Use both options { weekStartsOn: 1, firstWeekContainsDate: 4 } for ISO numbering.
import { getWeek } from '@frantss/temporal-fns';
getWeek(Temporal.PlainDate.from('2025-12-31')); // => 1
getWeek(Temporal.PlainDate.from('2026-01-04')); // => 2
getWeek(Temporal.PlainDate.from('2021-01-01'), {
weekStartsOn: 1,
firstWeekContainsDate: 4,
}); // => 53Related: getWeekYear, getWeekOfMonth, isSameWeek.
Behaviors: CAL-006: Week numbers and their week-years are a pair; CAL-007: Every week-start and first-week anchor combination follows the containing week rule; CAL-010: First-week anchors are dates from 1 through 7; CAL-013: Every week-grid query validates its weekday boundary.