sl-date-utils-v1
v1.1.1
Published
Sri Lankan date utilities: holidays, working days, Sinhala calendar & more
Maintainers
Readme
sl-date-utils-v1 🇱🇰
Utility functions for handling Sri Lankan holidays, working days, Sinhala calendar months, and Poya day calculations.
✨ Features
- 🇱🇰 Sri Lanka public holidays (with dynamic multi-year support)
- 🏖️ Filter holidays by category (Public, Bank, Mercantile)
- 📅 Check if a date is a holiday
- 🧮 Calculate working days between two dates (excluding weekends & specific holiday categories)
- 🗓️ Get the Sinhala month for any date
- 🌕 Get the Poya day for a given month
- 🔍 Find all holidays in a given year or month
- ⏩ Get the next upcoming holiday
- 💡 Simple & lightweight
- ✅ Full TypeScript support
📦 Installation
npm install sl-date-utils-v1🚀 Usage
1. Checking Holidays
Check if a specific date is a holiday. Optionally, filter by category:
import { isHoliday } from 'sl-date-utils-v1';
isHoliday("2026-05-01"); // true (May Day)
// Check if it's specifically a mercantile holiday
isHoliday("2026-04-03", ["mercantile"]); // false (Good Friday is Public/Bank only)2. Calculating Working Days
Get the number of working days between two dates. Weekends and holidays are excluded.
import { getWorkingDays } from 'sl-date-utils-v1';
// Get working days (excludes ALL holidays by default)
getWorkingDays("2026-04-01", "2026-04-30");
// Get working days (excludes only Mercantile holidays)
getWorkingDays("2026-04-01", "2026-04-30", ["mercantile"]);3. Extended Holiday Utilities
import { getHolidaysForYear, getHolidaysForMonth, getNextHoliday } from 'sl-date-utils-v1';
// Get all holidays in 2026
const holidays2026 = getHolidaysForYear(2026);
// Get all Bank holidays in April 2026
const aprilBankHolidays = getHolidaysForMonth(2026, 4, ["bank"]);
// Get the next upcoming holiday from a specific date
const next = getNextHoliday("2026-02-10");
console.log(next?.name); // e.g., "Maha Sivarathri Day"4. Sinhala Months & Poya Days
import { getSinhalaMonth, getPoyaDay } from 'sl-date-utils-v1';
getSinhalaMonth("2026-04-14"); // "Bak"
getPoyaDay("2026-05"); // "2026-05-01" (Vesak Poya)