batoulapps / adhan-js Goto Github PK
View Code? Open in Web Editor NEWHigh precision Islamic prayer time library for JavaScript
License: MIT License
High precision Islamic prayer time library for JavaScript
License: MIT License
Hi,
CalculationMethod.Tehran() not found in version 4.0.1
Can you help me?
What's the difference between adjustments
and methodAdjustments
in the params?
Hi
It would be good if the sunset time was also exported from prayerTimes and in the nextPrayer method
because in some calculation Maqrib prayer time is not same as sunset
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
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)
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 }
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.
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
Prefer typescript with javascript deliverables.
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"
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);
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) },
]
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!
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 .
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.
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
Often, I'll find that the output of the currentPrayer and nextPrayer functions can be "none". I'm unsure of why, and was hoping somebody could explain exactly when the output would be "none" and when it could output something else.
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.
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.
based off of batoulapps/adhan-swift#42
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.
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:
The calculated times from a JavaScript code in a browser are:
The calculated times from the two functions runing on a Node js server are :
Why we have those +/- 2 minutes differences from the two sources even if the code is the same?
Thanks.
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.
is it possible to generate a calculation method parameters based on publicly available data? basically, reverse engineer that process?
Does the variation of the altitude from a city to another change the results ?
There's difference of minutes in the prayer times I get using your library and other apps like Muslim Pro, Prayer times
Really a very great project
But would it be using in Angular 10?
I did't find it on documentations
How would instalation be done on this? just download and put in files?
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.
How to get sunset time?
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 👍
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?
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"
}
In my project I need to add Imsak time as well. could this feature be added?
it currently points to lib/types/Adhan.d.ts
while it should point to lib/types/src/Adhan.d.ts
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.
السلام عليكم ورحمة الله وبركاته
احاول حساب اوقات الصلاة لولايات الجزائر مثل ولاية ادرار
{
"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
based on batoulapps/adhan-swift#43
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.
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
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');
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.