oui-kit
Version:
🎯 *UI toolkit with a French touch* 🇫🇷
33 lines (32 loc) • 2 kB
TypeScript
import { DayValue } from 'zeed';
export type PeriodType = 'day' | 'week' | 'month' | 'year' | 'custom';
export declare const firstDayOfWeek: any;
export declare const today: number;
/**
* Compute the start day of the week for a given day.
*
* Given a DayValue, this function returns the DayValue that corresponds to the
* first day of the week containing that day. The first day of the week is
* controlled by `firstDayOfWeek` (0 = Sunday, 1 = Monday, ...), matching
* JavaScript's Date.getDay() indexing. An `offset` may be provided to move
* the result by whole weeks: 0 returns the start of the current week,
* 1 returns the start of the next week, -1 the start of the previous week, etc.
*
* @param {DayValue} [day] - The input day (defaults to today).
* @param {number} [offset] - Number of weeks to shift the computed week start.
* @param {number} [firstDayOfWeek] - Index of the week's first day (0 = Sunday).
*
* @returns {DayValue} The DayValue representing the first day of the (offset) week.
*
* @remarks
* Internally converts the DayValue to a Date, computes the weekday delta
* relative to `firstDayOfWeek`, and applies a day offset (offset * 7 + correction).
* This relies on the project's helpers (dayToDate, dayOffset) and preserves the
* project's DayValue representation.
*/
export declare function dayWeekStart(day?: number, offset?: number, firstDayOfWeek?: number): DayValue;
export declare function dayMaxToday(day: DayValue, maxToday?: boolean): DayValue;
export declare function dayRangeWeek(day?: number, offset?: number, firstDayOfWeek?: number, maxToday?: boolean): [DayValue, DayValue];
export declare function dayRangeMonth(day?: number, offset?: number, maxToday?: boolean): [DayValue, DayValue];
export declare function dayRangeYear(day?: number, offset?: number, maxToday?: boolean): [DayValue, DayValue];
export declare function dayRangePeriod(startDay: DayValue, endDay: DayValue, offset: number, periodType?: PeriodType): [DayValue, DayValue];