UNPKG

kenya-holidays

Version:

A simple package to retrieve all Kenyan public holidays for a given year

105 lines (80 loc) 2.83 kB
# Kenya Holidays A simple npm package to get all Kenyan public holidays for a given year. ## Installation ```bash npm install kenya-holidays ``` ## Usage ### Basic Usage ```javascript const { getKenyanHolidays } = require('kenya-holidays'); // Get holidays for the current year const holidays = getKenyanHolidays(); console.log(holidays); // Get holidays for a specific year const holidays2024 = getKenyanHolidays(2024); console.log(holidays2024); // Get formatted dates (YYYY-MM-DD) const formattedHolidays = getKenyanHolidays(null, true); console.log(formattedHolidays); ``` ### Detailed Holiday Information ```javascript const { getDetailedKenyanHolidays } = require('kenya-holidays'); // Get detailed holiday information for the current year const detailedHolidays = getDetailedKenyanHolidays(); console.log(detailedHolidays); // Example output: // [ // { // name: "New Year's Day", // date: "2025-01-01", // type: "National", // description: "Celebrates the start of the new year", // isVariable: false // }, // ... // ] ``` ### Check if a Date is a Holiday ```javascript const { isKenyanHoliday } = require('kenya-holidays'); // Check if a specific date is a holiday const holiday = isKenyanHoliday('2025-12-25'); if (holiday) { console.log(`${holiday.date} is ${holiday.name} (${holiday.type})`); console.log(`Description: ${holiday.description}`); } else { console.log('Not a holiday'); } // You can also pass a Date object const dateObj = new Date(2025, 11, 25); // December 25, 2025 const christmasHoliday = isKenyanHoliday(dateObj); console.log(christmasHoliday); // Returns holiday info ``` ## Features - Get all Kenyan public holidays for any year (past, present, or future) - Accurately calculates Easter-based holidays (Good Friday, Easter Monday) for any year - Option to get dates in JavaScript Date objects or formatted strings - Notes for variable Islamic holidays (Eid al-Fitr, Eid al-Adha) - Detailed holiday information including type and description - Flexible API with both simple and detailed output formats ## Holiday List The package includes the following Kenyan public holidays: 1. New Year's Day - January 1 2. Good Friday - Variable date (calculated) 3. Easter Monday - Variable date (calculated) 4. Labour Day - May 1 5. Madaraka Day - June 1 6. Huduma Day - October 10 7. Mashujaa Day - October 20 8. Jamhuri Day - December 12 9. Christmas Day - December 25 10. Boxing Day - December 26 11. Utamaduni Day - December 27 12. Eid al-Fitr* - Variable date (Islamic calendar) 13. Eid al-Adha* - Variable date (Islamic calendar) 14. Diwali* - Variable date (sometimes declared a public holiday) *Note: Islamic holidays depend on the lunar calendar and may vary. The package provides a note for these dates rather than calculating them. ## License MIT