srilanka-calendar
v1.1.0
Published
A comprehensive Sri Lankan calendar library with Poya days, public holidays, Sinhala/Tamil month names, and calendar conversions. Covers 2020–2035.
Downloads
21
Maintainers
Readme
🇱🇰 srilanka-calendar
A comprehensive Sri Lankan calendar library for JavaScript and TypeScript.
Features:
- 🌕 Poya (Full Moon) days — 2020–2030
- 🏖️ Public holidays including all national, cultural, and religious events
- 🔄 Gregorian ↔ Sinhala Buddhist Era conversion
- 🔤 Sinhala & Tamil month names and weekday translations
- 📋 Full month/year calendar generation
- 🎯 Zero dependencies
- 📦 CommonJS, ES Module, UMD, and TypeScript support
Installation
npm install srilanka-calendarUsage
CommonJS
const cal = require('srilanka-calendar');ES Module
import { isPoyaDay, getHolidaysInYear, getDateInfo } from 'srilanka-calendar';Browser (UMD)
<script src="node_modules/srilanka-calendar/dist/index.umd.js"></script>
<script>
const info = SriLankaCalendar.getDateInfo('2025-05-12');
</script>API Reference
🌕 Poya Day Functions
isPoyaDay(date)
Returns true if the given date is a Poya (Full Moon) day.
cal.isPoyaDay('2025-05-12'); // true (Vesak Poya)
cal.isPoyaDay('2025-05-13'); // falsegetPoyaDay(date)
Returns the Poya day info object, or null if not a Poya day.
cal.getPoyaDay('2025-05-12');
// {
// date: '2025-05-12',
// name: 'Vesak Poya',
// sinhala: 'වෙසක් පොහෝ දිනය'
// }getPoyaDaysInYear(year)
Returns an array of all Poya days in a given year.
cal.getPoyaDaysInYear(2025);
// [ { date: '2025-01-13', name: 'Duruthu Poya', ... }, ... ]getNextPoyaDay(date?)
Returns the next upcoming Poya day from the given date (defaults to today).
cal.getNextPoyaDay('2025-04-01');
// { date: '2025-04-12', name: 'Bak Poya', ... }🏖️ Public Holiday Functions
isPublicHoliday(date)
Returns true if the date is a Sri Lankan public holiday (including Poya days).
cal.isPublicHoliday('2025-04-14'); // true (Sinhala & Tamil New Year)
cal.isPublicHoliday('2025-02-04'); // true (Independence Day)getHoliday(date)
Returns the holiday info object, or null.
cal.getHoliday('2025-02-04');
// {
// date: '2025-02-04',
// name: 'National Day (Independence Day)',
// type: 'national',
// sinhala: 'ජාතික දිනය'
// }getHolidaysInYear(year)
Returns all public holidays (fixed + Poya) for a given year, sorted by date.
const holidays = cal.getHolidaysInYear(2025);
// 19+ entries including all Poya days and national holidaysgetHolidaysInRange(startDate, endDate)
Returns all holidays between two dates (inclusive).
const holidays = cal.getHolidaysInRange('2025-04-01', '2025-05-31');
// [ { date: '2025-04-12', name: 'Bak Poya', ... }, ... ]🗓️ Calendar Conversion
gregorianToSinhala(date)
Converts a Gregorian date to Sinhala Buddhist Era info.
cal.gregorianToSinhala('2025-06-15');
// {
// gregorianYear: 2025,
// gregorianDate: '2025-06-15',
// buddhistYear: 2568,
// sinhalYear: 2567,
// sinhalMonth: { id: 4, sinhala: 'බක්', romanized: 'Bak', english: 'Bak' },
// era: 'Buddhist Era (BE)'
// }getCurrentBuddhistYear()
Returns the current Buddhist Era year.
cal.getCurrentBuddhistYear(); // e.g. 2568🔤 Names & Localization
getSinhalaMonth(monthNumber)
Returns Sinhala month info for a given month number (1–12).
cal.getSinhalaMonth(5);
// { id: 5, sinhala: 'ඇසල', romanized: 'Esala', english: 'Esala' }getAllSinhalaMonths()
Returns all 12 Sinhala month names.
getTamilMonth(monthNumber)
Returns Tamil month info for a given month number (1–12).
cal.getTamilMonth(4);
// { id: 4, tamil: 'சித்திரை', romanized: 'Chithirai', english: 'April–May' }getAllTamilMonths()
Returns all 12 Tamil month names.
getWeekdayNames(date)
Returns weekday names in English, Sinhala, and Tamil for a given date.
cal.getWeekdayNames('2025-02-17'); // Monday
// {
// index: 1,
// english: 'Monday',
// sinhala: 'සඳුදා',
// tamil: 'திங்கட்கிழமை'
// }getAllWeekdays()
Returns all 7 weekday translations.
📋 Comprehensive Date Info
getDateInfo(date?)
Returns complete Sri Lankan calendar information for a date.
cal.getDateInfo('2025-05-12');
// {
// gregorian: { date: '2025-05-12', year: 2025, month: 5, day: 12 },
// sinhala: { buddhistYear: 2568, sinhalYear: 2567, month: {...} },
// tamil: { month: { tamil: 'வைகாசி', romanized: 'Vaikasi', ... } },
// weekday: { english: 'Monday', sinhala: 'සඳුදා', tamil: 'திங்கட்கிழமை' },
// poya: { isPoya: true, name: 'Vesak Poya', sinhala: '...' },
// holiday: { isHoliday: false },
// isWorkingDay: false
// }getMonthCalendar(year, month)
Returns an array of DateInfo objects for each day in a month.
const april = cal.getMonthCalendar(2025, 4);
// Array of 30 DateInfo objects for April 2025getSinhalaTamilNewYear(year)
Returns Sinhala & Tamil New Year info for a given year.
cal.getSinhalaTamilNewYear(2025);
// {
// year: 2025,
// eve: { date: '2025-04-13', name: 'Sinhala & Tamil New Year Eve', ... },
// newYear: { date: '2025-04-14', name: 'Sinhala & Tamil New Year', ... },
// buddhistYear: 2568,
// description: 'Celebrated when the sun transits from Meena Rashiya...'
// }Raw Data Access
All underlying data is exported for advanced usage:
const { SINHALA_MONTHS, TAMIL_MONTHS, WEEKDAYS, POYA_DAYS } = require('srilanka-calendar');Holiday Types
| Type | Description |
|------|-------------|
| national | National public holidays (Independence Day, New Year's Day, etc.) |
| cultural | Cultural celebrations (Sinhala & Tamil New Year, etc.) |
| religious | Religious observances (Christmas, etc.) |
| poya | Monthly Poya (Full Moon) days |
Supported Years
Poya day data covers 2020–2035. Fixed public holidays apply to any year.
TypeScript
Full TypeScript support is included. All functions and data structures are typed.
import { getDateInfo, DateInfo, PoyaDay } from 'srilanka-calendar';
const info: DateInfo = getDateInfo(new Date());
console.log(info.poya.isPoya);License
MIT © 2026 srilanka-calendar contributors
