API reference
getWeekYear
API index · Input types and conventions · Installation
getWeekYear(value, options?) → number
Return the year that owns the selected week. This may differ from value.year near New Year. Use the same weekStartsOn and firstWeekContainsDate options as getWeek.
import { getWeekYear } from '@frantss/temporal-fns';
getWeekYear(Temporal.PlainDate.from('2025-12-31')); // => 2026
getWeekYear(Temporal.PlainDate.from('2021-01-01'), {
weekStartsOn: 1,
firstWeekContainsDate: 4,
}); // => 2020
getWeekYear(Temporal.PlainDate.from('2026-01-01'), {
firstWeekContainsDate: 7,
}); // => 2025Related: getWeek, isSameISOWeek, startOfYear.
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-011: Calendar queries use a zoned value's local calendar fields.