API Reference
Complete function-by-function and type-by-type reference for @wesantal/santali-calendar.
Import
import { SantaliCalendar } from "@wesantal/santali-calendar";
const calendar = new SantaliCalendar();SantaliCalendar Class
The primary class that integrates the Metonic cycle, Meeus astronomy engine, and Chandradarshan rule.
calendar.getCalendar(year)Returns the full calendar data for a Santali year with month grids ready for rendering.
getCalendar(year: number): SantaliCalendarYearParameters
year—Santali year (e.g. 2026)numberSantaliCalendarYearconst yearData = calendar.getCalendar(2026);
// {
// year: 2026,
// currentMonthIndex: 0,
// months: [SantaliCalendarMonth, ...],
// startDate: Date("2026-01-19"),
// endDate: Date("2027-01-07")
// }calendar.getMonths(year)Returns the raw month metadata array for a Santali year.
getMonths(year: number): SantaliMonth[]Parameters
year—Santali yearnumberSantaliMonth[]const months = calendar.getMonths(2026);
console.log(months[0].name); // "ᱢᱟᱜᱽ" (Ol Chiki)
console.log(months[0].roman); // "Mag"
console.log(months.length); // 12 or 13calendar.getCurrentMonth()Returns the current Santali month based on today's date.
getCurrentMonth(): SantaliCalendarMonthSantaliCalendarMonthconst currentMonth = calendar.getCurrentMonth();
console.log(`${currentMonth.name} (${currentMonth.roman})`);calendar.getDate(date?)Converts any JavaScript Date to its corresponding Santali lunar date.
getDate(date?: DateTime): SantaliDateParameters
date—Date, string, or number (defaults to now)DateTimeSantaliDateconst santaliDate = calendar.getDate(new Date("2026-04-14"));
console.log(santaliDate.day); // Day of the lunar month (1..30)
console.log(santaliDate.month.name); // "ᱢᱟᱜᱽ"
console.log(santaliDate.month.roman); // "Mag"
console.log(santaliDate.weekDay); // English weekday
console.log(santaliDate.isPurnima); // true if Full Moon day
console.log(santaliDate.isAmavasya); // true if New Moon daycalendar.getToday()Returns today's Santali date.
getToday(): SantaliDateSantaliDateconst today = calendar.getToday();
console.log(`${today.day} ${today.month.name}`);calendar.isLeapYear(year)Returns true if the Santali year has 13 months (Sarcha Chando) according to the Metonic cycle.
isLeapYear(year: number): booleanParameters
year—Santali yearnumberbooleancalendar.isLeapYear(2026); // true
calendar.isLeapYear(2027); // false
calendar.isLeapYear(2029); // truecalendar.getDaysInMonth(year, month)Returns the number of days in a specific Santali month (1-indexed).
getDaysInMonth(year: number, month: number): numberParameters
year—Santali yearnumbermonth—Month number (1-12, or 1-13 in leap years)numbernumbercalendar.getDaysInMonth(2026, 1); // Days in Mag Bongacalendar.getMonthIndex(date)Returns the 0-based month index for a given date.
getMonthIndex(date: DateTime): numberParameters
date—Date, string, or numberDateTimenumber — 0-based index (0-11 normal, 0-12 leap)const idx = calendar.getMonthIndex(new Date()); // 0-12calendar.getCalendarMonthIndex(date)Returns the 0-based month index using the 17:00 IST calendar day boundary.
getCalendarMonthIndex(date: DateTime): numberParameters
date—Date, string, or numberDateTimenumber — 0-based indexconst idx = calendar.getCalendarMonthIndex(new Date());calendar.getMonthFromDate(date)Returns the Santali month data for a given date.
getMonthFromDate(date: DateTime): SantaliCalendarMonthParameters
date—Date, string, or numberDateTimeSantaliCalendarMonthconst month = calendar.getMonthFromDate(new Date("2026-06-15"));
console.log(month.name);calendar.getFestivals(year)Returns all resolved Santali festivals for a given year. Each festival's date is computed based on its rule (fixed Gregorian or moon-relative).
getFestivals(year: number): SantaliFestival[]Parameters
year—Santali yearnumberSantaliFestival[]const festivals = calendar.getFestivals(2026);
festivals.forEach((f) => {
console.log(`${f.roman}: ${f.date.toLocaleDateString()}`);
console.log(` Type: ${f.type}`);
console.log(` Month: ${f.monthId}`);
});
// Example output:
// Santali New Year: 1/19/2026
// Type: observance
// Month: MAG
// Mag Bonga: 1/23/2026
// Type: festival
// Month: MAGAstronomy Functions
Low-level astronomical calculation functions exported from the library.
getNewMoon(k)Meeus Chapter 49 New Moon calculation. Returns Unix milliseconds UTC.
getNewMoon(k: number): numberParameters
k—Meeus lunation indexnumbernumber — Unix milliseconds UTCconst nm = getNewMoon(285); // Magh 2023 New Moon\nconsole.log(new Date(nm));getFullMoon(k)Meeus Chapter 49 Full Moon calculation. Returns Unix milliseconds UTC.
getFullMoon(k: number): numberParameters
k—Meeus lunation indexnumbernumber — Unix milliseconds UTCgetFullMoonBetween(startMs, endMs)Find the Full Moon timestamp between two given instants.
getFullMoonBetween(startMs: number, endMs: number): number | nullParameters
startMs—Start timestamp (ms)numberendMs—End timestamp (ms)numbernumber | null — Unix milliseconds UTCgetChandradarshan(newMoonMs)Apply the 17:00 IST cutoff to determine the actual month start date from an astronomical New Moon.
getChandradarshan(newMoonMs: number): numberParameters
newMoonMs—Astronomical New Moon (Unix ms UTC)numbernumber — Chandradarshan date (Unix ms UTC)isSantaliLeapYear(year)Pure mathematical leap year check using the Metonic cycle. No astronomy overhead.
isSantaliLeapYear(year: number): booleanParameters
year—Santali yearnumberbooleanisSantaliLeapYear(2032); // truegetSantaliMonths(year)Returns all Santali months for a year with computed start/end dates, full moon, and new moon.
getSantaliMonths(year: number): SantaliMonth[]Parameters
year—Santali yearnumberSantaliMonth[]getSantaliMonth(date?)Returns the Santali month for a given date.
getSantaliMonth(date?: DateTime): SantaliMonthParameters
date—Date (defaults to now)DateTimeSantaliMonthgetNewMoonsForYear(year)Returns all astronomical New Moons for a Gregorian year.
getNewMoonsForYear(year: number): number[]Parameters
year—Gregorian yearnumbernumber[] — Array of Unix ms UTCgetFullMoonsForYear(year)Returns all astronomical Full Moons for a Gregorian year.
getFullMoonsForYear(year: number): number[]Parameters
year—Gregorian yearnumbernumber[] — Array of Unix ms UTCtoISTDate(ms)Convert a UTC timestamp to an IST Date.
toISTDate(ms: number): DateParameters
ms—Unix milliseconds UTCnumberDate — IST DateunixMsToJulianDay(ms)Convert Unix milliseconds to Julian Day Number.
unixMsToJulianDay(ms: number): numberParameters
ms—Unix milliseconds UTCnumbernumber — Julian Day NumberSun Utilities
NOAA-based solar calculation functions for sunrise, sunset, and day length.
getSunriseSunset(date, latitude, longitude, utcOffsetHours?)Returns sunrise, sunset, solar noon, and day length for a given date and location.
getSunriseSunset(
date: DateTime,
latitude: number,
longitude: number,
utcOffsetHours?: number
): SunTimes | nullParameters
date—Date to computeDateTimelatitude—Latitude (North positive)numberlongitude—Longitude (East positive)numberutcOffsetHours—UTC offset (default: 5.5 for IST)numberSunTimes | null — { sunrise, sunset, solarNoon, dayLengthMs }const sun = getSunriseSunset(
new Date(),
23.3441, // Ranchi latitude
85.3096, // Ranchi longitude
5.5 // IST
);
console.log(sun?.sunrise);
console.log(sun?.sunset);
console.log(sun?.dayLengthMs);getSunrise(date, latitude, longitude, utcOffsetHours?)Returns only the sunrise time.
getSunrise(
date: DateTime,
latitude: number,
longitude: number,
utcOffsetHours?: number
): Date | nullDate | nullgetSunset(date, latitude, longitude, utcOffsetHours?)Returns only the sunset time.
getSunset(
date: DateTime,
latitude: number,
longitude: number,
utcOffsetHours?: number
): Date | nullDate | nullgetBhubaneswarSunriseSunset(date?)Convenience method for sunrise/sunset in Bhubaneswar, Odisha.
getBhubaneswarSunriseSunset(date?: DateTime): SunTimes | nullSunTimes | nullDate Utilities
General-purpose date manipulation functions.
Available date utilities include:
toDatecloneDateisValidDateformatDateformatDateStringformatnowtodaygetYeargetMonthgetDaygetDayOfWeekaddDaysaddMonthsaddYearssubDayssubMonthssubYearsdiffInDaysdifferenceInCalendarDaysstartOfDaystartOfWeekstartOfMonthendOfDayendOfWeekendOfMonthisSameDayisSameMonthisTodayisBeforeisAfterisWeekendeachDayOfIntervaleachMonthOfIntervalparseISOcreateDateformatISTNumeral Conversion
toOlChikiNumeral(n)Converts an Arabic numeral to Ol Chiki script digits.
toOlChikiNumeral(n: number): stringParameters
n—An integernumberstring — Ol Chiki numeraltoOlChikiNumeral(1); // "᱑"
toOlChikiNumeral(19); // "᱑᱙"
toOlChikiNumeral(2026); // "᱒᱐᱒᱖"Constants
SANTALI_MONTHSSantaliBaseMonth[] — Array of 13 month definitions (12 regular + Sarcha Chando) with Ol Chiki names and English names.
METONIC_CYCLE_START2026 — Anchor year for the current Metonic cycle.
METONIC_LEAP_POSSet([1, 4, 7, 9, 12, 15, 18]) — Leap year positions within the 19-year cycle.
IST_OFFSET_MS19800000 — Indian Standard Time offset in milliseconds (5.5 hours).
weekDaysreadonly string[] — English weekday names: ["Sunday", "Monday", ..., "Saturday"].
santaliWeekDaysreadonly string[] — Ol Chiki weekday names: ["ᱥᱤᱸᱜᱤ", "ᱚᱛᱮ", ..., "ᱧᱩᱦᱩᱢ"].
santaliFestivalsSantaliFestivalDefination[] — Raw festival definitions with moon-relative and fixed Gregorian rules.
Types
// Core types
type DateTime = Date | string | number;
interface SantaliMonth {
index: number;
name: string; // Ol Chiki name
roman: string; // English name
isLeapMonth: boolean;
startDate: Date;
endDate: Date;
displayEndDate: Date;
totalDays: number;
newMoon: Date;
fullMoon: Date;
}
interface SantaliDate {
day: number;
date: Date;
weekDay: string;
month: SantaliMonth;
isPurnima: boolean;
isAmavasya: boolean;
isLeapMonth: boolean;
}
// Calendar types
interface SantaliCalendarYear {
year: number;
currentMonthIndex: number;
months: SantaliCalendarMonth[];
startDate: Date;
endDate: Date;
}
interface SantaliCalendarMonth extends SantaliMonth {
days: SantaliCalendarDayCell[];
}
interface SantaliCalendarDayCell {
day: number;
date: Date;
olchiki: string;
weekDay: string;
santaliWeekDay: string;
isToday: boolean;
isNewMoonDay: boolean;
isFullMoonDay: boolean;
isCurrentMonth: boolean;
}
// Festival types
type SantaliFestivalType =
| "festival"
| "birth-anniversary"
| "death-anniversary"
| "cultural"
| "community"
| "observance";
type MoonPhase = "new-moon" | "full-moon";
interface SantaliFestival {
id: string;
name: string;
roman: string;
monthId: string;
type: SantaliFestivalType;
description?: string;
date: Date;
}
// Sun types
interface SunTimes {
sunrise: Date;
sunset: Date;
solarNoon: Date;
dayLengthMs: number;
}