Calendar methods
setDayHours
Description
Sets single day hours
Usage
setDayHours(date: Date, hours: number): void
Parameters
date(Date) - target date (time component ignored)hours(number) - working hours (typically 0-24)
setRangeHours
Description
Sets range hours
Usage
setRangeHours(start: Date, end: Date, hours: number): void
Parameters
start(Date) - start dateend(Date) - end datehours(number) - working hours for each date
isWorkingDay
Description
Checks if a date is a working day
Usage
isWorkingDay(date: Date): boolean
Parameters
date(Date) - date to check (time component ignored)
Returns: true if the date has working hours > 0, false otherwise
getWorkingHours
Description
Gets hours for date
Usage
getWorkingHours(date: Date, end?: Date, excludeEndDate?: boolean): number
Parameters
date(Date) - start dateend(Date) - end dateexcludeEndDate(boolean) - if true, excludes the end date from the range (default: false)
Returns: If the date end is provided, returns total working hours across all dates in range, returns working hours for start date otherwise (0 if non-working)
getWorkingDays
Description
Counts working days
Usage
getWorkingDays(start: Date, end: Date, excludeEndDate?: boolean): number
Parameters
start(Date) - start dateend(Date) - end dateexcludeEndDate(boolean) - if true, excludes the end date from the range (default: false)
Returns: Count of days where working hours > 0
getNextWorkingDay
Description
Finds next working day
Usage
getNextWorkingDay(date: Date): Date | null
Parameters
date(Date) - starting date (excluded from search)
Returns: Date of next working day (hours > 0), or null if no working day found
getPreviousWorkingDay
Description
Finds previos working day
Usage
getPreviousWorkingDay(date: Date): Date | null
Parameters
date(Date) - starting date (excluded from search)
Returns: Date of previous working day (hours > 0), or null if no working day found within maximum iterations limit (365).
addWorkingDays
Description
Adds working days
Usage
addWorkingDays(start: Date, days: number, excludeEndDate?: boolean): Date | null
Parameters
start(Date) - starting date (included in count if it's a working day)days(number) - number of working days to add (positive) or subtract (negative)excludeEndDate(boolean) - if true, last added day can be non-working (default: false)
Returns: Date after adding the specified working days, or null if unable to find enough working days within maximum iterations limit (365).
addRule
Description
Adds custom rule
Usage
addRule(rule: (date) => number): void
Parameters
rule- function that receives date and returns hours or undefined
clone
Description
Creates derived calendar
Usage
clone(config?: CalendarConfig): Calendar
Parameters
config(CalendarConfig) - overrides for cloned calendar. It has the next parameters:name- overrides nameweekHours- overrides week hours
Returns: New Calendar instance with transformed inheritance