panchang-ts 3.0.1 → 3.1.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 CHANGED
@@ -5,7 +5,7 @@
5
5
  Pure TypeScript Hindu Panchang (almanac), Jyotish, and Birth Chart calculations.
6
6
  Zero native dependencies. Works offline in React Native (Hermes), Node.js, and browsers.
7
7
 
8
- **Fast** (~0.1 ms names-only, ~0.5 ms full) | **Typed** (full TypeScript types) | **Offline** (pure JS math, no network) | **6,912 tests**
8
+ **Fast** (~0.1 ms names-only, ~0.5 ms full) | **Typed** (full TypeScript types) | **Offline** (pure JS math, no network) | **7,156 tests**
9
9
 
10
10
  ---
11
11
 
@@ -41,10 +41,14 @@ sources, and exposed through the public API. Click a row to jump to its usage ex
41
41
  | **Planetary Positions** | All 9 grahas (sidereal) with rashi, nakshatra, pada, retrograde — mean or true Rahu/Ketu | [↓](#11-planetary-positions) |
42
42
  | **Vimshottari Dasha** | Maha → Antar → Pratyantar (3-level) breakdown from birth | [↓](#12-vimshottari-dasha) |
43
43
  | **Personal Transits** | Chandra Balam, Tarabala (9-tara cycle), Sade Sati (Saturn arc) | [↓](#13-personal-transits) |
44
- | **Birth Chart (Kundli)** | Lagna (sidereal), Bhava under 3 house systems, D1 (Rashi), D9 (Navamsa), Planetary Dignity | [↓](#14-birth-chart-kundli) |
45
- | **Compatibility & Doshas** | Ashtakoot Guna Milan (36-point), Mangal Dosha (Manglik) | [↓](#15-compatibility--doshas) |
46
- | **Localization** | English + Hindi (Devanagari) on every returned name | [↓](#16-localization) |
47
- | **Configuration** | 5 ayanamsas (Lahiri, Raman, KP, True Chitrapaksha, Thirukanitham), 2 masa systems, 3 house systems, 21 regional festival scopes | [↓](#17-configuration) |
44
+ | **Birth Chart (Kundli)** | Lagna (sidereal), Bhava under 3 house systems, D1 / D2 / D3 / D7 / D9 / D10 / D12 / D30 charts, Planetary Dignity | [↓](#14-birth-chart-kundli) |
45
+ | **Compatibility & Doshas** | Ashtakoot Guna Milan (36-point), Mangal Dosha, Kaal Sarp Dosha (12 subtypes), Pitru Dosha | [↓](#15-compatibility--doshas) |
46
+ | **Aspects & Strength** | Drishti (graha aspects), Shadbala (six-fold strength) | [↓](#16-aspects--strength) |
47
+ | **Dasha Systems** | Vimshottari (Maha→Antar→Pratyantar), Ashtottari, Yogini, Chara (Jaimini) | [↓](#17-dasha-systems) |
48
+ | **Muhurta Engine** | Configurable scoring + 13 stock occasions (vivah, griha pravesh, namakarana, …) | [↓](#18-muhurta-engine) |
49
+ | **Calendar Conversion** | Gregorian↔Hindu, Kali Yuga year, Hindu New Year, yearly Ekadashi / Sankranti / festival listings | [↓](#19-calendar-conversion) |
50
+ | **Localization** | English + Hindi (Devanagari) on every returned name | [↓](#20-localization) |
51
+ | **Configuration** | 5 ayanamsas (Lahiri, Raman, KP, True Chitrapaksha, Thirukanitham), 2 masa systems, 3 house systems, 21 regional festival scopes | [↓](#21-configuration) |
48
52
 
49
53
  ---
50
54
 
@@ -471,13 +475,15 @@ const sadeSati = computeSadeSati(natalMoonRashiIndex, new Date());
471
475
 
472
476
  ## 14. Birth Chart (Kundli)
473
477
 
474
- Sidereal **Lagna**, **Bhava** under three house systems, **D1 (Rashi)** and **D9
475
- (Navamsa)** charts placing all 9 grahas, and **Planetary Dignity**.
478
+ Sidereal **Lagna**, **Bhava** under three house systems, **D1 (Rashi)** + six classical
479
+ divisional charts (**D2 Hora**, **D3 Drekkana**, **D7 Saptamsa**, **D9 Navamsa**, **D10
480
+ Dasamsa**, **D12 Dwadasamsa**, **D30 Trimsamsa**) placing all 9 grahas, and **Planetary
481
+ Dignity**.
476
482
 
477
483
  ```typescript
478
484
  import {
479
485
  computeLagna, computeBhava, computeRashiChart, computeNavamsa,
480
- computeDignity,
486
+ computeDivisionalChart, computeDignity,
481
487
  } from 'panchang-ts';
482
488
 
483
489
  const birth = new Date('1995-08-15T05:30:00Z');
@@ -501,23 +507,38 @@ d1.planets.find(p => p.planet === 'Saturn')?.isRetrograde;
501
507
  // 4. D9 (Navamsa) chart — classical sign-based per-rashi-type rule
502
508
  const d9 = computeNavamsa(birth, loc);
503
509
 
504
- // 5. Planetary dignity (BPHS Ch.3-4)
510
+ // 5. Divisional charts (D2/D3/D7/D10/D12/D30) via the unified API
511
+ const d10 = computeDivisionalChart(birth, loc, 'D10'); // career
512
+ const d30 = computeDivisionalChart(birth, loc, 'D30'); // misfortune
513
+ // → { divisional: 'D10', lagnaRashi, planets[] }
514
+
515
+ // 6. Planetary dignity (BPHS Ch.3-4)
505
516
  computeDignity('Mars', 0); // 'moolatrikona' (Aries)
506
517
  computeDignity('Mars', 9); // 'exalted' (Capricorn)
507
518
  computeDignity('Sun', 6); // 'debilitated' (Libra)
508
519
  ```
509
520
 
521
+ The seven divisional kinds are: **D2 Hora** (wealth), **D3 Drekkana** (siblings),
522
+ **D7 Saptamsa** (children), **D9 Navamsa** (partner / dharma), **D10 Dasamsa** (career),
523
+ **D12 Dwadasamsa** (parents), **D30 Trimsamsa** (misfortune). Each follows its classical
524
+ per-rashi-type mapping per BPHS Ch. 6; D30 uses the non-uniform 5-segment split with
525
+ Mars / Saturn / Jupiter / Mercury / Venus rulership (no Sun / Moon segments).
526
+
510
527
  Birth-chart helpers accept the full ayanamsa set including `'true-chitra'` (True
511
528
  Chitrapaksha) and `'thirukanitham'` (Tamil-Vakya). Pass via `options.ayanamsa` or the
512
529
  ayanamsa positional arg.
513
530
 
514
531
  ## 15. Compatibility & Doshas
515
532
 
516
- **Ashtakoot Guna Milan** (36-point marriage compatibility) and **Mangal Dosha** (Manglik
517
- affliction with cancellations).
533
+ **Ashtakoot Guna Milan** (36-point marriage compatibility), **Mangal Dosha** (Manglik
534
+ with cancellations), **Kaal Sarp Dosha** (12 named subtypes by Rahu's house), and
535
+ **Pitru Dosha** (ancestral affliction triggers).
518
536
 
519
537
  ```typescript
520
- import { computeAshtakoot, computeMangalDosha } from 'panchang-ts';
538
+ import {
539
+ computeAshtakoot, computeMangalDosha,
540
+ computeKaalSarp, computePitruDosha,
541
+ } from 'panchang-ts';
521
542
 
522
543
  // Ashtakoot — from natal Moons
523
544
  const match = computeAshtakoot(
@@ -531,14 +552,181 @@ const match = computeAshtakoot(
531
552
  // Mangal Dosha — checks Mars from lagna, Moon, and Venus
532
553
  const mangal = computeMangalDosha(d1);
533
554
  // → { afflicted, fromLagna, fromMoon, fromVenus, cancellations }
555
+
556
+ // Kaal Sarp Dosha — all 7 visible planets between Rahu and Ketu axis
557
+ const ksd = computeKaalSarp(d1);
558
+ // → { afflicted, subtype, partial, rahuHouse, ketuHouse }
559
+ // subtype is one of: anant, kulik, vasuki, shankhpal, padma, mahapadma,
560
+ // takshak, karkotak, shankhachud, ghatak, vishdhar, sheshnag — by Rahu's house.
561
+
562
+ // Pitru Dosha — Sun + Rahu/Ketu in same house, OR Sun + Saturn in 9th
563
+ const pitru = computePitruDosha(d1);
564
+ // → { afflicted, reasons: string[] }
534
565
  ```
535
566
 
536
567
  **Documented limitations** — Mangal Dosha cancellations only cover Mars in own sign
537
568
  (Aries / Scorpio) or exalted (Capricorn); other classical cancellations (mutual Mangalik,
538
569
  Mars-Jupiter aspect, Mars-Saturn conjunction) are not applied. Ashtakoot Vashya koot is
539
- simplified to single-vashya per rashi.
570
+ simplified to single-vashya per rashi. Pitru Dosha surfaces the two highest-frequency
571
+ classical triggers (Sun + node, Sun + Saturn in 9th); the full BPHS catalog of triggers
572
+ (debilitated 9th lord, 9th lord in dusthana, etc.) is out of scope.
573
+
574
+ ## 16. Aspects & Strength
575
+
576
+ **Drishti** (planetary aspects per BPHS Ch. 26) and **Shadbala** (six-fold strength per
577
+ BPHS Ch. 27).
578
+
579
+ ```typescript
580
+ import { computeAspects, computeShadbala } from 'panchang-ts';
581
+
582
+ // Aspects — every graha aspects the 7th house from itself; malefics gain
583
+ // extra special aspects (Mars 4 + 8, Jupiter 5 + 9, Saturn 3 + 10).
584
+ const aspects = computeAspects(d1);
585
+ // → { Sun: [houses…], Moon: [...], …, Saturn: [...], Rahu: [...], Ketu: [...] }
586
+ //
587
+ // Default treats Rahu/Ketu with the 7th-only BPHS-literal rule. Pass
588
+ // { nodeAspects: '5-and-9' } to extend nodes with Jupiter-like 5/9 aspects
589
+ // (BV Raman / KP convention).
590
+
591
+ // Shadbala — 7 visible grahas, 6 components per planet, in Virupas (60 V = 1 Rupa).
592
+ const bala = computeShadbala(birth, loc);
593
+ // → { Sun: { sthana, dig, kala, chesta, naisargika, drik, total }, Moon: …, … }
594
+ //
595
+ // Components implemented at the simplified-model level used by ProKerala /
596
+ // PyJHora — Uchcha-only Sthana, Dig from directional cusp, Nathonatha + Paksha
597
+ // for Kala, retrograde-bucket Chesta, fixed Naisargika rank, weighted Drik.
598
+ ```
599
+
600
+ Both functions return additive surface — they do **not** modify the
601
+ `getDailyPanchang` / birth-chart pipelines. Call them on demand.
602
+
603
+ ## 17. Dasha Systems
604
+
605
+ Four classical dasha systems are exposed:
606
+
607
+ ```typescript
608
+ import {
609
+ computeVimshottariDashaFromBirth, computeVimshottariPratyantar,
610
+ computeAshtottariDasha, computeYoginiDasha, computeCharaDasha,
611
+ } from 'panchang-ts';
612
+
613
+ const birth = new Date('1995-08-15T05:30:00Z');
614
+ const loc = { latitude: 28.6139, longitude: 77.2090 };
615
+
616
+ // 1. Vimshottari (120-year, 9-lord) — already in v1; pratyantar (3-level) added in v3
617
+ const vim = computeVimshottariDashaFromBirth(birth);
618
+ const pratyantars = computeVimshottariPratyantar(vim.mahaDashas[0].antarDashas[0]);
619
+
620
+ // 2. Ashtottari (108-year, 8-lord, no Ketu) — used when Moon in Krishna Paksha
621
+ const moonLon = /* sidereal Moon longitude */ 145.7;
622
+ const ash = computeAshtottariDasha(birth, moonLon);
623
+ // → mahaDashas[0..7], lord cycle Sun(6)→Moon(15)→Mars(8)→Mercury(17)→
624
+ // Saturn(10)→Jupiter(19)→Rahu(12)→Venus(21)
625
+
626
+ // 3. Yogini (36-year, 8 yoginis with planetary lords)
627
+ const yog = computeYoginiDasha(birth, moonLon);
628
+ yog.mahaDashas[0].yogini; // 'Dhanya' (Magha → nakshatra 10, 10 % 8 = 2)
629
+ yog.mahaDashas[0].lord; // 'Jupiter' (Dhanya's planet)
630
+
631
+ // 4. Chara (Jaimini, sign-based, 9-8-7 years per modality)
632
+ const cha = computeCharaDasha(birth, loc);
633
+ cha.mahaDashas[0].rashi; // lagna's rashi
634
+ cha.mahaDashas[0].lord; // sign-lord planet
635
+ cha.mahaDashas[0].years; // 9 (movable) | 8 (fixed) | 7 (dual)
636
+ ```
637
+
638
+ **Sourcing:** Vimshottari per Parashara (BPHS Ch. 51); Ashtottari per Satya Acharya;
639
+ Yogini per Sanjay Rath (1999) / Charak; Chara per Jaimini Sutras Ch. 1 (9-8-7 years
640
+ variant). Documented limitations: Chara uses the forward zodiacal direction
641
+ unconditionally (Sundar / Achyutananda variant); the reverse-direction rule for
642
+ even-rashi lagnas is not currently exposed.
643
+
644
+ ## 18. Muhurta Engine
645
+
646
+ A configurable rule + scoring engine for picking auspicious dates. Ships with **13 stock
647
+ rules** (vivah, griha pravesh, namakarana, vidyarambh, vahan kharidi, annaprashan,
648
+ mundan, upanayanam, karnavedha, aksharabhyasam, seemantham, shop opening, travel
649
+ start). Each rule is a pure data declaration — write your own without touching the
650
+ engine.
651
+
652
+ ```typescript
653
+ import { scoreMuhurta, findAuspiciousDates, vivahRule } from 'panchang-ts';
654
+
655
+ // Score a single date
656
+ const r = scoreMuhurta(new Date('2026-05-12'), DELHI, vivahRule, { timezone: 330 });
657
+ // → { date, score: 0..100, passes: boolean, reasons: string[] }
658
+
659
+ // Find all auspicious dates in a range, sorted by score descending
660
+ const dates = findAuspiciousDates(
661
+ vivahRule,
662
+ new Date('2026-05-01'),
663
+ new Date('2026-05-31'),
664
+ DELHI,
665
+ { timezone: 330 },
666
+ );
667
+ // → MuhurtaDay[] with full panchang attached for each result
668
+
669
+ // Custom rule
670
+ const myRule: MuhurtaRule = {
671
+ occasion: 'launch_party',
672
+ auspiciousVaras: [3, 4, 5], // Wed/Thu/Fri
673
+ auspiciousNakshatras: [11, 12, 21], // Uttara Phalguni / Hasta / Shravana
674
+ excludeBhadra: true,
675
+ excludeEkadashi: true,
676
+ excludeAdhikaMasa: true,
677
+ };
678
+ ```
679
+
680
+ Scoring model: starts at 50 (neutral), +10 per matching auspicious axis (tithi,
681
+ nakshatra, vara, yoga), -15 per matching inauspicious axis, hard exclusions
682
+ (`excludeBhadra` / `excludeEkadashi` / `excludeEclipse` / `excludeAdhikaMasa` /
683
+ `excludeGandaMula` / `excludePanchaka` / `requirePaksha` mismatch) zero the score.
684
+ Special yogas — Amrit Siddhi, Sarvartha Siddhi, Ravi Pushya, Guru Pushya — add +5;
685
+ Jwalamukhi yoga subtracts -10. Final score clamped to 0..100; `passes: true` when
686
+ score ≥ 50.
687
+
688
+ ## 19. Calendar Conversion
689
+
690
+ Gregorian↔Hindu lunar coordinates, Kali Yuga year, regional Hindu New Year, and
691
+ yearly listings of Ekadashis / Sankrantis / festivals / eclipses.
692
+
693
+ ```typescript
694
+ import {
695
+ convertGregorianToHindu, convertHinduToGregorian,
696
+ getKaliYugaYear, getHinduNewYear,
697
+ getEkadashiDatesForYear, getSankrantisForYear,
698
+ getFestivalsInRange, getUpcomingEclipses,
699
+ } from 'panchang-ts';
700
+
701
+ // Gregorian → Hindu coordinates at sunrise
702
+ const h = convertGregorianToHindu(new Date('2026-04-15'), DELHI, { timezone: 330 });
703
+ // → { tithiName, tithi (1..30), pakshaTithi (1..15), paksha,
704
+ // masaName, masaIndex, isAdhika, vikramSamvat, shakaSamvat,
705
+ // varaName, varaIndex }
706
+
707
+ // Hindu → Gregorian: which Gregorian dates correspond to a (samvat, masa, paksha, tithi)?
708
+ const dates = convertHinduToGregorian(
709
+ { vikramSamvat: 2083, masaIndex: 0, paksha: 'shukla', pakshaTithi: 9 },
710
+ DELHI, { timezone: 330 },
711
+ );
712
+ // dates[0] → Rama Navami in VS 2083
713
+
714
+ getKaliYugaYear(new Date('2026-04-01')); // 5127
715
+ getHinduNewYear(2026, 'tamil-nadu', DELHI, { timezone: 330 }); // Puthandu
716
+
717
+ // Yearly listings
718
+ getEkadashiDatesForYear(2026, DELHI, { timezone: 330 }); // ~24 Date[]
719
+ getSankrantisForYear(2026, DELHI, { timezone: 330 }); // 12 SankrantiEvent[]
720
+ getFestivalsInRange(start, end, DELHI, { timezone: 330 }); // FestivalDay[]
721
+ getUpcomingEclipses(new Date(), DELHI, 5); // 5 EclipseInfo[]
722
+ ```
723
+
724
+ `getHinduNewYear` is region-aware: Tamil Nadu / Kerala / Punjab / Bengal / Assam use
725
+ the **solar** (Mesha Sankranti) anchor; everywhere else uses **Chaitra Shukla Pratipada**
726
+ (Ugadi / Gudi Padwa / Cheti Chand). When the Pratipada is a kshaya tithi (e.g. Ugadi
727
+ 2026), the function falls back to the Amanta-Chaitra-masa boundary.
540
728
 
541
- ## 16. Localization
729
+ ## 20. Localization
542
730
 
543
731
  All returned display names respect the `language` option. **English** and **Hindi
544
732
  (Devanagari)** are supported.
@@ -555,7 +743,7 @@ console.log(hi.choghadiya.day[0].name); // "अमृत"
555
743
  console.log(hi.vara.englishName); // "Tuesday"
556
744
  ```
557
745
 
558
- ## 17. Configuration
746
+ ## 21. Configuration
559
747
 
560
748
  ```typescript
561
749
  const r = getDailyPanchang(date, loc, {
@@ -900,9 +1088,23 @@ getUpcomingSolarEclipse, getUpcomingLunarEclipse, getEclipseDuringDay
900
1088
  // Jyotish
901
1089
  computePlanetaryPositions, GRAHA_ABBR
902
1090
  computeVimshottariDasha, computeVimshottariDashaFromBirth, computeVimshottariPratyantar
1091
+ computeAshtottariDasha, computeYoginiDasha, computeCharaDasha
903
1092
  computeChandraBalam, computeTarabala
904
- computeLagna, computeBhava, computeRashiChart, computeNavamsa
905
- computeAshtakoot, computeMangalDosha, computeSadeSati, computeDignity
1093
+ computeLagna, computeBhava, computeRashiChart, computeNavamsa, computeDivisionalChart
1094
+ computeAspects, computeShadbala
1095
+ computeAshtakoot, computeMangalDosha, computeKaalSarp, computePitruDosha
1096
+ computeSadeSati, computeDignity
1097
+
1098
+ // Muhurta engine
1099
+ scoreMuhurta, findAuspiciousDates, STOCK_MUHURTA_RULES
1100
+ vivahRule, grihaPraveshRule, namakaranaRule, vidyarambhRule, vahanKharidiRule
1101
+ annaprashanRule, mundanRule, upanayanamRule, karnavedhaRule
1102
+ aksharabhyasamRule, seemanthamRule, shopOpeningRule, travelStartRule
1103
+
1104
+ // Calendar conversion + yearly listings
1105
+ convertGregorianToHindu, convertHinduToGregorian
1106
+ getKaliYugaYear, getHinduNewYear, computeSamvat
1107
+ getEkadashiDatesForYear, getSankrantisForYear, getFestivalsInRange, getUpcomingEclipses
906
1108
 
907
1109
  // Errors
908
1110
  PanchangError
@@ -940,7 +1142,7 @@ InteractionManager.runAfterInteractions(() => {
940
1142
 
941
1143
  ## Accuracy
942
1144
 
943
- 6,912 tests passing across 74 files, including fixtures cross-verified against reference
1145
+ 7,156 tests passing across 81 files, including fixtures cross-verified against reference
944
1146
  panchang calculations spanning 2025–2026 across 10 Indian cities, plus New York, London,
945
1147
  Sydney, Dubai, and Singapore (diaspora fixtures cover DST transitions on
946
1148
  `America/New_York`).