panchang-ts 2.0.0 → 2.0.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/dist/index.cjs CHANGED
@@ -3935,13 +3935,14 @@ function computeFestivals(ctx, nameResolver, rashiNameResolver) {
3935
3935
  (adhikaBehaviour !== "shift-to-nija" || !ctx.isAdhika);
3936
3936
  if (masaMatches) {
3937
3937
  const dateRule = rule.dateRule ?? "sunrise";
3938
- const effectiveTithi = tithiForRule(dateRule);
3939
- if (effectiveTithi === rule.tithi) {
3940
- const startTithi = tithiForRuleStart(dateRule);
3941
- const priorEndTithi = priorDayTithiForRule(dateRule);
3942
- if (dateRule !== "sunrise" && startTithi !== void 0 && startTithi !== rule.tithi && priorEndTithi === rule.tithi) {
3943
- continue;
3944
- }
3938
+ const endTithi = tithiForRule(dateRule);
3939
+ const startTithi = tithiForRuleStart(dateRule);
3940
+ const priorEndTithi = priorDayTithiForRule(dateRule);
3941
+ const matchedByEnd = endTithi === rule.tithi;
3942
+ const matchedByStart = dateRule !== "sunrise" && startTithi !== void 0 && startTithi === rule.tithi && endTithi !== rule.tithi;
3943
+ if (matchedByEnd || matchedByStart) {
3944
+ if (dateRule !== "sunrise" && startTithi !== void 0 && startTithi !== rule.tithi && priorEndTithi === rule.tithi) continue;
3945
+ if (matchedByStart && priorEndTithi === rule.tithi) continue;
3945
3946
  match = true;
3946
3947
  }
3947
3948
  }
@@ -4001,26 +4002,32 @@ function computeFestivals(ctx, nameResolver, rashiNameResolver) {
4001
4002
  if (tithiForRule("chandrodaya") === 18) {
4002
4003
  results.push({ name: nameResolver("sankashti_chaturthi"), type: "major" });
4003
4004
  }
4004
- const nishitaTithi = tithiForRule("nishita");
4005
- if (nishitaTithi === 28) {
4006
- const isMahaShivaratriMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 10;
4007
- if (!isMahaShivaratriMonth) {
4008
- const startTithi = ctx.tithiByRuleStart?.nishita;
4009
- const priorEndTithi = ctx.priorDayTithiByRule?.nishita;
4010
- const suppressed = startTithi !== void 0 && startTithi !== 28 && priorEndTithi === 28;
4011
- if (!suppressed) {
4005
+ {
4006
+ const endTithi = tithiForRule("nishita");
4007
+ const startTithi = ctx.tithiByRuleStart?.nishita;
4008
+ const priorEndTithi = ctx.priorDayTithiByRule?.nishita;
4009
+ const matchedByEnd = endTithi === 28;
4010
+ const matchedByStart = startTithi !== void 0 && startTithi === 28 && endTithi !== 28;
4011
+ if (matchedByEnd || matchedByStart) {
4012
+ const isMahaShivaratriMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 10;
4013
+ const dedupeA = startTithi !== void 0 && startTithi !== 28 && priorEndTithi === 28;
4014
+ const dedupeB = matchedByStart && priorEndTithi === 28;
4015
+ if (!isMahaShivaratriMonth && !dedupeA && !dedupeB) {
4012
4016
  results.push({ name: nameResolver("masik_shivaratri"), type: "minor" });
4013
4017
  }
4014
4018
  }
4015
4019
  }
4016
- const madhyahnaTithi = tithiForRule("madhyahna");
4017
- if (madhyahnaTithi === 3) {
4018
- const isGaneshChaturthiMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 5;
4019
- if (!isGaneshChaturthiMonth) {
4020
- const startTithi = ctx.tithiByRuleStart?.madhyahna;
4021
- const priorEndTithi = ctx.priorDayTithiByRule?.madhyahna;
4022
- const suppressed = startTithi !== void 0 && startTithi !== 3 && priorEndTithi === 3;
4023
- if (!suppressed) {
4020
+ {
4021
+ const endTithi = tithiForRule("madhyahna");
4022
+ const startTithi = ctx.tithiByRuleStart?.madhyahna;
4023
+ const priorEndTithi = ctx.priorDayTithiByRule?.madhyahna;
4024
+ const matchedByEnd = endTithi === 3;
4025
+ const matchedByStart = startTithi !== void 0 && startTithi === 3 && endTithi !== 3;
4026
+ if (matchedByEnd || matchedByStart) {
4027
+ const isGaneshChaturthiMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 5;
4028
+ const dedupeA = startTithi !== void 0 && startTithi !== 3 && priorEndTithi === 3;
4029
+ const dedupeB = matchedByStart && priorEndTithi === 3;
4030
+ if (!isGaneshChaturthiMonth && !dedupeA && !dedupeB) {
4024
4031
  results.push({ name: nameResolver("vinayaka_chaturthi"), type: "minor" });
4025
4032
  }
4026
4033
  }
package/dist/index.js CHANGED
@@ -3933,13 +3933,14 @@ function computeFestivals(ctx, nameResolver, rashiNameResolver) {
3933
3933
  (adhikaBehaviour !== "shift-to-nija" || !ctx.isAdhika);
3934
3934
  if (masaMatches) {
3935
3935
  const dateRule = rule.dateRule ?? "sunrise";
3936
- const effectiveTithi = tithiForRule(dateRule);
3937
- if (effectiveTithi === rule.tithi) {
3938
- const startTithi = tithiForRuleStart(dateRule);
3939
- const priorEndTithi = priorDayTithiForRule(dateRule);
3940
- if (dateRule !== "sunrise" && startTithi !== void 0 && startTithi !== rule.tithi && priorEndTithi === rule.tithi) {
3941
- continue;
3942
- }
3936
+ const endTithi = tithiForRule(dateRule);
3937
+ const startTithi = tithiForRuleStart(dateRule);
3938
+ const priorEndTithi = priorDayTithiForRule(dateRule);
3939
+ const matchedByEnd = endTithi === rule.tithi;
3940
+ const matchedByStart = dateRule !== "sunrise" && startTithi !== void 0 && startTithi === rule.tithi && endTithi !== rule.tithi;
3941
+ if (matchedByEnd || matchedByStart) {
3942
+ if (dateRule !== "sunrise" && startTithi !== void 0 && startTithi !== rule.tithi && priorEndTithi === rule.tithi) continue;
3943
+ if (matchedByStart && priorEndTithi === rule.tithi) continue;
3943
3944
  match = true;
3944
3945
  }
3945
3946
  }
@@ -3999,26 +4000,32 @@ function computeFestivals(ctx, nameResolver, rashiNameResolver) {
3999
4000
  if (tithiForRule("chandrodaya") === 18) {
4000
4001
  results.push({ name: nameResolver("sankashti_chaturthi"), type: "major" });
4001
4002
  }
4002
- const nishitaTithi = tithiForRule("nishita");
4003
- if (nishitaTithi === 28) {
4004
- const isMahaShivaratriMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 10;
4005
- if (!isMahaShivaratriMonth) {
4006
- const startTithi = ctx.tithiByRuleStart?.nishita;
4007
- const priorEndTithi = ctx.priorDayTithiByRule?.nishita;
4008
- const suppressed = startTithi !== void 0 && startTithi !== 28 && priorEndTithi === 28;
4009
- if (!suppressed) {
4003
+ {
4004
+ const endTithi = tithiForRule("nishita");
4005
+ const startTithi = ctx.tithiByRuleStart?.nishita;
4006
+ const priorEndTithi = ctx.priorDayTithiByRule?.nishita;
4007
+ const matchedByEnd = endTithi === 28;
4008
+ const matchedByStart = startTithi !== void 0 && startTithi === 28 && endTithi !== 28;
4009
+ if (matchedByEnd || matchedByStart) {
4010
+ const isMahaShivaratriMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 10;
4011
+ const dedupeA = startTithi !== void 0 && startTithi !== 28 && priorEndTithi === 28;
4012
+ const dedupeB = matchedByStart && priorEndTithi === 28;
4013
+ if (!isMahaShivaratriMonth && !dedupeA && !dedupeB) {
4010
4014
  results.push({ name: nameResolver("masik_shivaratri"), type: "minor" });
4011
4015
  }
4012
4016
  }
4013
4017
  }
4014
- const madhyahnaTithi = tithiForRule("madhyahna");
4015
- if (madhyahnaTithi === 3) {
4016
- const isGaneshChaturthiMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 5;
4017
- if (!isGaneshChaturthiMonth) {
4018
- const startTithi = ctx.tithiByRuleStart?.madhyahna;
4019
- const priorEndTithi = ctx.priorDayTithiByRule?.madhyahna;
4020
- const suppressed = startTithi !== void 0 && startTithi !== 3 && priorEndTithi === 3;
4021
- if (!suppressed) {
4018
+ {
4019
+ const endTithi = tithiForRule("madhyahna");
4020
+ const startTithi = ctx.tithiByRuleStart?.madhyahna;
4021
+ const priorEndTithi = ctx.priorDayTithiByRule?.madhyahna;
4022
+ const matchedByEnd = endTithi === 3;
4023
+ const matchedByStart = startTithi !== void 0 && startTithi === 3 && endTithi !== 3;
4024
+ if (matchedByEnd || matchedByStart) {
4025
+ const isGaneshChaturthiMonth = !ctx.isAdhika && ctx.chandraMasaIndex === 5;
4026
+ const dedupeA = startTithi !== void 0 && startTithi !== 3 && priorEndTithi === 3;
4027
+ const dedupeB = matchedByStart && priorEndTithi === 3;
4028
+ if (!isGaneshChaturthiMonth && !dedupeA && !dedupeB) {
4022
4029
  results.push({ name: nameResolver("vinayaka_chaturthi"), type: "minor" });
4023
4030
  }
4024
4031
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "panchang-ts",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "description": "Pure TypeScript Hindu Panchang calculations. Tithi, Nakshatra, Yoga, Karana, Vara, and more. Offline-first, React Native compatible.",
5
5
  "author": "Ishank",
6
6
  "license": "MIT",