This function calculates the number of days (working days, weekends, holidays, etc.) between two dates. It is based on the business-days-js library. It is mainly used for the US, but with modifications to the library, it can also support other countries
- File:
calculateBusinessDays.mjs - Function: handler
- Runtime: NodeJS (e.g., 20)
- Function handler: calculateBusinessDays.handler
- Input parameters:
- startDate (\Date): start date
- endDate (\Date): end date
- state (\Text): state (optional,US: two-letter state abbreviation)
- excludeHolidays (\Text): excludeHolidays (optional, names of holidays separated by commas that you want to exclude, for example: Juneteenth, Independence Day)
- customHolidays (\Text): customHolidays (optional, names of custom holidays provided in the following way: MM-DD,NameOfHoliday for example: 06-01,Holiday1;07-01,Holiday2)
- Output parameters:
- Type: Text
Create zip file.
In Pega Launchpad:
- Select Runtime: NodeJS
- Upload the zip file to Code bundle
- Set Function handler to
calculateBusinessDays.handler - Configure the input and output parameters as described above