batoulapps / adhan-js

High precision Islamic prayer time library for JavaScript
MIT License
368 stars 81 forks source link

If all params same, except "method" the values are different. #121

Closed Noitidart closed 1 year ago

Noitidart commented 1 year ago

Amazing library here, would I be able to donate to support it somewhere?

I was hoping to learn something please. With let's say Coordinates of lat: 52.5556 lng: 5.91532 for August 8th using these parameters below give you Isha of 10:22pm. However if you just change "method" to "Other" it changes to 11:59pm. How is this possible? I was allowing my users to create custom params based on an existing preset, so I prefill all the params the same except "method" which I set to "Other", I was expecting it to match.

{
  "method": "MoonsightingCommittee",
  "fajrAngle": 18,
  "ishaAngle": 18,
  "ishaInterval": 0,
  "madhab": "shafi",
  "highLatitudeRule": "middleofthenight",
  "adjustments": {
    "fajr": 0,
    "sunrise": 0,
    "dhuhr": 0,
    "asr": 0,
    "maghrib": 0,
    "isha": 0
  },
  "methodAdjustments": {
    "dhuhr": 5,
    "maghrib": 3
  },
  "polarCircleResolution": "Unresolved"
}
Noitidart commented 1 year ago

Oh found it, it's a special case for some methods - https://github.com/batoulapps/adhan-js/blob/master/src/PrayerTimes.ts#L114

So even when cloning a preset, I should keep the method the same, just give it a different "Label" to indicate it's not the real preset, but a custom params setting.

Would still love to know where to donate to support this project please, I'll close this issue for now.

z3bi commented 1 year ago

This should only be true for "MoonsightingCommittee" which has seasonal adjusted values, although in the future we may need to do other custom calculation based on method name. I would recommend keeping the method name if you're only adjusting things like madhab, highLatitudeRule, adjustments, or polarCircleResolution. If you're modifying the fair or isha angle then its probably best to just make a brand new method with "other".

Also, in this specific case you mentioned you should be setting a highLatitudeRule to ensure that you get a reasonable isha time for such a high latitude.

Noitidart commented 1 year ago

JazakAllahkhair for your reply that's very helpful!

Is it possible to support this project?