Code Monkey home page Code Monkey logo

adhan-js's People

Contributors

abumalick avatar ahmedre avatar b-stud avatar basememara avatar dependabot[bot] avatar insha avatar jd1378 avatar kafiln avatar khawarizmus avatar meltuhamy avatar mmahalwy avatar mmmoussa avatar mzc13 avatar n-eq avatar semantic-release-bot avatar sgtsquiggs avatar thekbn avatar z3bi avatar zapolnoch avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

adhan-js's Issues

Release latest progress

Assalam alykoum

It seems to me that the current version 4.0.1 is behind master branch. for example, the type definitions in the latest release don't include polarCircleResolution. and I noticed that the Quibla feature is not defined in the current type definitions (probably needs a separate issue. let me know and I will open a new one).

How are the releases triggered?

Time Zone using getTimezoneOffset()

Hello
Can't we use getTimezoneOffset() function instead of defining it manually?
I think it will be much useful when it is used on GPS based development.

Thanks.

Prayers Time in Array

Would it be possible for the prayers response to return as an array alongside the names? Something like below

calculationParameters: {...}
fajrAngle: {...}
coordinates: {...}
date: Mon Jul 05 2021 11:35:42 GMT+0800 (Malaysia Time)
prayers: [
{ name: fajr, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
{ name: sunrise, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
{ name: dhuhr, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
{ name: asr, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
{ name: maghrib, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
{ name: isha, time: Mon Jul 05 2021 05:45:00 GMT+0800 (Malaysia Time) },
]

How to display prayer times of one month or later

First of All, Thanks for Great Script may Allah give you best return for your work

If I want to display prayer times of one month can it be possible with this script?
If yes then what will be the method.

Add type definitions for TypeScript

Are there any plans to add type definitions for TypeScript users?
This would be a huge benefit for us. JavaScript programmers that use VSCode would also benefit from better completions.

Prayer Ending Times

My understanding of this may be flawed, so please correct me if so.

Generally, you only have so much time to pray certain prayers (Maghrib being the main one). While this library does feature support for seeing the start of prayer times, I haven't been able to find anything on the ends of prayer times. Is there a way to calculate this?

Using in Angular 10

Really a very great project
But would it be using in Angular 10?
I did't find it on documentations

Altitude Support

Some scholars (one of whom specifically told me this) are very strict and explicitly want to see the sun go down. When on a plane or at very high altitudes, this would result in the sun setting later.

Does this library feature support for altitudes in its calculations? If so, how? If not, are there any plans to add support for this?

Most phones have altimeters today, which would directly aid in this calculation.

Altitude

Does the variation of the altitude from a city to another change the results ?

Add Correction time

Not sure if this is possible, but it would be great to add a new option to allow dev to correct the minute time. Currently I have to do something like this.time.fajr.setMinutes(this.time.fajr.getMinutes() + 10) for each one of the prayers.

Malaysia & Indonesia Prayer Times

Hi there,

I was just curious is there any calculations method for JAKIM? Because I tried using

    const coordinates = new adhan.Coordinates(2.926361, 101.696445);
    const date = new Date();
    const params = adhan.CalculationMethod.UmmAlQura();
    const time = new adhan.PrayerTimes(coordinates, date, params);

But i always get a few minutes earlier/later. Besides that I would also like to know what calculations are used for Malaysia and Indonesia. Thank you

Morocco Calculation method

I have a list of all the cities in Morocco ( with their coordinates and alt ) and the prayer times can fetched using this service https://apisearch.hadithm6.com/api/prieres/ville/{id} where id is also part of the city data.
Can you reverse engineer the calculation method based on this data ?
I didn't find a way to include the altitude in the calculationMethod

Sweden time calculation fails

Salam Alaikum,
I'm processing different tests on this absolutely great project and I'm facing a problem trying to calculate prayer times for Sweden (I guess it will be the same problem for all these northern geographical areas).

It would be awesome to get your input on it.
Below is the smallest snippet to reproduce :

const coordinates = new adhan.Coordinates(66.7222444, 17.7189);
const params = adhan.CalculationMethod.MuslimWorldLeague();
console.log(new adhan.PrayerTimes(coordinates, new Date('2020-06-21 21:55'), params));

The above code will output :

{
     fajr: Invalid Date,
     sunrise: Invalid Date,
     dhuhr: 2020-06-21T10:52:00.000Z,
     asr: 2020-06-21T15:52:00.000Z,
     maghrib: Invalid Date,
     isha: Invalid Date
}

This obviously sounds problematic since several times are Invalid.
You can try this out here : runkit demo
Thanks!

Calculation Method for Morocco

Salamu Alaykom, and Jazakom allahu for this awesome repo.

I'm trying to get the exact times given in the Moroccan Website.

I have tried different method / combination but I did not succeed so for.

Do you, by any chance, know how to do it ? I may open a Pull request to add to the methods if I know the corrects mesures.

Thanks 👍

Bad prayer time in France

Hi,

First thanks you for this awesome project !

Here is my problem, i cant get correct fajr in France

`

  var coordinates = new this.state.adhan.Coordinates(latitude, longitude);
  var params = this.state.adhan.CalculationMethod.Other();
  params.madhab = this.state.adhan.Madhab.Shafi;
  params.fajrAngle = 12
  params.ishaAngle = 12
  params.adjustments.fajr = -5
  params.adjustments.sunrise = 1
  params.adjustments.dhuhr = 5
  params.adjustments.asr=0
  params.adjustments.maghrib = 1
  params.adjustments.isha = 4
  this.state.prayerTimes = new this.state.adhan.PrayerTimes(coordinates, this.props.date, params))`

I use this to create prayerTimes object

but for the 30/06/2021
fajr is at 3:43 instead of 4:02
Thanks .

Shafi Asr Time Invalid

I was just playing around with the library and noticed that the ASR time for Shafi Madhab does not work.

const coordinates = new adhan.Coordinates(153.02789306640625, -27.467580795288086);
const params = adhan.CalculationMethod.MuslimWorldLeague();
params.madhab = adhan.Madhab.Shafi;
const times = new adhan.PrayerTimes(coordinates, new Date(), params);
console.log(times);

return as asr: Invalid Date {}

All other times are fine.

The issue appears to be caused in Adhan.js in correctedHourAngle: function
at line 357 (const H0 = radiansToDegrees(Math.acos(term1 / term2));), which returns a NaN

Just thought you would like to know.
Screen Shot 2020-07-27 at 11 39 52 pm

مساعدة في حساب اوقات الصلاة لدولة الجزائر

السلام عليكم ورحمة الله وبركاته
احاول حساب اوقات الصلاة لولايات الجزائر مثل ولاية ادرار

{
    "city": "Adrar",
    "name": "أدرار",
    "longitude": "27.9763317",
    "latitude": "-0.4841573",
    "timezone": "Africa/Algiers"
}

اتمنى مساعدتي في طريقة حساب اوقات الصلاة
استخدمت

 adhan.CalculationMethod.MuslimWorldLeague()

لاكن التوقيت يأتيني مختلف عن ما أجده في قوقل

const adhan = require('adhan');
const moment = require('moment-timezone');

let dz = {
    "city": "Adrar",
    "name": "أدرار",
    "longitude": "27.9763317",
    "latitude": "-0.4841573",
    "timezone": "Africa/Algiers"
}

let coordinates = new adhan.Coordinates(dz.latitude ,dz.longitude);
let params = adhan.CalculationMethod.MuslimWorldLeague()
let date = new Date();
let prayerTimes = new adhan.PrayerTimes(coordinates, date, params);
let fajr = moment(prayerTimes.fajr).tz(dz.timezone).format('h:mm A');
let sunrise = moment(prayerTimes.sunrise).tz(dz.timezone).format('h:mm A');
let dhuhr = moment(prayerTimes.dhuhr).tz(dz.timezone).format('h:mm A');
let asr = moment(prayerTimes.asr).tz(dz.timezone).format('h:mm A');
let maghrib = moment(prayerTimes.maghrib).tz(dz.timezone).format('h:mm A');
let isha = moment(prayerTimes.isha).tz(dz.timezone).format('h:mm A');


console.log('time now :', moment().tz(dz.timezone).format('h:mm A'));
console.log(`fajr ${fajr}\nsunrise ${sunrise}\ndhuhr ${dhuhr}\nasr ${asr}\nmaghrib ${maghrib}\nisha ${isha}`);

الإخراج

time now : 3:14 PM
fajr 3:59 AM
sunrise 5:12 AM
dhuhr 11:16 AM
asr 2:38 PM
maghrib 5:17 PM
isha 6:26 PM

المتوقع

time now : 3:14 PM
fajr 3:56 AM
sunrise 5:49 AM
dhuhr 12:54 AM
asr 4:44 PM
maghrib 7:59 PM
isha 9:38 PM

لقطة الشاشة_2022-07-27_15-34-23

Incorrect Isha timing in Milton Canada

Isha timing from adhan.js is different from that from moonsighting.com when selecting the moonsighting.com method. From the site Isha is at 17:59 for Milton (43.494,-79.844) compared to 18:18 from adhan.js. All other timings match exactly.

About Time Adjustments

What unit should I use for adjustments? Currently, I am using -0.5 to adjust the time to -1 minute. Is this correct?

image

Installation

How would instalation be done on this? just download and put in files?

Misalignment between arguments order in types file and implementation file

Salam Alaykum, I noticed a problem with the order of the arguments in the types file, I take profit from the fact we're releasing another version soon to add the Rounding: Rounding export to expose this little issue.

Adhan.d.ts

constructor(fajrAngle: number, ishaAngle: number, methodName?: string, ishaInterval?: number, maghribAngle?: number)

Adhan.js

constructor(methodName, fajrAngle, ishaAngle, ishaInterval, maghribAngle)

This leads to invalid suggestions being shown in IDEs :
image

Little différence between Node js and Browser in calculation

Hi,

I used this library to calculate prayer times in a browser and also in a function runing in a Node js server. I used npm to get the library and the functions was tested with Firebase function and also with Netlify functions.

The parameters used are:

  • Coordinates: [45.5049, -73.7142]
  • CalculationMethod: NorthAmerica
  • Madhab = adhan.Madhab.Shafi

The calculated times from a JavaScript code in a browser are:

  • fajr: 04:23
  • sunrise: 05:54
  • dhuhr: 12:54
  • asr: 16:46
  • maghrib: 19:52
  • isha: 21:25

The calculated times from the two functions runing on a Node js server are :

  • fajr: 04:21
  • sunrise: 05:53
  • dhuhr: 12:54
  • asr: 16:47
  • maghrib: 19:54
  • isha: 21:27

Why we have those +/- 2 minutes differences from the two sources even if the code is the same?

Thanks.

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

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"
}

Suggestions

I have two suggestion. One is instead if including the normal date maybe also provide the Hijri calendar. Secondly is to add the time for next prayer. Currently when using the next prayers function it only provides the type of prayers which is like 'asr' instead you could do something like { name: asr, time: 1:04PM }

prayer times are not accurate

There's difference of minutes in the prayer times I get using your library and other apps like Muslim Pro, Prayer times

JAKIM Prayers Time

Just a question, would it be possible if I send you the source code of the api i used for JAKIM? I used to use an api to get the accurate prayers time but its slow so thats why I switch to this library. If it would be helpful to integrate JAKIM method do let me know as I would send the source code on GitHub

timeforsalah.com [A website made with this library]

Git Repo : [ https://github.com/AbdulMalikDev/TimeForSalahWebsite ]

I have built a website with this library and it is open source. It has an estimated of 300+ users and i am not able to find the time to maintain it. If there is anyone interested to improve the website please submit a pull request. The aim of creating such a website is to provide muslims with an AD-FREE experience when trying to look up prayer timings.

Jazakallah khair.

Feature Suggestion: Add Next Day Parameter

It would be great if theres a next day parameter because if i use var nextPrayerTime = this.time.timeForPrayer(next); and the last prayers time is shown it will return as undefined. Would be great if it shows the next day time.

CalculationParameters type improvment

Assalam alykoum

Shouldn't the following constructor signature in the type definitions that is found here use optional arguments?

Basically changing this:

constructor(methodName: string|undefined|null, fajrAngle: number, ishaAngle: number, ishaInterval: number, maghribAngle: number)

To this:

constructor(methodName?: string, fajrAngle: number, ishaAngle: number, ishaInterval?: number, maghribAngle?: number)

Currently, all arguments are required except for methodName that is implied from undefined and null type that was added. but looking at the code only fajrAngle and ishaAngle seem required to me.

Also for library authors who use this library as a base (for example allow users to use a custom method). it would be useful to expose all params.

Currently methodAdjustments, maghribAngle, and polarCircleResolution are missing from the type definitions making the library throw an error when for example trying to assign custom method adjustments or any one of the three params mentioned above.

public initWithCustomMethod(config: PrayersCustomConfig) {
    this.config = config
    const { date, latitude, longitude, dateFormatter, ...paramsOptions } = this.config as PrayersCustomConfig;
    const calculationParams = new CalculationParameters(paramsOptions.fajrAngle || 18, paramsOptions.ishaAngle || 18, paramsOptions.ishaInterval || 0, 'Other');
    calculationParams.methodAdjustments = paramsOptions.methodAdjustments // this throws an error
    calculationParams.adjustments = paramsOptions.adjustments;
// ...
  }

This small change would bring better type checking and intelisence as well as prevent few type errors. and I can help PR the changes.

Rounding Behaviour

Hi may i know how to implement this rounding behaviour? Because i get an error saying its undefined

Cannot read property 'Nearest' of undefined
TypeError: Cannot read property 'Nearest' of undefined

Here's my implementation

 const coordinates = new adhan.Coordinates(res.coords.latitude, res.coords.longitude);
 const date = new Date();
 const params = adhan.CalculationMethod.Singapore();
 params.rounding = adhan.Rounding.Nearest;

 this.time = new adhan.PrayerTimes(coordinates, date, params);

"Upcoming: None at 02:00"

not sure if I am the only one getting this one "next prayer". If the time has passed Isha, it shows this "None at 02:00"

Some Problem With Indonesia Coordinate

Fajr Time : 5:37 AM
Sunrise Time : 5:34 AM

var coordinates = new adhan.Coordinates( -7.974219442081672, 112.62662994813381);
var fajrTime = moment(prayerTimes.fajr).tz('Asia/Jakarta').format('h:mm A');
var sunriseTime = moment(prayerTimes.sunrise).tz('Asia/Jakarta').format('h:mm A');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.