panchang-ts 0.1.1 → 0.2.1
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 +137 -17
- package/dist/index.cjs +258 -4
- package/dist/index.d.cts +103 -1
- package/dist/index.d.ts +103 -1
- package/dist/index.js +256 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -5,21 +5,31 @@ 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
|
|
20
26
|
|
|
21
27
|
```bash
|
|
22
28
|
npm install panchang-ts
|
|
29
|
+
# or
|
|
30
|
+
pnpm add panchang-ts
|
|
31
|
+
# or
|
|
32
|
+
yarn add panchang-ts
|
|
23
33
|
```
|
|
24
34
|
|
|
25
35
|
## Quick Start
|
|
@@ -33,11 +43,35 @@ const result = getDailyPanchang(
|
|
|
33
43
|
{ timezone: 330 }, // IST = UTC+5:30 = 330 minutes
|
|
34
44
|
);
|
|
35
45
|
|
|
46
|
+
// Pancha Anga
|
|
36
47
|
console.log(result.tithis[0].name); // "Krishna Chaturdashi"
|
|
37
48
|
console.log(result.nakshatras[0].name); // "Mrigashira"
|
|
38
49
|
console.log(result.vara.name); // "Mangalavara"
|
|
39
|
-
|
|
50
|
+
|
|
51
|
+
// Lunar calendar
|
|
52
|
+
console.log(result.chandramasa.name); // "Pausha"
|
|
53
|
+
console.log(result.samvat.vikramSamvat); // 2081
|
|
54
|
+
console.log(result.samvat.shakaSamvat); // 1946
|
|
55
|
+
|
|
56
|
+
// Zodiac
|
|
57
|
+
console.log(result.chandraRashi.name); // "Mithuna" (Moon in Gemini)
|
|
58
|
+
console.log(result.suryaNakshatra.name); // "Uttara Ashadha"
|
|
59
|
+
|
|
60
|
+
// Astronomical events
|
|
40
61
|
console.log(result.sunrise); // Date (read via getUTC*)
|
|
62
|
+
console.log(result.moonrise); // Date | null
|
|
63
|
+
|
|
64
|
+
// Muhurta
|
|
65
|
+
console.log(result.brahmaMuhurta); // { start: Date, end: Date }
|
|
66
|
+
console.log(result.rahuKalam); // { start: Date, end: Date }
|
|
67
|
+
|
|
68
|
+
// Choghadiya — 8 daytime slots
|
|
69
|
+
result.choghadiya.day.forEach(slot => {
|
|
70
|
+
console.log(slot.name, slot.quality); // "Amrit", "auspicious"
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
// Panchaka
|
|
74
|
+
console.log(result.panchaka); // true | false
|
|
41
75
|
```
|
|
42
76
|
|
|
43
77
|
## Reading Output Times
|
|
@@ -61,6 +95,9 @@ fmt(result.rahuKalam.start); // "09:04"
|
|
|
61
95
|
|
|
62
96
|
Do **not** use `.getHours()` — it uses your system timezone, which may differ.
|
|
63
97
|
|
|
98
|
+
`moonrise` and `moonset` can be `null` — the Moon occasionally does not rise or set
|
|
99
|
+
on a given calendar day, which is normal.
|
|
100
|
+
|
|
64
101
|
---
|
|
65
102
|
|
|
66
103
|
## API Reference
|
|
@@ -100,10 +137,20 @@ const result = getDailyPanchang(
|
|
|
100
137
|
| `gulikaKalam` | `TimePeriod` | Gulika Kalam start/end |
|
|
101
138
|
| `yamaganda` | `TimePeriod` | Yamaganda start/end |
|
|
102
139
|
| `abhijitMuhurta` | `TimePeriod` | Abhijit Muhurta start/end |
|
|
140
|
+
| `brahmaMuhurta` | `TimePeriod` | Brahma Muhurta (96–48 min before sunrise) |
|
|
141
|
+
| `masa` | `MasaInfo` | Solar month (Saura Masa) |
|
|
142
|
+
| `chandramasa` | `ChandraMasaInfo` | Lunar month + Adhika (leap) flag |
|
|
143
|
+
| `samvat` | `SamvatInfo` | Vikram Samvat and Shaka Samvat year numbers |
|
|
144
|
+
| `chandraRashi` | `RashiInfo` | Moon's zodiac sign (changes every ~2.5 days) |
|
|
145
|
+
| `suryaNakshatra` | `RashiInfo` | Sun's nakshatra (changes every ~13–14 days) |
|
|
146
|
+
| `choghadiya` | `ChoghadiyaInfo` | 8 day slots + 8 night slots, each named and rated |
|
|
147
|
+
| `hora` | `HoraInfo` | 12 day horas + 12 night horas, each with ruling planet |
|
|
148
|
+
| `moonrise` | `Date \| null` | Moonrise (offset-adjusted); `null` if none that day |
|
|
149
|
+
| `moonset` | `Date \| null` | Moonset (offset-adjusted); `null` if none that day |
|
|
150
|
+
| `panchaka` | `boolean` | `true` when Moon is in last 5 nakshatras |
|
|
103
151
|
| `ayanamsa` | `number` | Ayanamsa in degrees at sunrise |
|
|
104
152
|
| `siderealSunAtSunrise` | `number` | Sun sidereal longitude at sunrise (°) |
|
|
105
153
|
| `siderealMoonAtSunrise` | `number` | Moon sidereal longitude at sunrise (°) |
|
|
106
|
-
| `masa` | `MasaInfo` | Solar month (Saura Masa) |
|
|
107
154
|
|
|
108
155
|
---
|
|
109
156
|
|
|
@@ -120,9 +167,12 @@ const result = getInstantPanchang(
|
|
|
120
167
|
{ language: 'sa' }, // Sanskrit names
|
|
121
168
|
);
|
|
122
169
|
|
|
123
|
-
console.log(result.tithi.name);
|
|
124
|
-
console.log(result.nakshatra.name);
|
|
125
|
-
console.log(result.
|
|
170
|
+
console.log(result.tithi.name); // "कृष्ण चतुर्दशी"
|
|
171
|
+
console.log(result.nakshatra.name); // "मृगशिरा"
|
|
172
|
+
console.log(result.chandramasa.name); // "पौष"
|
|
173
|
+
console.log(result.chandraRashi.name); // "मिथुन"
|
|
174
|
+
console.log(result.samvat.vikramSamvat); // 2081
|
|
175
|
+
console.log(result.panchaka); // false
|
|
126
176
|
```
|
|
127
177
|
|
|
128
178
|
**Returns: `InstantPanchangResult`**
|
|
@@ -136,6 +186,11 @@ console.log(result.tithi.endTime); // Date when this Tithi ends
|
|
|
136
186
|
| `yoga` | `YogaInfo` | Active Yoga |
|
|
137
187
|
| `karana` | `KaranaInfo` | Active Karana (movable or fixed) |
|
|
138
188
|
| `vara` | `VaraInfo` | Active Vara (weekday) |
|
|
189
|
+
| `chandramasa` | `ChandraMasaInfo` | Lunar month + Adhika flag |
|
|
190
|
+
| `samvat` | `SamvatInfo` | Vikram Samvat and Shaka Samvat year numbers |
|
|
191
|
+
| `chandraRashi` | `RashiInfo` | Moon's zodiac sign |
|
|
192
|
+
| `suryaNakshatra` | `RashiInfo` | Sun's nakshatra |
|
|
193
|
+
| `panchaka` | `boolean` | `true` when Moon is in last 5 nakshatras |
|
|
139
194
|
| `ayanamsa` | `number` | Ayanamsa in degrees |
|
|
140
195
|
| `siderealSun` | `number` | Sun sidereal longitude (°) |
|
|
141
196
|
| `siderealMoon` | `number` | Moon sidereal longitude (°) |
|
|
@@ -160,22 +215,26 @@ console.log(result.tithi.endTime); // Date when this Tithi ends
|
|
|
160
215
|
|
|
161
216
|
### Low-level Utilities
|
|
162
217
|
|
|
163
|
-
These are exported for advanced use cases (building your own
|
|
164
|
-
visualisations, or debugging).
|
|
218
|
+
These are exported for advanced use cases (building your own tools, visualisations, or debugging).
|
|
165
219
|
|
|
166
220
|
```typescript
|
|
167
221
|
import {
|
|
168
222
|
getSunrise, getSunset,
|
|
223
|
+
getMoonrise, getMoonset,
|
|
169
224
|
getSiderealSunLongitude, getSiderealMoonLongitude,
|
|
170
225
|
getAyanamsa,
|
|
171
226
|
computeRahuKalam, computeGulikaKalam, computeYamaganda,
|
|
172
|
-
computeAbhijitMuhurta,
|
|
227
|
+
computeAbhijitMuhurta, computeBrahmaMuhurta,
|
|
173
228
|
} from 'panchang-ts';
|
|
174
229
|
|
|
175
230
|
// Sunrise/sunset
|
|
176
231
|
const sunrise = getSunrise(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
177
232
|
const sunset = getSunset(sunrise, { latitude: 28.6, longitude: 77.2 });
|
|
178
233
|
|
|
234
|
+
// Moonrise/moonset — return null when the Moon doesn't rise/set that day
|
|
235
|
+
const moonrise = getMoonrise(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
236
|
+
const moonset = getMoonset(localMidnightUtc, { latitude: 28.6, longitude: 77.2 });
|
|
237
|
+
|
|
179
238
|
// Sidereal longitudes
|
|
180
239
|
const moonLon = getSiderealMoonLongitude(new Date(), 'lahiri'); // degrees [0, 360)
|
|
181
240
|
const sunLon = getSiderealSunLongitude(new Date(), 'lahiri');
|
|
@@ -184,8 +243,13 @@ const sunLon = getSiderealSunLongitude(new Date(), 'lahiri');
|
|
|
184
243
|
const ayan = getAyanamsa(new Date(), 'lahiri'); // e.g. 24.10
|
|
185
244
|
|
|
186
245
|
// Inauspicious periods (varaIndex: 0=Sun … 6=Sat)
|
|
187
|
-
const rahu
|
|
188
|
-
|
|
246
|
+
const rahu = computeRahuKalam(sunrise, sunset, varaIndex); // { start, end }
|
|
247
|
+
const gulika = computeGulikaKalam(sunrise, sunset, varaIndex);
|
|
248
|
+
const yama = computeYamaganda(sunrise, sunset, varaIndex);
|
|
249
|
+
|
|
250
|
+
// Muhurta
|
|
251
|
+
const abhijit = computeAbhijitMuhurta(sunrise, sunset); // { start, end }
|
|
252
|
+
const brahma = computeBrahmaMuhurta(sunrise, sunset); // { start, end }
|
|
189
253
|
```
|
|
190
254
|
|
|
191
255
|
---
|
|
@@ -204,6 +268,8 @@ interface TimePeriod {
|
|
|
204
268
|
end: Date;
|
|
205
269
|
}
|
|
206
270
|
|
|
271
|
+
// ── Pancha Anga ──────────────────────────────────────────────────────────────
|
|
272
|
+
|
|
207
273
|
interface TithiInfo {
|
|
208
274
|
index: number; // 0–29
|
|
209
275
|
name: string; // e.g. "Shukla Pratipada"
|
|
@@ -228,6 +294,55 @@ interface DailyTithiInfo extends TithiInfo {
|
|
|
228
294
|
}
|
|
229
295
|
|
|
230
296
|
// DailyNakshatraInfo, DailyYogaInfo, DailyKaranaInfo follow the same pattern
|
|
297
|
+
|
|
298
|
+
// ── Lunar calendar ───────────────────────────────────────────────────────────
|
|
299
|
+
|
|
300
|
+
interface ChandraMasaInfo {
|
|
301
|
+
index: number; // 0 = Chaitra … 11 = Phalguna
|
|
302
|
+
name: string; // e.g. "Pausha"
|
|
303
|
+
isAdhika: boolean; // true = leap/intercalary month
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
interface SamvatInfo {
|
|
307
|
+
vikramSamvat: number; // e.g. 2081
|
|
308
|
+
shakaSamvat: number; // e.g. 1946
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
// ── Zodiac & asterism ────────────────────────────────────────────────────────
|
|
312
|
+
|
|
313
|
+
interface RashiInfo {
|
|
314
|
+
index: number; // 0 = Mesha … 11 = Meena (for rashi); 0–26 for nakshatra
|
|
315
|
+
name: string;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// chandraRashi and suryaNakshatra both use RashiInfo
|
|
319
|
+
|
|
320
|
+
// ── Choghadiya ───────────────────────────────────────────────────────────────
|
|
321
|
+
|
|
322
|
+
type ChoghadiyaQuality = 'auspicious' | 'inauspicious' | 'neutral';
|
|
323
|
+
|
|
324
|
+
interface ChoghadiyaSlot extends TimePeriod {
|
|
325
|
+
index: number;
|
|
326
|
+
name: string; // e.g. "Amrit", "Kaal", "Shubh"
|
|
327
|
+
quality: ChoghadiyaQuality;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
interface ChoghadiyaInfo {
|
|
331
|
+
day: ChoghadiyaSlot[]; // 8 slots (sunrise → sunset)
|
|
332
|
+
night: ChoghadiyaSlot[]; // 8 slots (sunset → next sunrise)
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
// ── Hora ─────────────────────────────────────────────────────────────────────
|
|
336
|
+
|
|
337
|
+
interface HoraSlot extends TimePeriod {
|
|
338
|
+
planet: string; // "Sun", "Moon", "Mars", "Mercury", "Jupiter", "Venus", "Saturn"
|
|
339
|
+
planetIndex: number; // 0–6 in Chaldean order
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
interface HoraInfo {
|
|
343
|
+
day: HoraSlot[]; // 12 slots (sunrise → sunset)
|
|
344
|
+
night: HoraSlot[]; // 12 slots (sunset → next sunrise)
|
|
345
|
+
}
|
|
231
346
|
```
|
|
232
347
|
|
|
233
348
|
---
|
|
@@ -264,8 +379,8 @@ InteractionManager.runAfterInteractions(() => {
|
|
|
264
379
|
|
|
265
380
|
| Mode | Node.js | Hermes (budget Android) |
|
|
266
381
|
|------|---------|------------------------|
|
|
267
|
-
| Names-only (`computeEndTimes: false`) | ~0.1 ms |
|
|
268
|
-
| Full with end-times | ~0.5 ms |
|
|
382
|
+
| Names-only (`computeEndTimes: false`) | ~0.1 ms | <100 ms |
|
|
383
|
+
| Full with end-times | ~0.5 ms | <500 ms |
|
|
269
384
|
|
|
270
385
|
Measured with Vitest benchmarks on Node 22 and on a physical budget Android device
|
|
271
386
|
via the dharmSetu React Native app.
|
|
@@ -279,9 +394,11 @@ Validated against [DrikPanchang.com](https://www.drikpanchang.com) for 15+ date/
|
|
|
279
394
|
| Element | Accuracy |
|
|
280
395
|
|---------|----------|
|
|
281
396
|
| Sunrise / Sunset | ±2 minutes |
|
|
397
|
+
| Moonrise / Moonset | ±2 minutes |
|
|
282
398
|
| Tithi, Nakshatra, Yoga, Karana names | Exact match |
|
|
283
399
|
| Element end-times | ±5 minutes |
|
|
284
400
|
| Ayanamsa | ±0.005° vs Swiss Ephemeris |
|
|
401
|
+
| Choghadiya / Hora slots | Derived from sunrise/sunset — inherits ±2 min |
|
|
285
402
|
|
|
286
403
|
---
|
|
287
404
|
|
|
@@ -317,6 +434,9 @@ try {
|
|
|
317
434
|
`PanchangErrorCode` values: `INVALID_DATE`, `INVALID_LATITUDE`, `INVALID_LONGITUDE`,
|
|
318
435
|
`INVALID_TIMEZONE`, `INVALID_AYANAMSA`, `NO_SUNRISE`, `NO_SUNSET`.
|
|
319
436
|
|
|
437
|
+
Note: `getMoonrise` / `getMoonset` never throw — they return `null` when no rise/set
|
|
438
|
+
occurs within the search window (this is normal for the Moon).
|
|
439
|
+
|
|
320
440
|
---
|
|
321
441
|
|
|
322
442
|
## 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,12 +3702,15 @@ 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;
|
package/dist/index.d.cts
CHANGED
|
@@ -65,6 +65,53 @@ interface DailyYogaInfo extends YogaInfo, DailyElementBase {
|
|
|
65
65
|
}
|
|
66
66
|
interface DailyKaranaInfo extends KaranaInfo, DailyElementBase {
|
|
67
67
|
}
|
|
68
|
+
interface RashiInfo {
|
|
69
|
+
/** 0 = Mesha … 11 = Meena */
|
|
70
|
+
index: number;
|
|
71
|
+
name: string;
|
|
72
|
+
}
|
|
73
|
+
interface ChandraMasaInfo {
|
|
74
|
+
/** 0 = Chaitra … 11 = Phalguna (Amanta / South-Indian system) */
|
|
75
|
+
index: number;
|
|
76
|
+
/** Translated month name (Amanta) */
|
|
77
|
+
name: string;
|
|
78
|
+
/** True when two new moons fall in the same solar month (extra/leap month) */
|
|
79
|
+
isAdhika: boolean;
|
|
80
|
+
/** Month index in the Purnimanta (North-Indian) system */
|
|
81
|
+
purnimantaIndex: number;
|
|
82
|
+
/** Month name in the Purnimanta system */
|
|
83
|
+
purnimantaName: string;
|
|
84
|
+
}
|
|
85
|
+
type ChoghadiyaQuality = 'auspicious' | 'inauspicious' | 'neutral';
|
|
86
|
+
interface ChoghadiyaSlot extends TimePeriod {
|
|
87
|
+
/** 0–6: index within the 7-name Choghadiya cycle */
|
|
88
|
+
index: number;
|
|
89
|
+
name: string;
|
|
90
|
+
quality: ChoghadiyaQuality;
|
|
91
|
+
}
|
|
92
|
+
interface ChoghadiyaInfo {
|
|
93
|
+
/** 8 equal slots from sunrise to sunset */
|
|
94
|
+
day: ChoghadiyaSlot[];
|
|
95
|
+
/** 8 equal slots from sunset to next sunrise */
|
|
96
|
+
night: ChoghadiyaSlot[];
|
|
97
|
+
}
|
|
98
|
+
interface HoraSlot extends TimePeriod {
|
|
99
|
+
/** 0–6 in Chaldean order: Sun, Venus, Mercury, Moon, Saturn, Jupiter, Mars */
|
|
100
|
+
planetIndex: number;
|
|
101
|
+
planet: string;
|
|
102
|
+
}
|
|
103
|
+
interface HoraInfo {
|
|
104
|
+
/** 12 equal horas from sunrise to sunset */
|
|
105
|
+
day: HoraSlot[];
|
|
106
|
+
/** 12 equal horas from sunset to next sunrise */
|
|
107
|
+
night: HoraSlot[];
|
|
108
|
+
}
|
|
109
|
+
interface SamvatInfo {
|
|
110
|
+
/** Vikram Samvat year (increments at Chaitra Shukla Pratipad ≈ April) */
|
|
111
|
+
vikramSamvat: number;
|
|
112
|
+
/** Shaka Samvat year (same new-year point, offset 135 years behind VS) */
|
|
113
|
+
shakaSamvat: number;
|
|
114
|
+
}
|
|
68
115
|
|
|
69
116
|
interface MasaInfo {
|
|
70
117
|
index: number;
|
|
@@ -92,6 +139,17 @@ interface DailyPanchangResult {
|
|
|
92
139
|
siderealSunAtSunrise: number;
|
|
93
140
|
siderealMoonAtSunrise: number;
|
|
94
141
|
masa: MasaInfo;
|
|
142
|
+
chandramasa: ChandraMasaInfo;
|
|
143
|
+
samvat: SamvatInfo;
|
|
144
|
+
chandraRashi: RashiInfo;
|
|
145
|
+
/** Sun's current Nakshatra (changes every ~13–14 days) */
|
|
146
|
+
suryaNakshatra: RashiInfo;
|
|
147
|
+
brahmaMuhurta: TimePeriod;
|
|
148
|
+
choghadiya: ChoghadiyaInfo;
|
|
149
|
+
hora: HoraInfo;
|
|
150
|
+
moonrise: Date | null;
|
|
151
|
+
moonset: Date | null;
|
|
152
|
+
panchaka: boolean;
|
|
95
153
|
_debug?: {
|
|
96
154
|
totalMs: number;
|
|
97
155
|
sunriseMs: number;
|
|
@@ -110,6 +168,12 @@ interface InstantPanchangResult {
|
|
|
110
168
|
ayanamsa: number;
|
|
111
169
|
siderealSun: number;
|
|
112
170
|
siderealMoon: number;
|
|
171
|
+
chandramasa: ChandraMasaInfo;
|
|
172
|
+
samvat: SamvatInfo;
|
|
173
|
+
chandraRashi: RashiInfo;
|
|
174
|
+
/** Sun's current Nakshatra (changes every ~13–14 days) */
|
|
175
|
+
suryaNakshatra: RashiInfo;
|
|
176
|
+
panchaka: boolean;
|
|
113
177
|
}
|
|
114
178
|
|
|
115
179
|
/**
|
|
@@ -208,6 +272,30 @@ declare function computeSunrise(searchFromUtc: Date, location: GeoLocation, limi
|
|
|
208
272
|
*/
|
|
209
273
|
declare function computeSunset(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date;
|
|
210
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Search for the next moonrise on or after the given UTC instant.
|
|
277
|
+
*
|
|
278
|
+
* Unlike sunrise, the Moon can have no rise on a given calendar day —
|
|
279
|
+
* this function returns `null` in that case rather than throwing.
|
|
280
|
+
*
|
|
281
|
+
* @param searchFromUtc Start searching from this UTC instant.
|
|
282
|
+
* @param location Observer coordinates.
|
|
283
|
+
* @param limitDays How far ahead to search. Default 2.
|
|
284
|
+
* @returns Moonrise as a UTC Date, or `null` if none found.
|
|
285
|
+
*/
|
|
286
|
+
declare function getMoonrise(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date | null;
|
|
287
|
+
/**
|
|
288
|
+
* Search for the next moonset on or after the given UTC instant.
|
|
289
|
+
*
|
|
290
|
+
* Returns `null` if no moonset is found within the search window.
|
|
291
|
+
*
|
|
292
|
+
* @param searchFromUtc Start searching from this UTC instant.
|
|
293
|
+
* @param location Observer coordinates.
|
|
294
|
+
* @param limitDays How far ahead to search. Default 2.
|
|
295
|
+
* @returns Moonset as a UTC Date, or `null` if none found.
|
|
296
|
+
*/
|
|
297
|
+
declare function getMoonset(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date | null;
|
|
298
|
+
|
|
211
299
|
/**
|
|
212
300
|
* Sidereal longitude of the Sun at a given UTC instant.
|
|
213
301
|
* Returns degrees in range [0, 360).
|
|
@@ -285,6 +373,20 @@ declare function computeYamaganda(sunrise: Date, sunset: Date, varaIndex: number
|
|
|
285
373
|
* @param sunset Sunset UTC Date
|
|
286
374
|
*/
|
|
287
375
|
declare function computeAbhijitMuhurta(sunrise: Date, sunset: Date): TimePeriod;
|
|
376
|
+
/**
|
|
377
|
+
* Brahma Muhurta: the auspicious 96-minute window ending 48 minutes before sunrise.
|
|
378
|
+
*
|
|
379
|
+
* Daytime is divided into 30 equal muhurtas (each ≈ 48 min for a 12-hour day).
|
|
380
|
+
* Brahma Muhurta spans the 29th and 30th muhurtas of the *preceding* night,
|
|
381
|
+
* i.e. the two muhurtas immediately before sunrise.
|
|
382
|
+
*
|
|
383
|
+
* Start: sunrise − 2 × muhurtaDuration
|
|
384
|
+
* End: sunrise − 1 × muhurtaDuration
|
|
385
|
+
*
|
|
386
|
+
* @param sunrise Sunrise UTC Date
|
|
387
|
+
* @param sunset Sunset UTC Date (used to derive the muhurta length)
|
|
388
|
+
*/
|
|
389
|
+
declare function computeBrahmaMuhurta(sunrise: Date, sunset: Date): TimePeriod;
|
|
288
390
|
|
|
289
391
|
type PanchangErrorCode = 'INVALID_LATITUDE' | 'INVALID_LONGITUDE' | 'INVALID_ELEVATION' | 'INVALID_DATE' | 'INVALID_TIMEZONE' | 'INVALID_AYANAMSA' | 'TIMEZONE_RESOLUTION_FAILED' | 'NO_SUNRISE' | 'NO_SUNSET' | 'SEARCH_DIVERGED';
|
|
290
392
|
declare class PanchangError extends Error {
|
|
@@ -292,4 +394,4 @@ declare class PanchangError extends Error {
|
|
|
292
394
|
constructor(message: string, code: PanchangErrorCode);
|
|
293
395
|
}
|
|
294
396
|
|
|
295
|
-
export { type AyanamsaType, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type GeoLocation, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type Precision, type TimePeriod, type TithiInfo, type VaraInfo, type YogaInfo, computeAbhijitMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
|
397
|
+
export { type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type GeoLocation, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type Precision, type RashiInfo, type SamvatInfo, type TimePeriod, type TithiInfo, type VaraInfo, type YogaInfo, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/dist/index.d.ts
CHANGED
|
@@ -65,6 +65,53 @@ interface DailyYogaInfo extends YogaInfo, DailyElementBase {
|
|
|
65
65
|
}
|
|
66
66
|
interface DailyKaranaInfo extends KaranaInfo, DailyElementBase {
|
|
67
67
|
}
|
|
68
|
+
interface RashiInfo {
|
|
69
|
+
/** 0 = Mesha … 11 = Meena */
|
|
70
|
+
index: number;
|
|
71
|
+
name: string;
|
|
72
|
+
}
|
|
73
|
+
interface ChandraMasaInfo {
|
|
74
|
+
/** 0 = Chaitra … 11 = Phalguna (Amanta / South-Indian system) */
|
|
75
|
+
index: number;
|
|
76
|
+
/** Translated month name (Amanta) */
|
|
77
|
+
name: string;
|
|
78
|
+
/** True when two new moons fall in the same solar month (extra/leap month) */
|
|
79
|
+
isAdhika: boolean;
|
|
80
|
+
/** Month index in the Purnimanta (North-Indian) system */
|
|
81
|
+
purnimantaIndex: number;
|
|
82
|
+
/** Month name in the Purnimanta system */
|
|
83
|
+
purnimantaName: string;
|
|
84
|
+
}
|
|
85
|
+
type ChoghadiyaQuality = 'auspicious' | 'inauspicious' | 'neutral';
|
|
86
|
+
interface ChoghadiyaSlot extends TimePeriod {
|
|
87
|
+
/** 0–6: index within the 7-name Choghadiya cycle */
|
|
88
|
+
index: number;
|
|
89
|
+
name: string;
|
|
90
|
+
quality: ChoghadiyaQuality;
|
|
91
|
+
}
|
|
92
|
+
interface ChoghadiyaInfo {
|
|
93
|
+
/** 8 equal slots from sunrise to sunset */
|
|
94
|
+
day: ChoghadiyaSlot[];
|
|
95
|
+
/** 8 equal slots from sunset to next sunrise */
|
|
96
|
+
night: ChoghadiyaSlot[];
|
|
97
|
+
}
|
|
98
|
+
interface HoraSlot extends TimePeriod {
|
|
99
|
+
/** 0–6 in Chaldean order: Sun, Venus, Mercury, Moon, Saturn, Jupiter, Mars */
|
|
100
|
+
planetIndex: number;
|
|
101
|
+
planet: string;
|
|
102
|
+
}
|
|
103
|
+
interface HoraInfo {
|
|
104
|
+
/** 12 equal horas from sunrise to sunset */
|
|
105
|
+
day: HoraSlot[];
|
|
106
|
+
/** 12 equal horas from sunset to next sunrise */
|
|
107
|
+
night: HoraSlot[];
|
|
108
|
+
}
|
|
109
|
+
interface SamvatInfo {
|
|
110
|
+
/** Vikram Samvat year (increments at Chaitra Shukla Pratipad ≈ April) */
|
|
111
|
+
vikramSamvat: number;
|
|
112
|
+
/** Shaka Samvat year (same new-year point, offset 135 years behind VS) */
|
|
113
|
+
shakaSamvat: number;
|
|
114
|
+
}
|
|
68
115
|
|
|
69
116
|
interface MasaInfo {
|
|
70
117
|
index: number;
|
|
@@ -92,6 +139,17 @@ interface DailyPanchangResult {
|
|
|
92
139
|
siderealSunAtSunrise: number;
|
|
93
140
|
siderealMoonAtSunrise: number;
|
|
94
141
|
masa: MasaInfo;
|
|
142
|
+
chandramasa: ChandraMasaInfo;
|
|
143
|
+
samvat: SamvatInfo;
|
|
144
|
+
chandraRashi: RashiInfo;
|
|
145
|
+
/** Sun's current Nakshatra (changes every ~13–14 days) */
|
|
146
|
+
suryaNakshatra: RashiInfo;
|
|
147
|
+
brahmaMuhurta: TimePeriod;
|
|
148
|
+
choghadiya: ChoghadiyaInfo;
|
|
149
|
+
hora: HoraInfo;
|
|
150
|
+
moonrise: Date | null;
|
|
151
|
+
moonset: Date | null;
|
|
152
|
+
panchaka: boolean;
|
|
95
153
|
_debug?: {
|
|
96
154
|
totalMs: number;
|
|
97
155
|
sunriseMs: number;
|
|
@@ -110,6 +168,12 @@ interface InstantPanchangResult {
|
|
|
110
168
|
ayanamsa: number;
|
|
111
169
|
siderealSun: number;
|
|
112
170
|
siderealMoon: number;
|
|
171
|
+
chandramasa: ChandraMasaInfo;
|
|
172
|
+
samvat: SamvatInfo;
|
|
173
|
+
chandraRashi: RashiInfo;
|
|
174
|
+
/** Sun's current Nakshatra (changes every ~13–14 days) */
|
|
175
|
+
suryaNakshatra: RashiInfo;
|
|
176
|
+
panchaka: boolean;
|
|
113
177
|
}
|
|
114
178
|
|
|
115
179
|
/**
|
|
@@ -208,6 +272,30 @@ declare function computeSunrise(searchFromUtc: Date, location: GeoLocation, limi
|
|
|
208
272
|
*/
|
|
209
273
|
declare function computeSunset(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date;
|
|
210
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Search for the next moonrise on or after the given UTC instant.
|
|
277
|
+
*
|
|
278
|
+
* Unlike sunrise, the Moon can have no rise on a given calendar day —
|
|
279
|
+
* this function returns `null` in that case rather than throwing.
|
|
280
|
+
*
|
|
281
|
+
* @param searchFromUtc Start searching from this UTC instant.
|
|
282
|
+
* @param location Observer coordinates.
|
|
283
|
+
* @param limitDays How far ahead to search. Default 2.
|
|
284
|
+
* @returns Moonrise as a UTC Date, or `null` if none found.
|
|
285
|
+
*/
|
|
286
|
+
declare function getMoonrise(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date | null;
|
|
287
|
+
/**
|
|
288
|
+
* Search for the next moonset on or after the given UTC instant.
|
|
289
|
+
*
|
|
290
|
+
* Returns `null` if no moonset is found within the search window.
|
|
291
|
+
*
|
|
292
|
+
* @param searchFromUtc Start searching from this UTC instant.
|
|
293
|
+
* @param location Observer coordinates.
|
|
294
|
+
* @param limitDays How far ahead to search. Default 2.
|
|
295
|
+
* @returns Moonset as a UTC Date, or `null` if none found.
|
|
296
|
+
*/
|
|
297
|
+
declare function getMoonset(searchFromUtc: Date, location: GeoLocation, limitDays?: number): Date | null;
|
|
298
|
+
|
|
211
299
|
/**
|
|
212
300
|
* Sidereal longitude of the Sun at a given UTC instant.
|
|
213
301
|
* Returns degrees in range [0, 360).
|
|
@@ -285,6 +373,20 @@ declare function computeYamaganda(sunrise: Date, sunset: Date, varaIndex: number
|
|
|
285
373
|
* @param sunset Sunset UTC Date
|
|
286
374
|
*/
|
|
287
375
|
declare function computeAbhijitMuhurta(sunrise: Date, sunset: Date): TimePeriod;
|
|
376
|
+
/**
|
|
377
|
+
* Brahma Muhurta: the auspicious 96-minute window ending 48 minutes before sunrise.
|
|
378
|
+
*
|
|
379
|
+
* Daytime is divided into 30 equal muhurtas (each ≈ 48 min for a 12-hour day).
|
|
380
|
+
* Brahma Muhurta spans the 29th and 30th muhurtas of the *preceding* night,
|
|
381
|
+
* i.e. the two muhurtas immediately before sunrise.
|
|
382
|
+
*
|
|
383
|
+
* Start: sunrise − 2 × muhurtaDuration
|
|
384
|
+
* End: sunrise − 1 × muhurtaDuration
|
|
385
|
+
*
|
|
386
|
+
* @param sunrise Sunrise UTC Date
|
|
387
|
+
* @param sunset Sunset UTC Date (used to derive the muhurta length)
|
|
388
|
+
*/
|
|
389
|
+
declare function computeBrahmaMuhurta(sunrise: Date, sunset: Date): TimePeriod;
|
|
288
390
|
|
|
289
391
|
type PanchangErrorCode = 'INVALID_LATITUDE' | 'INVALID_LONGITUDE' | 'INVALID_ELEVATION' | 'INVALID_DATE' | 'INVALID_TIMEZONE' | 'INVALID_AYANAMSA' | 'TIMEZONE_RESOLUTION_FAILED' | 'NO_SUNRISE' | 'NO_SUNSET' | 'SEARCH_DIVERGED';
|
|
290
392
|
declare class PanchangError extends Error {
|
|
@@ -292,4 +394,4 @@ declare class PanchangError extends Error {
|
|
|
292
394
|
constructor(message: string, code: PanchangErrorCode);
|
|
293
395
|
}
|
|
294
396
|
|
|
295
|
-
export { type AyanamsaType, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type GeoLocation, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type Precision, type TimePeriod, type TithiInfo, type VaraInfo, type YogaInfo, computeAbhijitMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
|
397
|
+
export { type AyanamsaType, type ChandraMasaInfo, type ChoghadiyaInfo, type ChoghadiyaQuality, type ChoghadiyaSlot, type DailyKaranaInfo, type DailyNakshatraInfo, type DailyPanchangResult, type DailyTithiInfo, type DailyYogaInfo, type GeoLocation, type HoraInfo, type HoraSlot, type InstantPanchangOptions, type InstantPanchangResult, type KaranaInfo, type Language, type MasaInfo, type NakshatraInfo, PanchangError, type PanchangErrorCode, type PanchangOptions, type Precision, type RashiInfo, type SamvatInfo, type TimePeriod, type TithiInfo, type VaraInfo, type YogaInfo, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/dist/index.js
CHANGED
|
@@ -2903,6 +2903,13 @@ function computeAbhijitMuhurta(sunrise, sunset) {
|
|
|
2903
2903
|
const end = new Date(start.getTime() + muhurtaDurationMs);
|
|
2904
2904
|
return { start, end };
|
|
2905
2905
|
}
|
|
2906
|
+
function computeBrahmaMuhurta(sunrise, sunset) {
|
|
2907
|
+
const dayDurationMs = sunset.getTime() - sunrise.getTime();
|
|
2908
|
+
const muhurtaDurationMs = dayDurationMs / 30;
|
|
2909
|
+
const end = new Date(sunrise.getTime() - muhurtaDurationMs);
|
|
2910
|
+
const start = new Date(end.getTime() - muhurtaDurationMs);
|
|
2911
|
+
return { start, end };
|
|
2912
|
+
}
|
|
2906
2913
|
|
|
2907
2914
|
// src/core/masa.ts
|
|
2908
2915
|
var MASA_NAMES_EN = [
|
|
@@ -2927,6 +2934,143 @@ function computeMasa(siderealSunLon) {
|
|
|
2927
2934
|
};
|
|
2928
2935
|
}
|
|
2929
2936
|
|
|
2937
|
+
// src/core/chandramasa.ts
|
|
2938
|
+
var SYNODIC_MONTH = 29.53059;
|
|
2939
|
+
var TROPICAL_YEAR = 365.25;
|
|
2940
|
+
function computeChandraMasa(siderealSun, siderealMoon, nameFn) {
|
|
2941
|
+
const elongation = (siderealMoon - siderealSun + 360) % 360;
|
|
2942
|
+
const daysElapsed = elongation / 360 * SYNODIC_MONTH;
|
|
2943
|
+
const sunAtPrevNewMoon = (siderealSun - daysElapsed / TROPICAL_YEAR * 360 + 36e3) % 360;
|
|
2944
|
+
const solarMonthAtPrev = Math.floor(sunAtPrevNewMoon / 30);
|
|
2945
|
+
const daysUntilNext = SYNODIC_MONTH - daysElapsed;
|
|
2946
|
+
const sunAtNextNewMoon = (siderealSun + daysUntilNext / TROPICAL_YEAR * 360) % 360;
|
|
2947
|
+
const solarMonthAtNext = Math.floor(sunAtNextNewMoon / 30);
|
|
2948
|
+
const isAdhika = solarMonthAtPrev === solarMonthAtNext;
|
|
2949
|
+
const index = solarMonthAtPrev;
|
|
2950
|
+
const name = nameFn(index, isAdhika);
|
|
2951
|
+
const isKrishnaPaksha = elongation >= 180;
|
|
2952
|
+
const purnimantaIndex = isKrishnaPaksha ? (index + 1) % 12 : index;
|
|
2953
|
+
const purnimantaName = nameFn(purnimantaIndex, false);
|
|
2954
|
+
return { index, name, isAdhika, purnimantaIndex, purnimantaName };
|
|
2955
|
+
}
|
|
2956
|
+
|
|
2957
|
+
// src/core/samvat.ts
|
|
2958
|
+
function computeSamvat(date) {
|
|
2959
|
+
const year = date.getUTCFullYear();
|
|
2960
|
+
const pastNewYear = date.getUTCMonth() >= 3;
|
|
2961
|
+
return {
|
|
2962
|
+
vikramSamvat: year + (pastNewYear ? 57 : 56),
|
|
2963
|
+
shakaSamvat: year + (pastNewYear ? -78 : -79)
|
|
2964
|
+
};
|
|
2965
|
+
}
|
|
2966
|
+
|
|
2967
|
+
// src/core/rashi.ts
|
|
2968
|
+
function computeChandraRashi(siderealMoon, nameFn) {
|
|
2969
|
+
const index = Math.floor(siderealMoon / 30);
|
|
2970
|
+
return { index, name: nameFn(index) };
|
|
2971
|
+
}
|
|
2972
|
+
function computeSuryaNakshatra(siderealSun, nameFn) {
|
|
2973
|
+
const index = Math.floor(siderealSun / NAKSHATRA_SPAN);
|
|
2974
|
+
return { index, name: nameFn(index) };
|
|
2975
|
+
}
|
|
2976
|
+
|
|
2977
|
+
// src/core/choghadiya.ts
|
|
2978
|
+
var CHOGHADIYA_QUALITY = [
|
|
2979
|
+
"inauspicious",
|
|
2980
|
+
// 0 Udveg (Sun)
|
|
2981
|
+
"neutral",
|
|
2982
|
+
// 1 Char (Venus)
|
|
2983
|
+
"auspicious",
|
|
2984
|
+
// 2 Labh (Mercury)
|
|
2985
|
+
"auspicious",
|
|
2986
|
+
// 3 Amrit (Moon) — most auspicious
|
|
2987
|
+
"inauspicious",
|
|
2988
|
+
// 4 Kaal (Saturn)
|
|
2989
|
+
"auspicious",
|
|
2990
|
+
// 5 Shubh (Jupiter)
|
|
2991
|
+
"inauspicious"
|
|
2992
|
+
// 6 Rog (Mars)
|
|
2993
|
+
];
|
|
2994
|
+
var DAY_START_INDEX = [0, 3, 6, 2, 5, 1, 4];
|
|
2995
|
+
var NIGHT_START_INDEX = [5, 1, 4, 6, 0, 3, 2];
|
|
2996
|
+
function buildSlots(reference, durationMs, startIndex, nameFn, count) {
|
|
2997
|
+
const slotMs = durationMs / count;
|
|
2998
|
+
const slots = [];
|
|
2999
|
+
for (let i = 0; i < count; i++) {
|
|
3000
|
+
const idx = (startIndex + i) % 7;
|
|
3001
|
+
slots.push({
|
|
3002
|
+
start: new Date(reference.getTime() + i * slotMs),
|
|
3003
|
+
end: new Date(reference.getTime() + (i + 1) * slotMs),
|
|
3004
|
+
index: idx,
|
|
3005
|
+
name: nameFn(idx),
|
|
3006
|
+
quality: CHOGHADIYA_QUALITY[idx]
|
|
3007
|
+
});
|
|
3008
|
+
}
|
|
3009
|
+
return slots;
|
|
3010
|
+
}
|
|
3011
|
+
function computeChoghadiya(sunrise, sunset, nextSunrise, varaIndex, nameFn) {
|
|
3012
|
+
const dayMs = sunset.getTime() - sunrise.getTime();
|
|
3013
|
+
const nightMs = nextSunrise.getTime() - sunset.getTime();
|
|
3014
|
+
return {
|
|
3015
|
+
day: buildSlots(sunrise, dayMs, DAY_START_INDEX[varaIndex], nameFn, 8),
|
|
3016
|
+
night: buildSlots(sunset, nightMs, NIGHT_START_INDEX[varaIndex], nameFn, 8)
|
|
3017
|
+
};
|
|
3018
|
+
}
|
|
3019
|
+
|
|
3020
|
+
// src/core/hora.ts
|
|
3021
|
+
var DAY_FIRST_HORA = [0, 3, 6, 2, 5, 1, 4];
|
|
3022
|
+
function buildHoras(reference, durationMs, firstPlanetIndex, nameFn, count) {
|
|
3023
|
+
const horaMs = durationMs / count;
|
|
3024
|
+
const horas = [];
|
|
3025
|
+
for (let i = 0; i < count; i++) {
|
|
3026
|
+
const planetIndex = (firstPlanetIndex + i) % 7;
|
|
3027
|
+
horas.push({
|
|
3028
|
+
start: new Date(reference.getTime() + i * horaMs),
|
|
3029
|
+
end: new Date(reference.getTime() + (i + 1) * horaMs),
|
|
3030
|
+
planetIndex,
|
|
3031
|
+
planet: nameFn(planetIndex)
|
|
3032
|
+
});
|
|
3033
|
+
}
|
|
3034
|
+
return horas;
|
|
3035
|
+
}
|
|
3036
|
+
function computeHora(sunrise, sunset, nextSunrise, varaIndex, nameFn) {
|
|
3037
|
+
const dayMs = sunset.getTime() - sunrise.getTime();
|
|
3038
|
+
const nightMs = nextSunrise.getTime() - sunset.getTime();
|
|
3039
|
+
const firstDay = DAY_FIRST_HORA[varaIndex];
|
|
3040
|
+
const firstNight = (firstDay + 12) % 7;
|
|
3041
|
+
return {
|
|
3042
|
+
day: buildHoras(sunrise, dayMs, firstDay, nameFn, 12),
|
|
3043
|
+
night: buildHoras(sunset, nightMs, firstNight, nameFn, 12)
|
|
3044
|
+
};
|
|
3045
|
+
}
|
|
3046
|
+
|
|
3047
|
+
// src/core/panchaka.ts
|
|
3048
|
+
function computePanchaka(siderealMoon) {
|
|
3049
|
+
return siderealMoon >= 300;
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
// src/astronomy/moonrise.ts
|
|
3053
|
+
function getMoonrise(searchFromUtc, location, limitDays = 2) {
|
|
3054
|
+
const observer = new Observer(
|
|
3055
|
+
location.latitude,
|
|
3056
|
+
location.longitude,
|
|
3057
|
+
location.elevation ?? 0
|
|
3058
|
+
);
|
|
3059
|
+
const astroTime = MakeTime(searchFromUtc);
|
|
3060
|
+
const result = SearchRiseSet(Body.Moon, observer, 1, astroTime, limitDays);
|
|
3061
|
+
return result ? result.date : null;
|
|
3062
|
+
}
|
|
3063
|
+
function getMoonset(searchFromUtc, location, limitDays = 2) {
|
|
3064
|
+
const observer = new Observer(
|
|
3065
|
+
location.latitude,
|
|
3066
|
+
location.longitude,
|
|
3067
|
+
location.elevation ?? 0
|
|
3068
|
+
);
|
|
3069
|
+
const astroTime = MakeTime(searchFromUtc);
|
|
3070
|
+
const result = SearchRiseSet(Body.Moon, observer, -1, astroTime, limitDays);
|
|
3071
|
+
return result ? result.date : null;
|
|
3072
|
+
}
|
|
3073
|
+
|
|
2930
3074
|
// src/i18n/en.ts
|
|
2931
3075
|
var en = {
|
|
2932
3076
|
tithiNames: [
|
|
@@ -3031,7 +3175,23 @@ var en = {
|
|
|
3031
3175
|
"Kumbha",
|
|
3032
3176
|
"Meena"
|
|
3033
3177
|
],
|
|
3034
|
-
|
|
3178
|
+
chandraMasaNames: [
|
|
3179
|
+
"Chaitra",
|
|
3180
|
+
"Vaishakha",
|
|
3181
|
+
"Jyeshtha",
|
|
3182
|
+
"Ashadha",
|
|
3183
|
+
"Shravana",
|
|
3184
|
+
"Bhadrapada",
|
|
3185
|
+
"Ashwin",
|
|
3186
|
+
"Kartika",
|
|
3187
|
+
"Margashirsha",
|
|
3188
|
+
"Pausha",
|
|
3189
|
+
"Magha",
|
|
3190
|
+
"Phalguna"
|
|
3191
|
+
],
|
|
3192
|
+
choghadiyaNames: ["Udveg", "Char", "Labh", "Amrit", "Kaal", "Shubh", "Rog"],
|
|
3193
|
+
grahaNames: ["Sun", "Venus", "Mercury", "Moon", "Saturn", "Jupiter", "Mars"],
|
|
3194
|
+
misc: { purnima: "Purnima", amavasya: "Amavasya", adhika: "Adhika" }
|
|
3035
3195
|
};
|
|
3036
3196
|
|
|
3037
3197
|
// src/i18n/sa.ts
|
|
@@ -3138,7 +3298,23 @@ var sa = {
|
|
|
3138
3298
|
"\u0915\u0941\u092E\u094D\u092D",
|
|
3139
3299
|
"\u092E\u0940\u0928"
|
|
3140
3300
|
],
|
|
3141
|
-
|
|
3301
|
+
chandraMasaNames: [
|
|
3302
|
+
"\u091A\u0948\u0924\u094D\u0930",
|
|
3303
|
+
"\u0935\u0948\u0936\u093E\u0916",
|
|
3304
|
+
"\u091C\u094D\u092F\u0947\u0937\u094D\u0920",
|
|
3305
|
+
"\u0906\u0937\u093E\u0922",
|
|
3306
|
+
"\u0936\u094D\u0930\u093E\u0935\u0923",
|
|
3307
|
+
"\u092D\u093E\u0926\u094D\u0930\u092A\u0926",
|
|
3308
|
+
"\u0906\u0936\u094D\u0935\u093F\u0928",
|
|
3309
|
+
"\u0915\u093E\u0930\u094D\u0924\u093F\u0915",
|
|
3310
|
+
"\u092E\u093E\u0930\u094D\u0917\u0936\u0940\u0930\u094D\u0937",
|
|
3311
|
+
"\u092A\u094C\u0937",
|
|
3312
|
+
"\u092E\u093E\u0918",
|
|
3313
|
+
"\u092B\u093E\u0932\u094D\u0917\u0941\u0928"
|
|
3314
|
+
],
|
|
3315
|
+
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"],
|
|
3316
|
+
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"],
|
|
3317
|
+
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" }
|
|
3142
3318
|
};
|
|
3143
3319
|
|
|
3144
3320
|
// src/i18n/hi.ts
|
|
@@ -3169,6 +3345,14 @@ function resolveKaranaName(index, lang) {
|
|
|
3169
3345
|
if (index >= 57) return t.karanaNames.fixed[index - 56];
|
|
3170
3346
|
return t.karanaNames.movable[(index - 1) % 7];
|
|
3171
3347
|
}
|
|
3348
|
+
function resolveMasaName(index, lang) {
|
|
3349
|
+
return getTranslations(lang).masaNames[index];
|
|
3350
|
+
}
|
|
3351
|
+
function resolveChandraMasaName(index, lang, adhika = false) {
|
|
3352
|
+
const t = getTranslations(lang);
|
|
3353
|
+
const name = t.chandraMasaNames[index];
|
|
3354
|
+
return adhika ? `${t.misc.adhika} ${name}` : name;
|
|
3355
|
+
}
|
|
3172
3356
|
|
|
3173
3357
|
// src/core/panchang.ts
|
|
3174
3358
|
function getInstantPanchang(date, location, options) {
|
|
@@ -3208,6 +3392,20 @@ function getInstantPanchang(date, location, options) {
|
|
|
3208
3392
|
location
|
|
3209
3393
|
);
|
|
3210
3394
|
const vara = computeVara(date, sunriseUtc, getTranslations(lang).varaNames);
|
|
3395
|
+
const chandramasa = computeChandraMasa(
|
|
3396
|
+
siderealSun,
|
|
3397
|
+
siderealMoon,
|
|
3398
|
+
(idx, isAdhika) => resolveChandraMasaName(idx, lang, isAdhika)
|
|
3399
|
+
);
|
|
3400
|
+
const samvat = computeSamvat(date);
|
|
3401
|
+
const chandraRashi = computeChandraRashi(
|
|
3402
|
+
siderealMoon,
|
|
3403
|
+
(idx) => resolveMasaName(idx, lang)
|
|
3404
|
+
);
|
|
3405
|
+
const suryaNakshatra = computeSuryaNakshatra(
|
|
3406
|
+
siderealSun,
|
|
3407
|
+
(idx) => resolveNakshatraName(idx, lang)
|
|
3408
|
+
);
|
|
3211
3409
|
if (doEndTimes) {
|
|
3212
3410
|
tithi.endTime = findTransitionTime(
|
|
3213
3411
|
date,
|
|
@@ -3248,7 +3446,12 @@ function getInstantPanchang(date, location, options) {
|
|
|
3248
3446
|
vara,
|
|
3249
3447
|
ayanamsa: ayanamsaValue,
|
|
3250
3448
|
siderealSun,
|
|
3251
|
-
siderealMoon
|
|
3449
|
+
siderealMoon,
|
|
3450
|
+
chandramasa,
|
|
3451
|
+
samvat,
|
|
3452
|
+
chandraRashi,
|
|
3453
|
+
suryaNakshatra,
|
|
3454
|
+
panchaka: computePanchaka(siderealMoon)
|
|
3252
3455
|
};
|
|
3253
3456
|
}
|
|
3254
3457
|
function getDailyPanchang(date, location, options) {
|
|
@@ -3290,6 +3493,38 @@ function getDailyPanchang(date, location, options) {
|
|
|
3290
3493
|
);
|
|
3291
3494
|
const vara = computeVara(sunriseUtc, sunriseUtc, getTranslations(lang).varaNames);
|
|
3292
3495
|
const masa = computeMasa(siderealSunAtSunrise);
|
|
3496
|
+
const chandramasa = computeChandraMasa(
|
|
3497
|
+
siderealSunAtSunrise,
|
|
3498
|
+
siderealMoonAtSunrise,
|
|
3499
|
+
(idx, isAdhika) => resolveChandraMasaName(idx, lang, isAdhika)
|
|
3500
|
+
);
|
|
3501
|
+
const samvat = computeSamvat(sunriseUtc);
|
|
3502
|
+
const chandraRashi = computeChandraRashi(
|
|
3503
|
+
siderealMoonAtSunrise,
|
|
3504
|
+
(idx) => resolveMasaName(idx, lang)
|
|
3505
|
+
);
|
|
3506
|
+
const suryaNakshatra = computeSuryaNakshatra(
|
|
3507
|
+
siderealSunAtSunrise,
|
|
3508
|
+
(idx) => resolveNakshatraName(idx, lang)
|
|
3509
|
+
);
|
|
3510
|
+
const brahmaMuhurta = computeBrahmaMuhurta(sunriseUtc, sunsetUtc);
|
|
3511
|
+
const choghadiya = computeChoghadiya(
|
|
3512
|
+
sunriseUtc,
|
|
3513
|
+
sunsetUtc,
|
|
3514
|
+
nextSunriseUtc,
|
|
3515
|
+
vara.index,
|
|
3516
|
+
(idx) => getTranslations(lang).choghadiyaNames[idx]
|
|
3517
|
+
);
|
|
3518
|
+
const hora = computeHora(
|
|
3519
|
+
sunriseUtc,
|
|
3520
|
+
sunsetUtc,
|
|
3521
|
+
nextSunriseUtc,
|
|
3522
|
+
vara.index,
|
|
3523
|
+
(idx) => getTranslations(lang).grahaNames[idx]
|
|
3524
|
+
);
|
|
3525
|
+
const moonriseUtc = getMoonrise(localMidnightUtc, location);
|
|
3526
|
+
const moonsetUtc = getMoonset(localMidnightUtc, location);
|
|
3527
|
+
const panchaka = computePanchaka(siderealMoonAtSunrise);
|
|
3293
3528
|
let tithis;
|
|
3294
3529
|
let nakshatras;
|
|
3295
3530
|
let yogas;
|
|
@@ -3406,7 +3641,23 @@ function getDailyPanchang(date, location, options) {
|
|
|
3406
3641
|
ayanamsa: ayanamsaValue,
|
|
3407
3642
|
siderealSunAtSunrise,
|
|
3408
3643
|
siderealMoonAtSunrise,
|
|
3409
|
-
masa
|
|
3644
|
+
masa,
|
|
3645
|
+
chandramasa,
|
|
3646
|
+
samvat,
|
|
3647
|
+
chandraRashi,
|
|
3648
|
+
suryaNakshatra,
|
|
3649
|
+
brahmaMuhurta: convertTimePeriod(brahmaMuhurta),
|
|
3650
|
+
choghadiya: {
|
|
3651
|
+
day: choghadiya.day.map((s) => ({ ...s, ...convertTimePeriod(s) })),
|
|
3652
|
+
night: choghadiya.night.map((s) => ({ ...s, ...convertTimePeriod(s) }))
|
|
3653
|
+
},
|
|
3654
|
+
hora: {
|
|
3655
|
+
day: hora.day.map((s) => ({ ...s, ...convertTimePeriod(s) })),
|
|
3656
|
+
night: hora.night.map((s) => ({ ...s, ...convertTimePeriod(s) }))
|
|
3657
|
+
},
|
|
3658
|
+
moonrise: moonriseUtc ? toLocal(moonriseUtc) : null,
|
|
3659
|
+
moonset: moonsetUtc ? toLocal(moonsetUtc) : null,
|
|
3660
|
+
panchaka
|
|
3410
3661
|
};
|
|
3411
3662
|
}
|
|
3412
3663
|
/*! Bundled license information:
|
|
@@ -3447,4 +3698,4 @@ astronomy-engine/esm/astronomy.js:
|
|
|
3447
3698
|
*)
|
|
3448
3699
|
*/
|
|
3449
3700
|
|
|
3450
|
-
export { PanchangError, computeAbhijitMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
|
3701
|
+
export { PanchangError, computeAbhijitMuhurta, computeBrahmaMuhurta, computeGulikaKalam, computeRahuKalam, computeYamaganda, computeAyanamsa as getAyanamsa, getDailyPanchang, getInstantPanchang, getMoonrise, getMoonset, getSiderealMoonLongitude, getSiderealSunLongitude, computeSunrise as getSunrise, computeSunset as getSunset };
|
package/package.json
CHANGED