nepali-calendar-panchang
v1.0.2
Published
Nepali calendar & Panchang (BS 1970-2100): Bikram Sambat <-> Gregorian dates, tithi, nakshatra, yoga, karana, rashi, Nepal Sambat, and festivals. Astronomically computed (Swiss Ephemeris / Lahiri).
Maintainers
Readme
nepali-calendar-panchang
A Nepali calendar and Panchang for Bikram Sambat years 1970 to 2100 (roughly 1913 to 2044 in the Gregorian calendar). It ships as a small library with no runtime dependencies.
Every day comes with the full panchang:
- Bikram Sambat and Gregorian dates, plus the weekday
- Nepal Sambat (the Newar lunisolar date)
- Tithi, Paksha, Nakshatra, Yoga, Karana and the moon Rashi, each with ending times in Nepal time
- A set of major festivals and events
The panchang is computed astronomically using the Swiss Ephemeris with the Lahiri ayanamsa, and it was cross checked against established Nepali almanacs for the dates where they overlap. The data is precomputed and shipped compressed (about 2 MB), and it loads one year at a time so you never pull in more than you need.
Install
npm install nepali-calendar-panchangQuick start
import { getPanchang, getPanchangBS, getMonth, adToBs, bsToAd } from 'nepali-calendar-panchang';
// Today, using the Nepal civil date
getPanchang();
// By a Gregorian date
const p = getPanchang('2026-07-30');
p.bikram_sambat; // "२०८३ साउन १४ बिहीवार"
p.nepal_sambat; // "1146 दिल्लागा पारु - 16"
p.tithi; // "प्रतिपदा upto 21:45:50, उपरान्त: द्वितीया"
p.rashi; // "मकर ♑"
p.events; // ["विश्व मित्रता दिवस"]
// By a Bikram Sambat date
getPanchangBS(2083, 4, 14); // same day
// A whole BS month (Baishakh is 1)
getMonth(2083, 4).days; // DayPanchang[]
// Just the date conversion, no data loaded
adToBs(new Date('2026-07-30')); // { year: 2083, month: 4, day: 14, ... }
bsToAd(2083, 4, 14); // Date for 2026-07-30 (UTC)It works with CommonJS too:
const { getPanchang } = require('nepali-calendar-panchang');API
getPanchang(date?)
Returns one day's panchang. Pass a Date, a "YYYY-MM-DD" string, or nothing for today.
getPanchangBS(year, month, day)
Same record, looked up by Bikram Sambat date.
getToday()
Today's panchang, using the current Nepal civil date.
getMonth(bsYear, bsMonth)
A whole BS month with all its days.
getMonthOf(date?)
The whole BS month that contains a given Gregorian date (or today).
getYear(bsYear)
A whole BS year, all 12 months.
adToBs(date) and bsToAd(year, month, day)
Plain date conversion, no data file is read.
daysInMonth(year, month), daysInYear(year)
Length helpers.
MIN_BS_YEAR and MAX_BS_YEAR
The supported range, currently 1970 and 2100.
A Date you pass in is mapped to its Nepal civil date (UTC+5:45). A "YYYY-MM-DD" string is taken as that calendar date directly.
The DayPanchang shape
interface DayPanchang {
day: number; // BS day of the month
weekday: string; // "बिहीवार"
bikram_sambat: string; // "२०८३ साउन १४ बिहीवार"
english_date: string; // "2026 Jul 30, Thursday"
nepal_sambat: string; // "1146 दिल्लागा पारु - 16"
tithi: string;
paksha: string;
nakshatra: string;
yoga: string;
karana: string;
rashi: string; // "मकर ♑"
sunrise_npt: string; // "05:27:06"
events: string[];
is_holiday: boolean;
}Times follow the extended hour style you see in Nepali patros. Hours count from the day's local midnight, so a value between 24 and 30 means the early hours of the next morning.
Environment
This needs Node 16 or newer, because the year data is read from disk with fs and zlib. The date functions and the types work anywhere. For the browser, load a specific year's data yourself or let your bundler inline the files in the data folder.
How accurate is it
The dates, tithi, nakshatra, yoga, karana, rashi and Nepal Sambat are the solid parts. They were cross checked against established Nepali almanacs (a full match on the month that was tested) and the calendar round trips with no errors across the whole range.
Events are a computed set of the major festivals: Dashain, Tihar, Nag Panchami, Janai Purnima, the monthly sankranti, and the common national and international days. They are tied to the lunar (amanta) month, so the big festivals land on the right day. This is not a full patro. Small local jatras and vrats are not included, and a few festivals that follow evening or midnight tithi rules can be off by a day.
The ending times are computed properly, but they can differ from any particular almanac by a minute or two depending on the ephemeris and ayanamsa that almanac uses.
Regenerating the data
The compressed year files in data are built from the source JSON with:
npm run pack-dataLicense
MIT
