UNPKG

@scmmishra/business-hours

Version:
73 lines (71 loc) 2.49 kB
/** * Represents a scheduler that manages working hours and holidays. */ declare class Scheduler { private hours; private holidays; /** * Creates a new instance of the Scheduler. * @param config - The configuration object containing working hours and holidays. */ constructor(config: { hours: { [day: number]: Array<{ start: string; end: string; }> | null; }; holidays: Date[]; }); /** * Checks if a given date is a working day. * @param date - The date to check. * @returns True if the date is a working day, false otherwise. */ isWorkingDay(date: Date): boolean; /** * Checks if a given date and time is within working hours. * @param date - The date and time to check. * @returns True if the date and time is within working hours, false otherwise. */ isWorkingTime(date: Date): boolean; /** * Checks if a given date is a holiday. * @param date - The date to check. * @returns True if the date is a holiday, false otherwise. */ isHoliday(date: Date): boolean; nextWorkingTime(date: Date): Date; /** * Get the next working day after a given date. * @param date - The date after which the next working day is calculated. * @returns The next working day as a Date object. */ nextWorkingDay(date: Date): Date; /** * Get the remaining working time for a given date. * @param date - The date for which the remaining working time is calculated. * @returns The remaining working time in seconds. */ getRemainingWorkingTime(date: Date): number; /** * Get the elapsed working time for a given date. * @param date - The date for which the elapsed working time is calculated. * @returns The elapsed working time in seconds. */ getElapsedWorkingTime(date: Date): number; /** * Add a specified number of seconds to a given date. * @param date - The date to which the seconds are added. * @param seconds - The number of seconds to add. * @returns A new Date object with the added seconds. */ addTime(date: Date, seconds: number): Date; /** * Get the working hours for a given date. * @param date - The date for which the working hours are retrieved. * @returns The working hours for the given date. */ private getWorkingHours; } export { Scheduler };