UNPKG

banking-holidays

Version:

A TypeScript package for detecting banking holidays in USA, Puerto Rico, and Dominican Republic

88 lines (66 loc) 2.26 kB
# Banking Holiday Detection A TypeScript package for detecting banking holidays in USA, Puerto Rico (PR), and Dominican Republic (RD). ## Installation ```bash npm install packages ``` ## Usage ```typescript import { getDateStatus, isHoliday, isWorkingDay, getHolidays } from 'packages'; // Check if a date is a holiday and get its status const status = getDateStatus('2024-01-01', 'USA'); console.log(status); // { // isHoliday: true, // holiday: { name: "New Year's Day", date: "2024-01-01", ... }, // isWorkingDay: false, // isWeekend: false // } // Check if a date is a working day const isWorking = isWorkingDay('2024-01-02', 'USA'); console.log(isWorking); // true // Check if a date is a holiday const isHoliday = isHoliday('2024-07-04', 'USA'); console.log(isHoliday); // { isHoliday: true, holiday: { name: "Independence Day", ... } } // Get all holidays for a country const holidays = getHolidays({ country: 'USA' }); console.log(holidays.map(h => h.name)); // ["New Year's Day", "Martin Luther King Jr. Day", ...] ``` ## Features - Check if a specific date is a banking holiday - Check if a date is a working day (not weekend and not holiday) - Check if a date is a weekend - Get all holidays for a specific country - Filter holidays by date range - Supports USA, Puerto Rico (PR), and Dominican Republic (RD) - Proper timezone handling for each country ## API ### getDateStatus(date: string | Date, country: Country): DateStatus Returns complete status of a date including holiday and working day information. ### isHoliday(date: string | Date, country: Country): HolidayResponse Returns whether a date is a holiday and the holiday details if it is. ### isWorkingDay(date: string | Date, country: Country): boolean Returns whether a date is a working day (not weekend and not holiday). ### getHolidays(options?: HolidayOptions): Holiday[] Returns holidays based on the provided options. ## Development 1. Clone the repository 2. Install dependencies: ```bash npm install ``` 3. Build the package: ```bash npm run build ``` 4. Run tests: ```bash npm test ``` ## Scripts - `npm run build` - Build the package - `npm test` - Run tests - `npm run dev` - Watch mode for development ## License ISC