gantt-task-react-powern
Version:
Interactive Gantt Chart for React with TypeScript.
50 lines (49 loc) • 2.4 kB
TypeScript
import { CalendarDefinition } from "../types/public-types";
/** Parse "HH:MM" or "HH:MM:SS" into minutes since midnight. */
export declare function parseTimeToMinutes(t: string): number;
/** True if the date falls on a calendar holiday. */
export declare function isHoliday(date: Date, cal: CalendarDefinition): boolean;
/** True if the date's weekday is in off_days or is a holiday. */
export declare function isOffDay(date: Date, cal: CalendarDefinition): boolean;
/** True if the date is a regular working day (not off_day, not holiday). */
export declare function isWorkingDay(date: Date, cal: CalendarDefinition): boolean;
/**
* Returns the shift windows (in minutes since midnight) for a given date.
* Returns [] for off days / holidays.
*/
export declare function getShiftsForDay(date: Date, cal: CalendarDefinition): Array<{
start: number;
end: number;
}>;
/**
* Returns all working time intervals between start and end, respecting:
* - off days and holidays (entire day skipped)
* - shift windows (multiple shifts per day are supported)
* - partial first/last days clipped to the actual start/end time
*/
export declare function getWorkingIntervals(start: Date, end: Date, cal: CalendarDefinition): Array<{
start: Date;
end: Date;
}>;
/**
* Snaps a date to the nearest valid working moment.
* direction "forward" → move forward until inside a shift
* direction "backward" → move backward until inside a shift
* Searches up to 60 days to avoid infinite loops.
*/
export declare function snapToWorkingTime(date: Date, cal: CalendarDefinition, direction: "forward" | "backward"): Date;
/**
* Returns the most recent week-start date on or before the given date,
* where weekStartDay is a JS day index (0=Sun, 1=Mon, ..., 6=Sat).
*/
export declare function getWeekStartDate(date: Date, weekStartDay: number): Date;
/**
* Returns the quarter number (1–4) for a date, given a fiscal quarterStart month (0–11, 0=Jan).
* e.g. quarterStart=4 means Q1 starts in May.
*/
export declare function getQuarterNumber(date: Date, quarterStart: number): number;
/**
* Returns the quarter start month (0-11) for a given date and fiscal quarterStart (0-indexed).
* Useful for labeling (e.g. Q1 starting in May → returns 4).
*/
export declare function getQuarterStartMonth(date: Date, quarterStart: number): number;