Skip to main content

Function: clippedWeeksInPeriod()

clippedWeeksInPeriod(period, weekStartsOn?): ClippedWeek[]

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

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) or 'sunday' (the pay engine uses Sunday weeks so they align with how overage is detected and approved — see the overage flow, which keys everything on sundayWeekStart).

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 US/billing weeks.

Returns

ClippedWeek[]

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