@ishubhamx/panchangam-js
Version:
Enhanced Indian Panchangam (Hindu Calendar) library with comprehensive Vedic features including Muhurta calculations, planetary positions, Rashi placements, and auspicious/inauspicious time calculations
182 lines • 9.49 kB
TypeScript
import { Body, Observer } from "astronomy-engine";
import { KaranaTransition, TithiTransition, NakshatraTransition, YogaTransition, PlanetaryPosition, MuhurtaTime, RashiTransition, SankrantiInfo, PanchakInfo, DashaResult } from "./types";
/**
* Calculate Tithi (lunar day) from Sun and Moon sidereal longitudes.
*
* @param sunLon - Sidereal longitude of the Sun (0-360)
* @param moonLon - Sidereal longitude of the Moon (0-360)
* @returns Tithi index, **0-indexed** (0-29).
* 0-14 = Shukla Prathama to Purnima,
* 15-29 = Krishna Prathama to Amavasya.
* Use `getTithiAtSunrise()` from udaya-tithi.ts for 1-indexed (1-30) values
* required by festival detection.
*/
export declare function getTithi(sunLon: number, moonLon: number): number;
/**
* Calculate the current Nakshatra (lunar mansion) from the Moon's sidereal longitude.
* @param moonLon - Sidereal longitude of the Moon (0-360)
* @returns Nakshatra index (0-26): 0 = Ashwini, 26 = Revati
*/
export declare function getNakshatra(moonLon: number): number;
/**
* Calculate the current Yoga from Sun and Moon sidereal longitudes.
* @param sunLonSidereal - Sidereal longitude of the Sun (0-360)
* @param moonLonSidereal - Sidereal longitude of the Moon (0-360)
* @returns Yoga index (0-26): 0 = Vishkambha, 26 = Vaidhriti
*/
export declare function getYoga(sunLonSidereal: number, moonLonSidereal: number): number;
/**
* Calculate the current Karana (half-tithi) from Sun and Moon longitudes.
* @param sunLon - Sidereal longitude of the Sun (0-360)
* @param moonLon - Sidereal longitude of the Moon (0-360)
* @returns Karana name string
*/
export declare function getKarana(sunLon: number, moonLon: number): string;
/**
* Returns the weekday (0=Sunday, ...) based on the Observer's local time.
*
* @param date - Date to check
* @param observer - Observer location (used to approximate timezone from longitude if timezoneOffsetMinutes is not given)
* @param timezoneOffsetMinutes - Explicit timezone offset in minutes (e.g. 330 for IST). Preferred over longitude approximation.
*/
export declare function getVara(date: Date, observer?: Observer, timezoneOffsetMinutes?: number): number;
interface LocalDayOptions {
timezoneOffset?: number;
}
export declare function getSunrise(date: Date, observer: Observer, options?: LocalDayOptions): Date | null;
export declare function getSunset(date: Date, observer: Observer, options?: LocalDayOptions): Date | null;
export declare function getMoonrise(date: Date, observer: Observer, options?: LocalDayOptions): Date | null;
export declare function getMoonset(date: Date, observer: Observer, options?: LocalDayOptions): Date | null;
export declare function findNakshatraStart(date: Date, ayanamsa: number): Date | null;
export declare function findNakshatraEnd(date: Date, ayanamsa: number): Date | null;
export declare function findTithiStart(date: Date): Date | null;
export declare function findTithiEnd(date: Date): Date | null;
export declare function findYogaEnd(date: Date, ayanamsa: number): Date | null;
export declare function getPlanetaryPosition(body: Body, date: Date, ayanamsa: number): PlanetaryPosition;
export declare function getRahuPosition(date: Date, ayanamsa: number): PlanetaryPosition;
export declare function getKetuPosition(rahuPos: PlanetaryPosition): PlanetaryPosition;
export declare function calculateAbhijitMuhurta(sunrise: Date, sunset: Date): MuhurtaTime | null;
export declare function calculateBrahmaMuhurta(sunrise: Date, prevSunset?: Date): MuhurtaTime | null;
export declare function calculateGovardhanMuhurta(sunrise: Date, sunset: Date): MuhurtaTime | null;
export declare function calculateYamagandaKalam(sunrise: Date, sunset: Date, vara: number): MuhurtaTime | null;
export declare function calculateGulikaKalam(sunrise: Date, sunset: Date, vara: number): MuhurtaTime | null;
/**
* Calculate Dur (inauspicious) Muhurtas for the day.
* Traditional Panchanga specifies two dur muhurtas per weekday.
*
* @param sunrise - Sunrise time
* @param sunset - Sunset time
* @param vara - Weekday (0=Sun … 6=Sat). When omitted, falls back to static [4, 6].
*/
export declare function calculateDurMuhurta(sunrise: Date, sunset: Date, vara?: number): MuhurtaTime[] | null;
export declare function calculateChandraBalam(moonLon: number, sunLon: number): number;
/**
* Get the current Hora (planetary hour) lord.
*
* @param date - Current time
* @param sunrise - Sunrise time for the day
* @param observer - Observer location
* @param timezoneOffsetMinutes - Explicit TZ offset in minutes (e.g. 330 for IST) for accurate weekday
*/
export declare function getCurrentHora(date: Date, sunrise: Date, observer?: Observer, timezoneOffsetMinutes?: number): string;
export declare function calculateRahuKalam(sunrise: Date, sunset: Date, vara: number): {
start: Date;
end: Date;
} | null;
export declare function findKaranaTransitions(startDate: Date, endDate: Date): KaranaTransition[];
export declare function findTithiTransitions(startDate: Date, endDate: Date): TithiTransition[];
export declare function findNakshatraTransitions(startDate: Date, endDate: Date, ayanamsa: number): NakshatraTransition[];
export declare function findYogaTransitions(startDate: Date, endDate: Date, ayanamsa: number): YogaTransition[];
export declare function getPaksha(tithi: number): string;
export declare function getAyana(sunLon: number): string;
export declare function getRitu(sunLon: number): string;
export declare function getMasa(sunLon: number, moonLon: number, date: Date, calendarType?: 'amanta' | 'purnimanta'): {
index: number;
name: string;
isAdhika: boolean;
};
export declare function getSamvat(date: Date, masaIndex: number): {
vikram: number;
shaka: number;
samvatsara: string;
};
export declare function getNakshatraPada(moonLon: number): number;
export declare function getRashi(lon: number): {
index: number;
name: string;
};
export declare function getSunNakshatra(sunLon: number): {
index: number;
name: string;
pada: number;
};
/**
* Find the next Sankranti (Sun's ingress into a Rashi) from a given date.
* Sankranti marks the Sun entering a new sidereal zodiac sign.
*
* @param date - Starting date to search from
* @param ayanamsa - Ayanamsa value for sidereal calculation
* @returns SankrantiInfo with exact time, rashi, and punya kalam
*/
export declare function findNextSankranti(date: Date, ayanamsa: number): SankrantiInfo | null;
/**
* Find all Sankrantis within a date range.
*
* @param startDate - Start of date range
* @param endDate - End of date range
* @param ayanamsa - Ayanamsa value for sidereal calculation
* @returns Array of SankrantiInfo objects
*/
export declare function findSankrantisInRange(startDate: Date, endDate: Date, ayanamsa: number): SankrantiInfo[];
/**
* Check if a given date falls on a Sankranti day (within the same civil day).
*
* @param date - Date to check
* @param ayanamsa - Ayanamsa value
* @param timezoneOffsetMinutes - Timezone offset in minutes for civil day calculation
* @returns SankrantiInfo if Sankranti occurs on this day, null otherwise
*/
export declare function getSankrantiForDate(date: Date, ayanamsa: number, timezoneOffsetMinutes?: number): SankrantiInfo | null;
/**
* Check if the current Moon Nakshatra falls in Panchak period.
* Panchak occurs when Moon transits through the last 5 Nakshatras:
* Dhanishta (22), Shatabhisha (23), Purva Bhadrapada (24), Uttara Bhadrapada (25), Revati (26)
*
* Each Panchak Nakshatra is associated with specific doshas:
* - Dhanishta: Mrityu Panchak (death-related activities avoided)
* - Shatabhisha: Agni Panchak (fire-related activities avoided)
* - Purva Bhadrapada: Raja Panchak (government/legal matters avoided)
* - Uttara Bhadrapada: Chora Panchak (theft-related fears, travel avoided)
* - Revati: Roga Panchak (health-related activities avoided)
*
* @param moonNakshatraIndex - Current Moon Nakshatra (0-26)
* @returns PanchakInfo with type and activity recommendations
*/
export declare function getPanchak(moonNakshatraIndex: number): PanchakInfo;
export declare function getUdayaLagna(date: Date, observer: Observer, ayanamsa: number): number;
export declare function findRashiTransitions(startDate: Date, endDate: Date, ayanamsa: number): RashiTransition[];
/**
* Calculate Tara Balam based on Moon's current Nakshatra and birth Nakshatra.
*
* @deprecated Use `getTarabalam(birthNakshatra, moonNakshatra)` from `tarabalam.ts` for richer output.
* @param moonNakshatra - Current Moon Nakshatra index (0-26)
* @param birthNakshatra - Birth Nakshatra index (0-26)
*/
export declare function calculateTaraBalam(moonNakshatra: number, birthNakshatra: number): {
strength: string;
type: string;
};
export declare function calculateChandraBalamFromRashi(moonRashi: number, birthRashi: number): {
strength: string;
type: string;
};
export declare function calculateVarjyam(nakshatraIndex: number, nakshatraStart: Date, nakshatraEnd: Date): MuhurtaTime[];
export declare function calculateAmritKalam(nakshatraIndex: number, nakshatraStart: Date, nakshatraEnd: Date): MuhurtaTime | null;
export declare function getSpecialYoga(vara: number, nakshatraIndex: number): {
name: string;
description: string;
isAuspicious: boolean;
}[];
export declare function calculateVimshottariDasha(moonLon: number, birthDate: Date): DashaResult;
export {};
//# sourceMappingURL=calculations.d.ts.map