batoulapps / adhan-js

High precision Islamic prayer time library for JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add Correction time

farisfaisalthena opened this issue · comments

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.

You can make use of the adjustments parameter for that.

let params = adhan.CalculationMethod.MuslimWorldLeague();
params.adjustments = { fajr: 10, sunrise: 10, dhuhr: 10, maghrib: 10, isha: 10 };

Dint realise this existed. Thanks

Is it possible to update the time in realtime? for example if user changes the adjustments time in settings i will have to restart the app. Can it be done automatically on change?

Is it possible to update the time in real time? for example, if user changes the adjustments time in settings i will have to restart the app. Can it be done automatically on change?

Your app must be able to trigger a recomputation without a restart, and then, accordingly updating the UI, which should not be a problem with any modern framework.

This library is built to give you only one calculation result, which makes sense since even if it would give you "real-time" results you would still have to have a timer to refresh the UI, so make use of this timer not only to update the UI but also to calculate again the prayers times :

Basic example:

let times;
const refreshUI = () => {
  if (null !== times) {
     // Do whatever with times variable
  }
}

setInterval(() => {
     times = new adhan.PrayerTimes(coordinates, date, params);
     refreshUI();
}, 60 * 1000);

@farisfaisalthena

Here's an interactive demo using ReactJS - https://8n5y0.csb.app/

Stale issue message