panchang-ts 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +133 -17
- package/dist/index.cjs +258 -6
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +256 -7
- package/package.json +1 -5
- package/dist/index.cjs.map +0 -1
- package/dist/index.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,15 +5,21 @@ Works offline in React Native (Hermes), Node.js, and browsers.
|
|
|
5
5
|
|
|
6
6
|
## Features
|
|
7
7
|
|
|
8
|
-
- **
|
|
9
|
-
|
|
8
|
+
- **Pancha Anga (5 limbs):** Tithi, Nakshatra, Yoga, Karana, Vara — with mid-day transition times
|
|
9
|
+
- **Lunar calendar:** Chandra Masa (lunar month + Adhika/leap detection), Vikram Samvat, Shaka Samvat
|
|
10
|
+
- **Zodiac & asterism:** Chandra Rashi (Moon sign), Surya Nakshatra (Sun's asterism)
|
|
11
|
+
- **Muhurta:** Brahma Muhurta, Abhijit Muhurta
|
|
12
|
+
- **Inauspicious periods:** Rahu Kalam, Gulika Kalam, Yamaganda
|
|
13
|
+
- **Choghadiya:** 16 time slots (8 day + 8 night), each named and rated auspicious/neutral/inauspicious
|
|
14
|
+
- **Hora:** 24 planetary hours per day (12 day + 12 night) in Chaldean order
|
|
15
|
+
- **Astronomical events:** Sunrise, Sunset, Moonrise, Moonset
|
|
16
|
+
- **Panchaka detection:** Flag when Moon is in the last 5 nakshatras (Dhanishta 3rd pada → Revati)
|
|
10
17
|
- **Daily mode:** Full sunrise-to-sunrise day with all element transitions
|
|
11
|
-
|
|
12
|
-
- **Instant mode:** Element active at an exact moment (birth charts, muhurta selection)
|
|
18
|
+
- **Instant mode:** Elements active at an exact moment (birth charts, muhurta selection)
|
|
13
19
|
- **3 ayanamsa systems:** Lahiri (default), B.V. Raman, KP (Krishnamurti)
|
|
14
20
|
- **3 languages:** English, Sanskrit (Devanagari), Hindi
|
|
15
21
|
- **React Native compatible:** Pure JS math, no native modules, tested on Hermes
|
|
16
|
-
- **Fast:** ~0.1 ms names-only on Node.js;
|
|
22
|
+
- **Fast:** ~0.1 ms names-only on Node.js; <100 ms on budget Android (Hermes)
|
|
17
23
|
- **Typed:** Full TypeScript types for every result and option
|
|
18
24
|
|
|
19
25
|
## Install
|
|
@@ -33,11 +39,35 @@ const result = getDailyPanchang(
|
|
|
33
39
|
{ timezone: 330 }, // IST = UTC+5:30 = 330 minutes
|
|
34
40
|
);
|
|
35
41
|
|
|
42
|
+
// Pancha Anga
|
|
36
43
|
console.log(result.tithis[0].name); // "Krishna Chaturdashi"
|
|
37
44
|
console.log(result.nakshatras[0].name); // "Mrigashira"
|
|
38
45
|
console.log(result.vara.name); // "Mangalavara"
|
|
39
|
-
|
|
46
|
+
|
|
47
|
+
// Lunar calendar
|
|
48
|
+
console.log(result.chandramasa.name); // "Pausha"
|
|
49
|
+
console.log(result.samvat.vikramSamvat); // 2081
|
|
50
|
+
console.log(result.samvat.shakaSamvat); // 1946
|
|
51
|
+
|
|
52
|
+
// Zodiac
|
|
53
|
+
console.log(result.chandraRashi.name); // "Mithuna" (Moon in Gemini)
|
|
54
|
+
console.log(result.suryaNakshatra.name); // "Uttara Ashadha"
|
|
55
|
+
|
|
56
|
+
// Astronomical events
|
|
40
57
|
console.log(result.sunrise); // Date (read via getUTC*)
|
|
58
|
+
console.log(result.moonrise); // Date | null
|
|
59
|
+
|
|
60
|
+
// Muhurta
|
|
61
|
+
console.log(result.brahmaMuhurta); // { start: Date, end: Date }
|
|
62
|
+
console.log(result.rahuKalam); // { start: Date, end: Date }
|
|
63
|
+
|
|
64
|
+
// Choghadiya — 8 daytime slots
|
|
65
|
+
result.choghadiya.day.forEach(slot => {
|
|
66
|
+
console.log(slot.name, slot.quality); // "Amrit", "auspicious"
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Panchaka
|
|
70
|
+
console.log(result.panchaka); // true | false
|
|
41
71
|
```
|
|
42
72
|
|
|
43
73
|
## Reading Output Times
|
|
@@ -61,6 +91,9 @@ fmt(result.rahuKalam.start); // "09:04"
|
|
|
61
91
|
|
|
62
92
|
Do **not** use `.getHours()` — it uses your system timezone, which may differ.
|
|
63
93
|
|
|
94
|
+
`moonrise` and `moonset` can be `null` — the Moon occasionally does not rise or set
|
|
95
|
+
on a given calendar day, which is normal.
|
|
96
|
+
|
|
64
97
|
---
|
|
65
98
|
|
|
66
99
|
## API Reference
|
|
@@ -100,10 +133,20 @@ const result = getDailyPanchang(
|
|
|
100
133
|
| `gulikaKalam` | `TimePeriod` | Gulika Kalam start/end |
|
|
101
134
|
| `yamaganda` | `TimePeriod` | Yamaganda start/end |
|
|
102
135
|
| `abhijitMuhurta` | `TimePeriod` | Abhijit Muhurta start/end |
|
|
136
|
+
| `brahmaMuhurta` | `TimePeriod` | Brahma Muhurta (96–48 min before sunrise) |
|
|
137
|
+
| `masa` | `MasaInfo` | Solar month (Saura Masa) |
|
|
138
|
+
| `chandramasa` | `ChandraMasaInfo` | Lunar month + Adhika (leap) flag |
|
|
139
|
+
| `samvat` | `SamvatInfo` | Vikram Samvat and Shaka Samvat year numbers |
|
|
140
|
+
| `chandraRashi` | `RashiInfo` | Moon's zodiac sign (changes every ~2.5 days) |
|
|
141
|
+
| `suryaNakshatra` | `RashiInfo` | Sun's nakshatra (changes every ~13–14 days) |
|
|
142
|
+
| `choghadiya` | `ChoghadiyaInfo` | 8 day slots + 8 night slots, each named and rated |
|
|
143
|
+
| `hora` | `HoraInfo` | 12 day horas + 12 night horas, each with ruling planet |
|
|
144
|
+
| `moonrise` | `Date \| null` | Moonrise (offset-adjusted); `null` if none that day |
|
|
145
|
+
| `moonset` | `Date \| null` | Moonset (offset-adjusted); `null` if none that day |
|
|
146
|
+
| `panchaka` | `boolean` | `true` when Moon is in last 5 nakshatras |
|
|
103
147
|
| `ayanamsa` | `number` | Ayanamsa in degrees at sunrise |
|
|
104
148
|
| `siderealSunAtSunrise` | `number` | Sun sidereal longitude at sunrise (°) |
|
|
105
149
|
| `siderealMoonAtSunrise` | `number` | Moon sidereal longitude at sunrise (°) |
|
|
106
|
-
| `masa` | `MasaInfo` | Solar month (Saura Masa) |
|
|
107
150
|
|
|
108
151
|
---
|
|
109
152
|
|
|
@@ -120,9 +163,12 @@ const result = getInstantPanchang(
|
|
|
120
163
|
{ language: 'sa' }, // Sanskrit names
|
|
121
164
|
);
|
|
122
165
|
|
|
123
|
-
console.log(result.tithi.name);
|
|
124
|
-
console.log(result.nakshatra.name);
|
|
125
|
-
console.log(result.
|
|
166
|
+
console.log(result.tithi.name); // "कृष्ण चतुर्दशी"
|
|
167
|
+
console.log(result.nakshatra.name); // "मृगशिरा"
|
|
168
|
+
console.log(result.chandramasa.name); // "पौष"
|
|
169
|
+
console.log(result.chandraRashi.name); // "मिथुन"
|
|
170
|
+
console.log(result.samvat.vikramSamvat); // 2081
|
|
171
|
+
console.log(result.panchaka); // false
|
|
126
172
|
```
|
|
127
173
|
|
|
128
174
|
**Returns: `InstantPanchangResult`**
|
|
@@ -136,6 +182,11 @@ console.log(result.tithi.endTime); // Date when this Tithi ends
|
|
|
136
182
|
| `yoga` | `YogaInfo` | Active Yoga |
|
|
137
183
|
| `karana` | `KaranaInfo` | Active Karana (movable or fixed) |
|
|
138
184
|
| `vara` | `VaraInfo` | Active Vara (weekday) |
|
|
185
|
+
| `chandramasa` | `ChandraMasaInfo` | Lunar month + Adhika flag |
|
|
186
|
+
| `samvat` | `SamvatInfo` | Vikram Samvat and Shaka Samvat year numbers |
|
|
187
|
+
| `chandraRashi` | `RashiInfo` | Moon's zodiac sign |
|
|
188
|
+
| `suryaNakshatra` | `RashiInfo` | Sun's nakshatra |
|
|
189
|
+
| `panchaka` | `boolean` | `true` when Moon is in last 5 nakshatras |
|
|
139
190
|
| `ayanamsa` | `number` | Ayanamsa in degrees |
|
|
140
191
|
| `siderealSun` | `number` | Sun sidereal longitude (°) |
|
|
141
192
|
| `siderealMoon` | `number` | Moon sidereal longitude (°) |
|
|
@@ -160,22 +211,26 @@ console.log(result.tithi.endTime); // Date when this Tithi ends
|
|
|
160
211
|
|
|
161
212
|
### Low-level Utilities
|
|
162
213
|
|
|
163
|
-
These are exported for advanced use cases (building your own
|
|
164
|
-
visualisations, or debugging).
|
|
214
|
+
These are exported for advanced use cases (building your own tools, visualisations, or debugging).
|
|
165
215
|
|
|
166
216
|
```typescript
|
|
167
217
|
import {
|
|
168
218
|
getSunrise, getSunset,
|
|
219
|
+
getMoonrise, getMoonset,
|
|
169
220
|
getSiderealSunLongitude, getSiderealMoonLongitude,
|
|
170
221
|
getAyanamsa,
|
|
171
222
|
computeRahuKalam, computeGulikaKalam, computeYamaganda,
|
|
172
|
-
computeAbhijitMuhurta,
|
|
223
|
+
computeAbhijitMuhurta, computeBrahmaMuhurta,
|
|
173
224
|
} from 'panchang-ts';
|
|
174
225
|
|
|
175
226
|
// Sunrise/sunset
|
|
176
227
|
const sunrise = getSunrise(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
177
228
|
const sunset = getSunset(sunrise, { latitude: 28.6, longitude: 77.2 });
|
|
178
229
|
|
|
230
|
+
// Moonrise/moonset — return null when the Moon doesn't rise/set that day
|
|
231
|
+
const moonrise = getMoonrise(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
232
|
+
const moonset = getMoonset(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
233
|
+
|
|
179
234
|
// Sidereal longitudes
|
|
180
235
|
const moonLon = getSiderealMoonLongitude(new Date(), 'lahiri'); // degrees [0, 360)
|
|
181
236
|
const sunLon = getSiderealSunLongitude(new Date(), 'lahiri');
|
|
@@ -184,8 +239,13 @@ const sunLon = getSiderealSunLongitude(new Date(), 'lahiri');
|
|
|
184
239
|
const ayan = getAyanamsa(new Date(), 'lahiri'); // e.g. 24.10
|
|
185
240
|
|
|
186
241
|
// Inauspicious periods (varaIndex: 0=Sun … 6=Sat)
|
|
187
|
-
const rahu
|
|
188
|
-
|
|
242
|
+
const rahu = computeRahuKalam(sunrise, sunset, varaIndex); // { start, end }
|
|
243
|
+
const gulika = computeGulikaKalam(sunrise, sunset, varaIndex);
|
|
244
|
+
const yama = computeYamaganda(sunrise, sunset, varaIndex);
|
|
245
|
+
|
|
246
|
+
// Muhurta
|
|
247
|
+
const abhijit = computeAbhijitMuhurta(sunrise, sunset); // { start, end }
|
|
248
|
+
const brahma = computeBrahmaMuhurta(sunrise, sunset); // { start, end }
|
|
189
249
|
```
|
|
190
250
|
|
|
191
251
|
---
|
|
@@ -204,6 +264,8 @@ interface TimePeriod {
|
|
|
204
264
|
end: Date;
|
|
205
265
|
}
|
|
206
266
|
|
|
267
|
+
// ── Pancha Anga ──────────────────────────────────────────────────────────────
|
|
268
|
+
|
|
207
269
|
interface TithiInfo {
|
|
208
270
|
index: number; // 0–29
|
|
209
271
|
name: string; // e.g. "Shukla Pratipada"
|
|
@@ -228,6 +290,55 @@ interface DailyTithiInfo extends TithiInfo {
|
|
|
228
290
|
}
|
|
229
291
|
|
|
230
292
|
// DailyNakshatraInfo, DailyYogaInfo, DailyKaranaInfo follow the same pattern
|
|
293
|
+
|
|
294
|
+
// ── Lunar calendar ───────────────────────────────────────────────────────────
|
|
295
|
+
|
|
296
|
+
interface ChandraMasaInfo {
|
|
297
|
+
index: number; // 0 = Chaitra … 11 = Phalguna
|
|
298
|
+
name: string; // e.g. "Pausha"
|
|
299
|
+
isAdhika: boolean; // true = leap/intercalary month
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
interface SamvatInfo {
|
|
303
|
+
vikramSamvat: number; // e.g. 2081
|
|
304
|
+
shakaSamvat: number; // e.g. 1946
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
// ── Zodiac & asterism ────────────────────────────────────────────────────────
|
|
308
|
+
|
|
309
|
+
interface RashiInfo {
|
|
310
|
+
index: number; // 0 = Mesha … 11 = Meena (for rashi); 0–26 for nakshatra
|
|
311
|
+
name: string;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// chandraRashi and suryaNakshatra both use RashiInfo
|
|
315
|
+
|
|
316
|
+
// ── Choghadiya ───────────────────────────────────────────────────────────────
|
|
317
|
+
|
|
318
|
+
type ChoghadiyaQuality = 'auspicious' | 'inauspicious' | 'neutral';
|
|
319
|
+
|
|
320
|
+
interface ChoghadiyaSlot extends TimePeriod {
|
|
321
|
+
index: number;
|
|
322
|
+
name: string; // e.g. "Amrit", "Kaal", "Shubh"
|
|
323
|
+
quality: ChoghadiyaQuality;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
interface ChoghadiyaInfo {
|
|
327
|
+
day: ChoghadiyaSlot[]; // 8 slots (sunrise → sunset)
|
|
328
|
+
night: ChoghadiyaSlot[]; // 8 slots (sunset → next sunrise)
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
// ── Hora ─────────────────────────────────────────────────────────────────────
|
|
332
|
+
|
|
333
|
+
interface HoraSlot extends TimePeriod {
|
|
334
|
+
planet: string; // "Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"
|
|
335
|
+
planetIndex: number; // 0–6 in Chaldean order
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
interface HoraInfo {
|
|
339
|
+
day: HoraSlot[]; // 12 slots (sunrise → sunset)
|
|
340
|
+
night: HoraSlot[]; // 12 slots (sunset → next sunrise)
|
|
341
|
+
}
|
|
231
342
|
```
|
|
232
343
|
|
|
233
344
|
---
|
|
@@ -264,8 +375,8 @@ InteractionManager.runAfterInteractions(() => {
|
|
|
264
375
|
|
|
265
376
|
| Mode | Node.js | Hermes (budget Android) |
|
|
266
377
|
|------|---------|------------------------|
|
|
267
|
-
| Names-only (`computeEndTimes: false`) | ~0.1 ms |
|
|
268
|
-
| Full with end-times | ~0.5 ms |
|
|
378
|
+
| Names-only (`computeEndTimes: false`) | ~0.1 ms | <100 ms |
|
|
379
|
+
| Full with end-times | ~0.5 ms | <500 ms |
|
|
269
380
|
|
|
270
381
|
Measured with Vitest benchmarks on Node 22 and on a physical budget Android device
|
|
271
382
|
via the dharmSetu React Native app.
|
|
@@ -279,9 +390,11 @@ Validated against [DrikPanchang.com](https://www.drikpanchang.com) for 15+ date/
|
|
|
279
390
|
| Element | Accuracy |
|
|
280
391
|
|---------|----------|
|
|
281
392
|
| Sunrise / Sunset | ±2 minutes |
|
|
393
|
+
| Moonrise / Moonset | ±2 minutes |
|
|
282
394
|
| Tithi, Nakshatra, Yoga, Karana names | Exact match |
|
|
283
395
|
| Element end-times | ±5 minutes |
|
|
284
396
|
| Ayanamsa | ±0.005° vs Swiss Ephemeris |
|
|
397
|
+
| Choghadiya / Hora slots | Derived from sunrise/sunset — inherits ±2 min |
|
|
285
398
|
|
|
286
399
|
---
|
|
287
400
|
|
|
@@ -317,6 +430,9 @@ try {
|
|
|
317
430
|
`PanchangErrorCode` values: `INVALID_DATE`, `INVALID_LATITUDE`, `INVALID_LONGITUDE`,
|
|
318
431
|
`INVALID_TIMEZONE`, `INVALID_AYANAMSA`, `NO_SUNRISE`, `NO_SUNSET`.
|
|
319
432
|
|
|
433
|
+
Note: `getMoonrise` / `getMoonset` never throw — they return `null` when no rise/set
|
|
434
|
+
occurs within the search window (this is normal for the Moon).
|
|
435
|
+
|
|
320
436
|
---
|
|
321
437
|
|
|
322
438
|
## License
|
package/dist/index.cjs
CHANGED
|
@@ -2905,6 +2905,13 @@ function computeAbhijitMuhurta(sunrise, sunset) {
|
|
|
2905
2905
|
const end = new Date(start.getTime() + muhurtaDurationMs);
|
|
2906
2906
|
return { start, end };
|
|
2907
2907
|
}
|
|
2908
|
+
function computeBrahmaMuhurta(sunrise, sunset) {
|
|
2909
|
+
const dayDurationMs = sunset.getTime() - sunrise.getTime();
|
|
2910
|
+
const muhurtaDurationMs = dayDurationMs / 30;
|
|
2911
|
+
const end = new Date(sunrise.getTime() - muhurtaDurationMs);
|
|
2912
|
+
const start = new Date(end.getTime() - muhurtaDurationMs);
|
|
2913
|
+
return { start, end };
|
|
2914
|
+
}
|
|
2908
2915
|
|
|
2909
2916
|
// src/core/masa.ts
|
|
2910
2917
|
var MASA_NAMES_EN = [
|
|
@@ -2929,6 +2936,143 @@ function computeMasa(siderealSunLon) {
|
|
|
2929
2936
|
};
|
|
2930
2937
|
}
|
|
2931
2938
|
|
|
2939
|
+
// src/core/chandramasa.ts
|
|
2940
|
+
var SYNODIC_MONTH = 29.53059;
|
|
2941
|
+
var TROPICAL_YEAR = 365.25;
|
|
2942
|
+
function computeChandraMasa(siderealSun, siderealMoon, nameFn) {
|
|
2943
|
+
const elongation = (siderealMoon - siderealSun + 360) % 360;
|
|
2944
|
+
const daysElapsed = elongation / 360 * SYNODIC_MONTH;
|
|
2945
|
+
const sunAtPrevNewMoon = (siderealSun - daysElapsed / TROPICAL_YEAR * 360 + 36e3) % 360;
|
|
2946
|
+
const solarMonthAtPrev = Math.floor(sunAtPrevNewMoon / 30);
|
|
2947
|
+
const daysUntilNext = SYNODIC_MONTH - daysElapsed;
|
|
2948
|
+
const sunAtNextNewMoon = (siderealSun + daysUntilNext / TROPICAL_YEAR * 360) % 360;
|
|
2949
|
+
const solarMonthAtNext = Math.floor(sunAtNextNewMoon / 30);
|
|
2950
|
+
const isAdhika = solarMonthAtPrev === solarMonthAtNext;
|
|
2951
|
+
const index = solarMonthAtPrev;
|
|
2952
|
+
const name = nameFn(index, isAdhika);
|
|
2953
|
+
const isKrishnaPaksha = elongation >= 180;
|
|
2954
|
+
const purnimantaIndex = isKrishnaPaksha ? (index + 1) % 12 : index;
|
|
2955
|
+
const purnimantaName = nameFn(purnimantaIndex, false);
|
|
2956
|
+
return { index, name, isAdhika, purnimantaIndex, purnimantaName };
|
|
2957
|
+
}
|
|
2958
|
+
|
|
2959
|
+
// src/core/samvat.ts
|
|
2960
|
+
function computeSamvat(date) {
|
|
2961
|
+
const year = date.getUTCFullYear();
|
|
2962
|
+
const pastNewYear = date.getUTCMonth() >= 3;
|
|
2963
|
+
return {
|
|
2964
|
+
vikramSamvat: year + (pastNewYear ? 57 : 56),
|
|
2965
|
+
shakaSamvat: year + (pastNewYear ? -78 : -79)
|
|
2966
|
+
};
|
|
2967
|
+
}
|
|
2968
|
+
|
|
2969
|
+
// src/core/rashi.ts
|
|
2970
|
+
function computeChandraRashi(siderealMoon, nameFn) {
|
|
2971
|
+
const index = Math.floor(siderealMoon / 30);
|
|
2972
|
+
return { index, name: nameFn(index) };
|
|
2973
|
+
}
|
|
2974
|
+
function computeSuryaNakshatra(siderealSun, nameFn) {
|
|
2975
|
+
const index = Math.floor(siderealSun / NAKSHATRA_SPAN);
|
|
2976
|
+
return { index, name: nameFn(index) };
|
|
2977
|
+
}
|
|
2978
|
+
|
|
2979
|
+
// src/core/choghadiya.ts
|
|
2980
|
+
var CHOGHADIYA_QUALITY = [
|
|
2981
|
+
"inauspicious",
|
|
2982
|
+
// 0 Udveg (Sun)
|
|
2983
|
+
"neutral",
|
|
2984
|
+
// 1 Char (Venus)
|
|
2985
|
+
"auspicious",
|
|
2986
|
+
// 2 Labh (Mercury)
|
|
2987
|
+
"auspicious",
|
|
2988
|
+
// 3 Amrit (Moon) — most auspicious
|
|
2989
|
+
"inauspicious",
|
|
2990
|
+
// 4 Kaal (Saturn)
|
|
2991
|
+
"auspicious",
|
|
2992
|
+
// 5 Shubh (Jupiter)
|
|
2993
|
+
"inauspicious"
|
|
2994
|
+
// 6 Rog (Mars)
|
|
2995
|
+
];
|
|
2996
|
+
var DAY_START_INDEX = [0, 3, 6, 2, 5, 1, 4];
|
|
2997
|
+
var NIGHT_START_INDEX = [5, 1, 4, 6, 0, 3, 2];
|
|
2998
|
+
function buildSlots(reference, durationMs, startIndex, nameFn, count) {
|
|
2999
|
+
const slotMs = durationMs / count;
|
|
3000
|
+
const slots = [];
|
|
3001
|
+
for (let i = 0; i < count; i++) {
|
|
3002
|
+
const idx = (startIndex + i) % 7;
|
|
3003
|
+
slots.push({
|
|
3004
|
+
start: new Date(reference.getTime() + i * slotMs),
|
|
3005
|
+
end: new Date(reference.getTime() + (i + 1) * slotMs),
|
|
3006
|
+
index: idx,
|
|
3007
|
+
name: nameFn(idx),
|
|
3008
|
+
quality: CHOGHADIYA_QUALITY[idx]
|
|
3009
|
+
});
|
|
3010
|
+
}
|
|
3011
|
+
return slots;
|
|
3012
|
+
}
|
|
3013
|
+
function computeChoghadiya(sunrise, sunset, nextSunrise, varaIndex, nameFn) {
|
|
3014
|
+
const dayMs = sunset.getTime() - sunrise.getTime();
|
|
3015
|
+
const nightMs = nextSunrise.getTime() - sunset.getTime();
|
|
3016
|
+
return {
|
|
3017
|
+
day: buildSlots(sunrise, dayMs, DAY_START_INDEX[varaIndex], nameFn, 8),
|
|
3018
|
+
night: buildSlots(sunset, nightMs, NIGHT_START_INDEX[varaIndex], nameFn, 8)
|
|
3019
|
+
};
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
// src/core/hora.ts
|
|
3023
|
+
var DAY_FIRST_HORA = [0, 3, 6, 2, 5, 1, 4];
|
|
3024
|
+
function buildHoras(reference, durationMs, firstPlanetIndex, nameFn, count) {
|
|
3025
|
+
const horaMs = durationMs / count;
|
|
3026
|
+
const horas = [];
|
|
3027
|
+
for (let i = 0; i < count; i++) {
|
|
3028
|
+
const planetIndex = (firstPlanetIndex + i) % 7;
|
|
3029
|
+
horas.push({
|
|
3030
|
+
start: new Date(reference.getTime() + i * horaMs),
|
|
3031
|
+
end: new Date(reference.getTime() + (i + 1) * horaMs),
|
|
3032
|
+
planetIndex,
|
|
3033
|
+
planet: nameFn(planetIndex)
|
|
3034
|
+
});
|
|
3035
|
+
}
|
|
3036
|
+
return horas;
|
|
3037
|
+
}
|
|
3038
|
+
function computeHora(sunrise, sunset, nextSunrise, varaIndex, nameFn) {
|
|
3039
|
+
const dayMs = sunset.getTime() - sunrise.getTime();
|
|
3040
|
+
const nightMs = nextSunrise.getTime() - sunset.getTime();
|
|
3041
|
+
const firstDay = DAY_FIRST_HORA[varaIndex];
|
|
3042
|
+
const firstNight = (firstDay + 12) % 7;
|
|
3043
|
+
return {
|
|
3044
|
+
day: buildHoras(sunrise, dayMs, firstDay, nameFn, 12),
|
|
3045
|
+
night: buildHoras(sunset, nightMs, firstNight, nameFn, 12)
|
|
3046
|
+
};
|
|
3047
|
+
}
|
|
3048
|
+
|
|
3049
|
+
// src/core/panchaka.ts
|
|
3050
|
+
function computePanchaka(siderealMoon) {
|
|
3051
|
+
return siderealMoon >= 300;
|
|
3052
|
+
}
|
|
3053
|
+
|
|
3054
|
+
// src/astronomy/moonrise.ts
|
|
3055
|
+
function getMoonrise(searchFromUtc, location, limitDays = 2) {
|
|
3056
|
+
const observer = new Observer(
|
|
3057
|
+
location.latitude,
|
|
3058
|
+
location.longitude,
|
|
3059
|
+
location.elevation ?? 0
|
|
3060
|
+
);
|
|
3061
|
+
const astroTime = MakeTime(searchFromUtc);
|
|
3062
|
+
const result = SearchRiseSet(Body.Moon, observer, 1, astroTime, limitDays);
|
|
3063
|
+
return result ? result.date : null;
|
|
3064
|
+
}
|
|
3065
|
+
function getMoonset(searchFromUtc, location, limitDays = 2) {
|
|
3066
|
+
const observer = new Observer(
|
|
3067
|
+
location.latitude,
|
|
3068
|
+
location.longitude,
|
|
3069
|
+
location.elevation ?? 0
|
|
3070
|
+
);
|
|
3071
|
+
const astroTime = MakeTime(searchFromUtc);
|
|
3072
|
+
const result = SearchRiseSet(Body.Moon, observer, -1, astroTime, limitDays);
|
|
3073
|
+
return result ? result.date : null;
|
|
3074
|
+
}
|
|
3075
|
+
|
|
2932
3076
|
// src/i18n/en.ts
|
|
2933
3077
|
var en = {
|
|
2934
3078
|
tithiNames: [
|
|
@@ -3033,7 +3177,23 @@ var en = {
|
|
|
3033
3177
|
"Kumbha",
|
|
3034
3178
|
"Meena"
|
|
3035
3179
|
],
|
|
3036
|
-
|
|
3180
|
+
chandraMasaNames: [
|
|
3181
|
+
"Chaitra",
|
|
3182
|
+
"Vaishakha",
|
|
3183
|
+
"Jyeshtha",
|
|
3184
|
+
"Ashadha",
|
|
3185
|
+
"Shravana",
|
|
3186
|
+
"Bhadrapada",
|
|
3187
|
+
"Ashwin",
|
|
3188
|
+
"Kartika",
|
|
3189
|
+
"Margashirsha",
|
|
3190
|
+
"Pausha",
|
|
3191
|
+
"Magha",
|
|
3192
|
+
"Phalguna"
|
|
3193
|
+
],
|
|
3194
|
+
choghadiyaNames: ["Udveg", "Char", "Labh", "Amrit", "Kaal", "Shubh", "Rog"],
|
|
3195
|
+
grahaNames: ["Sun", "Venus", "Mercury", "Moon", "Saturn", "Jupiter", "Mars"],
|
|
3196
|
+
misc: { purnima: "Purnima", amavasya: "Amavasya", adhika: "Adhika" }
|
|
3037
3197
|
};
|
|
3038
3198
|
|
|
3039
3199
|
// src/i18n/sa.ts
|
|
@@ -3140,7 +3300,23 @@ var sa = {
|
|
|
3140
3300
|
"\u0915\u0941\u092E\u094D\u092D",
|
|
3141
3301
|
"\u092E\u0940\u0928"
|
|
3142
3302
|
],
|
|
3143
|
-
|
|
3303
|
+
chandraMasaNames: [
|
|
3304
|
+
"\u091A\u0948\u0924\u094D\u0930",
|
|
3305
|
+
"\u0935\u0948\u0936\u093E\u0916",
|
|
3306
|
+
"\u091C\u094D\u092F\u0947\u0937\u094D\u0920",
|
|
3307
|
+
"\u0906\u0937\u093E\u0922",
|
|
3308
|
+
"\u0936\u094D\u0930\u093E\u0935\u0923",
|
|
3309
|
+
"\u092D\u093E\u0926\u094D\u0930\u092A\u0926",
|
|
3310
|
+
"\u0906\u0936\u094D\u0935\u093F\u0928",
|
|
3311
|
+
"\u0915\u093E\u0930\u094D\u0924\u093F\u0915",
|
|
3312
|
+
"\u092E\u093E\u0930\u094D\u0917\u0936\u0940\u0930\u094D\u0937",
|
|
3313
|
+
"\u092A\u094C\u0937",
|
|
3314
|
+
"\u092E\u093E\u0918",
|
|
3315
|
+
"\u092B\u093E\u0932\u094D\u0917\u0941\u0928"
|
|
3316
|
+
],
|
|
3317
|
+
choghadiyaNames: ["\u0909\u0926\u094D\u0935\u0947\u0917", "\u091A\u0930", "\u0932\u093E\u092D", "\u0905\u092E\u0943\u0924", "\u0915\u093E\u0932", "\u0936\u0941\u092D", "\u0930\u094B\u0917"],
|
|
3318
|
+
grahaNames: ["\u0938\u0942\u0930\u094D\u092F", "\u0936\u0941\u0915\u094D\u0930", "\u092C\u0941\u0927", "\u091A\u0928\u094D\u0926\u094D\u0930", "\u0936\u0928\u093F", "\u0917\u0941\u0930\u0941", "\u092E\u0919\u094D\u0917\u0932"],
|
|
3319
|
+
misc: { purnima: "\u092A\u0942\u0930\u094D\u0923\u093F\u092E\u093E", amavasya: "\u0905\u092E\u093E\u0935\u093E\u0938\u094D\u092F\u093E", adhika: "\u0905\u0927\u093F\u0915" }
|
|
3144
3320
|
};
|
|
3145
3321
|
|
|
3146
3322
|
// src/i18n/hi.ts
|
|
@@ -3171,6 +3347,14 @@ function resolveKaranaName(index, lang) {
|
|
|
3171
3347
|
if (index >= 57) return t.karanaNames.fixed[index - 56];
|
|
3172
3348
|
return t.karanaNames.movable[(index - 1) % 7];
|
|
3173
3349
|
}
|
|
3350
|
+
function resolveMasaName(index, lang) {
|
|
3351
|
+
return getTranslations(lang).masaNames[index];
|
|
3352
|
+
}
|
|
3353
|
+
function resolveChandraMasaName(index, lang, adhika = false) {
|
|
3354
|
+
const t = getTranslations(lang);
|
|
3355
|
+
const name = t.chandraMasaNames[index];
|
|
3356
|
+
return adhika ? `${t.misc.adhika} ${name}` : name;
|
|
3357
|
+
}
|
|
3174
3358
|
|
|
3175
3359
|
// src/core/panchang.ts
|
|
3176
3360
|
function getInstantPanchang(date, location, options) {
|
|
@@ -3210,6 +3394,20 @@ function getInstantPanchang(date, location, options) {
|
|
|
3210
3394
|
location
|
|
3211
3395
|
);
|
|
3212
3396
|
const vara = computeVara(date, sunriseUtc, getTranslations(lang).varaNames);
|
|
3397
|
+
const chandramasa = computeChandraMasa(
|
|
3398
|
+
siderealSun,
|
|
3399
|
+
siderealMoon,
|
|
3400
|
+
(idx, isAdhika) => resolveChandraMasaName(idx, lang, isAdhika)
|
|
3401
|
+
);
|
|
3402
|
+
const samvat = computeSamvat(date);
|
|
3403
|
+
const chandraRashi = computeChandraRashi(
|
|
3404
|
+
siderealMoon,
|
|
3405
|
+
(idx) => resolveMasaName(idx, lang)
|
|
3406
|
+
);
|
|
3407
|
+
const suryaNakshatra = computeSuryaNakshatra(
|
|
3408
|
+
siderealSun,
|
|
3409
|
+
(idx) => resolveNakshatraName(idx, lang)
|
|
3410
|
+
);
|
|
3213
3411
|
if (doEndTimes) {
|
|
3214
3412
|
tithi.endTime = findTransitionTime(
|
|
3215
3413
|
date,
|
|
@@ -3250,7 +3448,12 @@ function getInstantPanchang(date, location, options) {
|
|
|
3250
3448
|
vara,
|
|
3251
3449
|
ayanamsa: ayanamsaValue,
|
|
3252
3450
|
siderealSun,
|
|
3253
|
-
siderealMoon
|
|
3451
|
+
siderealMoon,
|
|
3452
|
+
chandramasa,
|
|
3453
|
+
samvat,
|
|
3454
|
+
chandraRashi,
|
|
3455
|
+
suryaNakshatra,
|
|
3456
|
+
panchaka: computePanchaka(siderealMoon)
|
|
3254
3457
|
};
|
|
3255
3458
|
}
|
|
3256
3459
|
function getDailyPanchang(date, location, options) {
|
|
@@ -3292,6 +3495,38 @@ function getDailyPanchang(date, location, options) {
|
|
|
3292
3495
|
);
|
|
3293
3496
|
const vara = computeVara(sunriseUtc, sunriseUtc, getTranslations(lang).varaNames);
|
|
3294
3497
|
const masa = computeMasa(siderealSunAtSunrise);
|
|
3498
|
+
const chandramasa = computeChandraMasa(
|
|
3499
|
+
siderealSunAtSunrise,
|
|
3500
|
+
siderealMoonAtSunrise,
|
|
3501
|
+
(idx, isAdhika) => resolveChandraMasaName(idx, lang, isAdhika)
|
|
3502
|
+
);
|
|
3503
|
+
const samvat = computeSamvat(sunriseUtc);
|
|
3504
|
+
const chandraRashi = computeChandraRashi(
|
|
3505
|
+
siderealMoonAtSunrise,
|
|
3506
|
+
(idx) => resolveMasaName(idx, lang)
|
|
3507
|
+
);
|
|
3508
|
+
const suryaNakshatra = computeSuryaNakshatra(
|
|
3509
|
+
siderealSunAtSunrise,
|
|
3510
|
+
(idx) => resolveNakshatraName(idx, lang)
|
|
3511
|
+
);
|
|
3512
|
+
const brahmaMuhurta = computeBrahmaMuhurta(sunriseUtc, sunsetUtc);
|
|
3513
|
+
const choghadiya = computeChoghadiya(
|
|
3514
|
+
sunriseUtc,
|
|
3515
|
+
sunsetUtc,
|
|
3516
|
+
nextSunriseUtc,
|
|
3517
|
+
vara.index,
|
|
3518
|
+
(idx) => getTranslations(lang).choghadiyaNames[idx]
|
|
3519
|
+
);
|
|
3520
|
+
const hora = computeHora(
|
|
3521
|
+
sunriseUtc,
|
|
3522
|
+
sunsetUtc,
|
|
3523
|
+
nextSunriseUtc,
|
|
3524
|
+
vara.index,
|
|
3525
|
+
(idx) => getTranslations(lang).grahaNames[idx]
|
|
3526
|
+
);
|
|
3527
|
+
const moonriseUtc = getMoonrise(localMidnightUtc, location);
|
|
3528
|
+
const moonsetUtc = getMoonset(localMidnightUtc, location);
|
|
3529
|
+
const panchaka = computePanchaka(siderealMoonAtSunrise);
|
|
3295
3530
|
let tithis;
|
|
3296
3531
|
let nakshatras;
|
|
3297
3532
|
let yogas;
|
|
@@ -3408,7 +3643,23 @@ function getDailyPanchang(date, location, options) {
|
|
|
3408
3643
|
ayanamsa: ayanamsaValue,
|
|
3409
3644
|
siderealSunAtSunrise,
|
|
3410
3645
|
siderealMoonAtSunrise,
|
|
3411
|
-
masa
|
|
3646
|
+
masa,
|
|
3647
|
+
chandramasa,
|
|
3648
|
+
samvat,
|
|
3649
|
+
chandraRashi,
|
|
3650
|
+
suryaNakshatra,
|
|
3651
|
+
brahmaMuhurta: convertTimePeriod(brahmaMuhurta),
|
|
3652
|
+
choghadiya: {
|
|
3653
|
+
day: choghadiya.day.map((s) => ({ ...s, ...convertTimePeriod(s) })),
|
|
3654
|
+
night: choghadiya.night.map((s) => ({ ...s, ...convertTimePeriod(s) }))
|
|
3655
|
+
},
|
|
3656
|
+
hora: {
|
|
3657
|
+
day: hora.day.map((s) => ({ ...s, ...convertTimePeriod(s) })),
|
|
3658
|
+
night: hora.night.map((s) => ({ ...s, ...convertTimePeriod(s) }))
|
|
3659
|
+
},
|
|
3660
|
+
moonrise: moonriseUtc ? toLocal(moonriseUtc) : null,
|
|
3661
|
+
moonset: moonsetUtc ? toLocal(moonsetUtc) : null,
|
|
3662
|
+
panchaka
|
|
3412
3663
|
};
|
|
3413
3664
|
}
|
|
3414
3665
|
/*! Bundled license information:
|
|
@@ -3451,15 +3702,16 @@ astronomy-engine/esm/astronomy.js:
|
|
|
3451
3702
|
|
|
3452
3703
|
exports.PanchangError = PanchangError;
|
|
3453
3704
|
exports.computeAbhijitMuhurta = computeAbhijitMuhurta;
|
|
3705
|
+
exports.computeBrahmaMuhurta = computeBrahmaMuhurta;
|
|
3454
3706
|
exports.computeGulikaKalam = computeGulikaKalam;
|
|
3455
3707
|
exports.computeRahuKalam = computeRahuKalam;
|
|
3456
3708
|
exports.computeYamaganda = computeYamaganda;
|
|
3457
3709
|
exports.getAyanamsa = computeAyanamsa;
|
|
3458
3710
|
exports.getDailyPanchang = getDailyPanchang;
|
|
3459
3711
|
exports.getInstantPanchang = getInstantPanchang;
|
|
3712
|
+
exports.getMoonrise = getMoonrise;
|
|
3713
|
+
exports.getMoonset = getMoonset;
|
|
3460
3714
|
exports.getSiderealMoonLongitude = getSiderealMoonLongitude;
|
|
3461
3715
|
exports.getSiderealSunLongitude = getSiderealSunLongitude;
|
|
3462
3716
|
exports.getSunrise = computeSunrise;
|
|
3463
3717
|
exports.getSunset = computeSunset;
|
|
3464
|
-
//# sourceMappingURL=index.cjs.map
|
|
3465
|
-
//# sourceMappingURL=index.cjs.map
|