Skip to main content

Function: clippedWeeksInPeriod()

clippedWeeksInPeriod(period, weekStartsOn?): ClippedWeek[]

Defined in: src/lib/dates/index.ts:443

Split a period into weeks, each clipped to the period. The first and last weeks may be partial (fewer than 7 days). The clipped weeks tile the period exactly — their days sum to the period's total day count — which is what lets the pay engine allocate the bi-monthly rate by each week's share without losing a centavo.

weekStartsOn chooses the week boundary: 'monday' (ISO weeks, default — billing and pay both key on the Mon–Sun week, ADR-0044) or 'sunday' (legacy US weeks, retained for back-compat only).

Parameters

period

BiMonthlyPeriod

The bi-monthly period to tile into clipped weeks.

weekStartsOn?

"monday" | "sunday"

Week anchor: 'monday' for ISO weeks (default) or 'sunday' for legacy US weeks.

Returns

ClippedWeek[]

Ordered, non-overlapping ClippedWeeks covering the period exactly; their days values sum to inclusiveDays(period.start, period.end).