Skip to content

prayer-timetable/prayer_calc_dart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Dart Prayer Calc Library

Library for calculating muslim prayer times based on excellent Adhan JavaScript. Ported to Dart, preserving the calculation logic. Adapted to use Dart's superior DateTime class for quick and convenient time calculations.

All astronomical calculations are high precision equations directly from the book “Astronomical Algorithms” by Jean Meeus. This book is recommended by the Astronomical Applications Department of the U.S. Naval Observatory and the Earth System Research Laboratory of the National Oceanic and Atmospheric Administration.

Dart Classes

PrayerTimetable

This class returns 5 daily prayers plus Sunrise. Takes the following input parameters:

  • int timezone,
  • double latitude,
  • double longitude,
  • double angle

Optional parameters:

  • int year,
  • int month,
  • int day,
  • int hour,
  • int minute,
  • int second,
  • int asrMethod: 1,
  • double ishaAngle,
  • bool summerTimeCalc: true,
  • DateTime time,
  • double altitude,
  • bool precision: true,

Some notes:

  • if no date is used, the library uses current date and time
  • asrMethod defaults to 1 (Shafi), 2 would mean Hanafi
  • ishaAngle would default to angle, in other words if ishaAngle is not used, angle value would be used for both dusk and dawn
  • summerTimeCalc is true by default, optionally it can be forced to false (no hour adjustments)
  • time is used for calculation of now as per below, otherwise current time is used
  • altitude currently not used
  • precision enables the display of seconds, otherwise if false, output times are rounded to nearest minute

This class returns prayers, calc, sunnah and qibla classes.

Prayers

This class returns the following:

  • DateTime now - current time at the location
  • DateTime current - current prayer time
  • DateTime next - next prayer time
  • DateTime previous - previous prayer time
  • bool isAfterIsha - is the current time after isha and before the midnight
  • int currentId - id of the current prayer/time (0 - 5)

Each of the current, next and previous returns 6 prayer times (ie. current.sunrise):

  • DateTime dawn - fajr prayer time
  • DateTime sunrise - shurooq time
  • DateTime midday - dhuhr prayer time
  • DateTime afternoon - asr prayer time
  • DateTime sunset - maghrib prayer time
  • DateTime dusk - isha prayer time

Calc

This class calculates calc to and from the prayers, taking into account next day Dawn for Isha prayer, as well as Previous day Isha when calculating Dawn for day after midnight. It also determines current, next and previous prayers based on current time. It returns the following:

  • Duration countDown - time until the next prayer
  • Duration countUp - time passed since the current prayer begun
  • double percentage: percentage of time passed between current and next prayer

Sunnah

This class calculates times that apply to certain sunnah-defined times. It provides the following:

  • DateTime midnight - mid-point between the Sunset-Maghrib and Dawn-Fajr
  • DateTime lastThird - as above, time indicating the beginning of the last third of the night

Qibla

Class returning single value:

  • double qibla - direction (bearing) to Qibla, in degrees

Installation

Add to your pubspec.yaml file:

  prayer_timetable:
    git:
      url: git://github.com/prayer-timetable/prayer_timetable_dart.git

Example

      int timezone = 1;
      double lat = 43.8563;
      double lng = 18.4131;
      double angle = 14.6;

      PrayerTimetable location = new PrayerTimetable(timezone, lat, lng, angle);

      // current day fajr
      print('${location.prayers.current.dawn');
      // next day asr
      print('${location.prayers.next.afternoon');
      // previous day isha
      print('${location.prayers.previous.dusk');
      // last third of the night
      print('${location.sunnah.lastThird}');
      // countdown to next prayer
      print('${location.calc.countDown}');
      // Qibla direction
      print('${location.qibla}');


This document still under review and more updates coming insha'Allah soon.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages