iamriajul / adhan-dart

Adhan for Dart / Muslim Prayer Times Library. Now retrieving Prayer time in Dart easier than ever.
https://pub.dev/packages/adhan
MIT License
88 stars 41 forks source link

Current Prayer & Next prayer #7

Closed moosalim closed 3 years ago

moosalim commented 3 years ago

Hello Brother.

There are issues with current preyer and next prayer , if you can pleas check and fix.

The issues are as follows:

1- if the current preayer is showing as (Prayer.isha) then the next Prayer is showing (Prayer.none). it should show (Prayer.fajr).

2- if the time is now is after the Sunrise time, it shows (Prayer.sunrise). there is not prayer as sunrise.

Also I have some suggestion to add more time calculations as follows:

1- can you please add (next prayer) is after ....... (count down time)

2- can you please add the time of mid-night (calculated as the mean time from sunset to fajr)

3- can you please add the start time of the last third of the night. (duration between sunset and fajr / 3 = i) (i + i + sunset time = start time of the last third of the night)

iamriajul commented 3 years ago

Just updated the doc, for SunnahTimes and Qibla.

iamriajul commented 3 years ago

2- can you please add the time of mid-night (calculated as the mean time from sunset to fajr)

3- can you please add the start time of the last third of the night. (duration between sunset and fajr / 3 = i) (i + i + sunset time = start time of the last third of the night)

for these two please check SunnahTimes

iamriajul commented 3 years ago

1- if the current preayer is showing as (Prayer.isha) then the next Prayer is showing (Prayer.none). it should show (Prayer.fajr).

giving next prayer fajr at a date-changing point (24 hours a day) will be complicated to handle, and it will make complexity as there will be two fajr in the same PrayerTimes instance, which will be confusing. so handle the Prayer.none case with your own application's needs and logic.

iamriajul commented 3 years ago

2- if the time is now is after the Sunrise time, it shows (Prayer.sunrise). there is not prayer as sunrise.

Yes, there is!. there is a prayer called Ishraq.

The time for the Ishraq prayer begins fifteen to twenty minutes after sunrise and consists of two Raka'ahs. ... According to majority of scholars of Hadith and Fiqh, Duha Prayer and Al-Ishraq Prayer are all names of the same salah (ritual prayer).

https://en.wikipedia.org/wiki/Nafl_prayer#:~:text=The%20time%20for%20the%20Ishraq,consists%20of%20two%20Raka'ahs.&text=According%20to%20majority%20of%20scholars,same%20salah%20(ritual%20prayer).

iamriajul commented 3 years ago

1- can you please add (next prayer) is after ....... (count down time)

this is not clear to me.

moosalim commented 3 years ago

Thank you very much for updating the docs. Please allow my to add the following comments:

alamsz commented 3 years ago

Thank you very much for updating the docs. Please allow my to add the following comments:

  • For Qibla, the docs is not clear to me, how to use it. Do you have an example? is this a compass ?
  • For the last item which is not clear to you , I mean by adding count down time for the remining time to next preayer like: Aser after 1:18:23

Sorry to chime in, the count down time should be pretty straightforward, and the library already has timeForPrayer method, which I think sufficient to calculate countdown timer, this is my implementation


 Timer(Duration(seconds: 1), () {
      var curTime = DateTime.now();
      var nextPrayerTime = prayerTime.timeForPrayer(prayerTimes.nextPrayer());
      var milisDiff = nextPrayerTime.millisecondsSinceEpoch -
          curTime.millisecondsSinceEpoch;
      var hourDiff = milisDiff ~/ 3600000;
      var minuteDiff = (milisDiff - hourDiff * 3600000) ~/ 60000;
      setState(() {
        textAdzanRemaining = 'next prayer in $hourDiff hour $minuteDiff minutes';
      });```
iamriajul commented 3 years ago

Thank you very much for updating the docs. Please allow my to add the following comments:

  • For Qibla, the docs is not clear to me, how to use it. Do you have an example? is this a compass ?
  • For the last item which is not clear to you , I mean by adding count down time for the remining time to next preayer like: Aser after 1:18:23

Sorry to chime in, the count down time should be pretty straightforward, and the library already has timeForPrayer method, which I think sufficient to calculate countdown timer, this is my implementation

 Timer(Duration(seconds: 1), () {
      var curTime = DateTime.now();
      var nextPrayerTime = prayerTime.timeForPrayer(prayerTimes.nextPrayer());
      var milisDiff = nextPrayerTime.millisecondsSinceEpoch -
          curTime.millisecondsSinceEpoch;
      var hourDiff = milisDiff ~/ 3600000;
      var minuteDiff = (milisDiff - hourDiff * 3600000) ~/ 60000;
      setState(() {
        textAdzanRemaining = 'next prayer in $hourDiff hour $minuteDiff minutes';
      });```

this is not a flutter specific flutter library, it's a dart library, so it should be usable everywhere. please try to understand, everything can't be pushed into the library. the library follows the Adhan project.

alamsz commented 3 years ago

Thank you very much for updating the docs. Please allow my to add the following comments:

  • For Qibla, the docs is not clear to me, how to use it. Do you have an example? is this a compass ?
  • For the last item which is not clear to you , I mean by adding count down time for the remining time to next preayer like: Aser after 1:18:23

Sorry to chime in, the count down time should be pretty straightforward, and the library already has timeForPrayer method, which I think sufficient to calculate countdown timer, this is my implementation

 Timer(Duration(seconds: 1), () {
      var curTime = DateTime.now();
      var nextPrayerTime = prayerTime.timeForPrayer(prayerTimes.nextPrayer());
      var milisDiff = nextPrayerTime.millisecondsSinceEpoch -
          curTime.millisecondsSinceEpoch;
      var hourDiff = milisDiff ~/ 3600000;
      var minuteDiff = (milisDiff - hourDiff * 3600000) ~/ 60000;
      setState(() {
        textAdzanRemaining = 'next prayer in $hourDiff hour $minuteDiff minutes';
      });```

this is not a flutter specific flutter library, it's a dart library, so it should be usable everywhere. please try to understand, everything can't be pushed into the library. the library follows the Adhan project.

Agree, I only point out that the library has sufficient method for dev to be able to implement it in flutter, and only giving example. My apologies if my comment causing confusion

muzohaib763 commented 3 years ago

@alamsz i want to implement same functionality to my app but i don't know how, i copy your code but it cannot work can you show me how to implement it

alamsz commented 3 years ago

@alamsz i want to implement same functionality to my app but i don't know how, i copy your code but it cannot work can you show me how to implement it

I've made simple example in https://github.com/lamsz/adzan it is deployed in https://adzan.lamsz.id/#/ hopefully could help you @muzohaib763

moosalim commented 3 years ago

@alamsz thanks for the code. but there is an issue, it does not work if the next prayer is Fajr.

dijitalkale commented 2 years ago

@alamsz thanks for the code. but there is an issue, it does not work if the next prayer is Fajr.

did you solve the problem

dijitalkale commented 2 years ago

@alamsz thanks for the code. but there is an issue, it does not work if the next prayer is Fajr.

did you solve the problem

Let me write the solution I found for those who come to this issue. below snippet will solve your problem.

var newDate = DateTime( nextPrayerTime.year, nextPrayerTime.month, nextPrayerTime.day + 1, //we mark the next day nextPrayerTime.hour, nextPrayerTime.minute , nextPrayerTime.second, nextPrayerTime.microsecond, );

debugPrint(newDate.millisecondsSinceEpoch.toString());

alamsz commented 2 years ago

@alamsz thanks for the code. but there is an issue, it does not work if the next prayer is Fajr.

did you solve the problem

it's not an issue actually, since the library regards Fajr in the next day, you only need to get the next day first prayer if it is none.

other alternative, you could give intermediate placeholder such as waiting for midnight, since after midnight next prayer will show fajr

iamriajul commented 2 years ago

Here's my Kotlin version of Running & Next Prayer determination, this might help you write your own dart code: https://gist.github.com/2cdbc15d4fd0e8bad203205c9302a54b

Thanks.