dutyhours
Version:
A tool to calculate total working hours in a given month, taking into account public holidays and configurable working days.
118 lines (116 loc) • 2.96 kB
TypeScript
interface Options {
/**
* The country code to determine the public holidays. In ISO 3166-1 alpha-2 format.
* For example, 'US' for United States, 'PL' for Poland, etc.
* @type {string}
*/
country: string;
/**
* The number of working hours in a single working day.
* @type {number}
* @default 8
*
*/
hoursPerDay?: number;
/**
* Whether to include Mondays as working days.
* @type {boolean}
* @default true
*/
withMondays?: boolean;
/**
* Whether to include Tuesdays as working days.
* @type {boolean}
* @default true
*/
withTuesdays?: boolean;
/**
* Whether to include Wednesdays as working days.
* @type {boolean}
* @default true
*/
withWednesdays?: boolean;
/**
* Whether to include Thursdays as working days.
* @type {boolean}
* @default true
*/
withThursdays?: boolean;
/**
* Whether to include Fridays as working days.
* @type {boolean}
* @default true
*/
withFridays?: boolean;
/**
* Whether to include Saturdays as working days.
* @type {boolean}
* @default false
*/
withSaturdays?: boolean;
/**
* Whether to include Sundays as working days.
* @type {boolean}
* @default false
*/
withSundays?: boolean;
/**
* Whether to exclude Mondays from working days.
* @type {boolean}
* @default false
*/
withoutMondays?: boolean;
/**
* Whether to exclude Tuesdays from working days.
* @type {boolean}
* @default false
*/
withoutTuesdays?: boolean;
/**
* Whether to exclude Wednesdays from working days.
* @type {boolean}
* @default false
*/
withoutWednesdays?: boolean;
/**
* Whether to exclude Thursdays from working days.
* @type {boolean}
* @default false
*/
withoutThursdays?: boolean;
/**
* Whether to exclude Fridays from working days.
* @type {boolean}
* @default false
*/
withoutFridays?: boolean;
/**
* Whether to exclude Saturdays from working days.
* @type {boolean}
* @default true
*/
withoutSaturdays?: boolean;
/**
* Whether to exclude Sundays from working days.
* @type {boolean}
* @default true
*/
withoutSundays?: boolean;
/**
* The month (indexed from 1 to 12) to calculate working hours for. Defaults to the current month.
* @type {number}
*/
month?: number;
/**
* The year to calculate working hours for. Defaults to the current year.
* @type {number}
*/
year?: number;
}
/**
* Calculates the total number of working hours in a given month.
* @param options Configuration options
* @returns Total working hours
*/
declare function calculateWorkingHours(options: Options): number;
export { type Options, calculateWorkingHours as default };