Islamic prayer times for Dart/Flutter. Pure Dart port of pray-calc with NREL SPA + dynamic twilight angles.
Find a file
Aric Camarata 178e990cbc fix: normalize date to UTC calendar day so prayer times are host-timezone-independent
getTimes now constructs civDate = DateTime.utc(date.year, date.month, date.day, 12, 0, 0)
at entry and passes it to both getSpa and getAngles. Previously a local DateTime in a
positive-UTC-offset zone (e.g. UTC+12) would reach getSpa.toUtc() as the previous UTC
calendar day, shifting all prayer times by ~24 h. Regression tests added for UTC/local
DateTime consistency across UTC, EDT, and Auckland host timezones (27 tests, all pass).
2026-06-13 10:37:32 -04:00
.github docs: update README, add wiki docs, and document types (P1) 2026-05-30 20:16:21 -04:00
lib fix: normalize date to UTC calendar day so prayer times are host-timezone-independent 2026-06-13 10:37:32 -04:00
test fix: normalize date to UTC calendar day so prayer times are host-timezone-independent 2026-06-13 10:37:32 -04:00
.editorconfig style: replace em dashes with colons; add .editorconfig 2026-03-08 17:28:08 -04:00
.gitignore Initial release: pray_calc_dart v1.0.0 2026-03-08 12:48:40 -04:00
analysis_options.yaml Initial release: pray_calc_dart v1.0.0 2026-03-08 12:48:40 -04:00
CHANGELOG.md fix: normalize date to UTC calendar day so prayer times are host-timezone-independent 2026-06-13 10:37:32 -04:00
LICENSE Initial release: pray_calc_dart v1.0.0 2026-03-08 12:48:40 -04:00
pubspec.yaml fix: remove invalid publisher field from pubspec 2026-05-29 15:53:39 -04:00
README.md docs: update README, add wiki docs, and document types (P1) 2026-05-30 20:16:21 -04:00

pray_calc_dart

pub package CI License: MIT Wiki

Islamic prayer times for Dart and Flutter. Pure Dart port of pray-calc, implementing the MCW seasonal model and dynamic twilight angles. Uses nrel_spa for the NREL Solar Position Algorithm.

Installation

dependencies:
  pray_calc_dart: ^1.0.0

Quick Start

import 'package:pray_calc_dart/pray_calc_dart.dart';

void main() {
  final date = DateTime(2024, 3, 15);
  final times = getTimes(date, 40.7128, -74.0060, -5.0);

  print('Fajr:    ${formatTime(times.fajr)}');
  print('Sunrise: ${formatTime(times.sunrise)}');
  print('Dhuhr:   ${formatTime(times.dhuhr)}');
  print('Asr:     ${formatTime(times.asr)}');
  print('Maghrib: ${formatTime(times.maghrib)}');
  print('Isha:    ${formatTime(times.isha)}');
  print('Qiyam:   ${formatTime(times.qiyam)}');
}

API

Full API documentation, guides, and examples are in the wiki.

Core functions

Function Description
getTimes(date, lat, lng, tz, {...}) All prayer times for a date and location
getAngles(date, lat, lng, {...}) Dynamic Fajr/Isha depression angles
getSpa(date, lat, lng, tz, {...}) NREL Solar Position Algorithm (re-export)
formatTime(hours) Fractional hours to HH:MM:SS string

Dynamic Angle Algorithm

Fixed-angle methods (ISNA 15 degrees, MWL 18 degrees) produce inaccurate Fajr times at latitudes above 45 degrees N/S. The dynamic method adapts the depression angle based on season, latitude, Earth-Sun distance, and local atmospheric conditions.

Result: approximately 18 degrees at the equator, approximately 12-14 degrees at 50-55 degrees N in summer. Matches observational data from the Moonsighting Committee Worldwide.

Compatibility

Dart SDK 3.7.0+. Works in Flutter (iOS, Android, Web, Desktop), Dart CLI, and server-side Dart. Single dependency: nrel_spa.

  • pray-calc - TypeScript/JavaScript version (npm)
  • nrel-spa - Standalone NREL SPA for JavaScript
  • qibla - Qibla direction calculator

Acknowledgments

The Solar Position Algorithm is based on:

Reda, I. and Andreas, A. (2004). Solar Position Algorithm for Solar Radiation Applications. NREL/TP-560-34302. DOI: 10.2172/15003974

The MCW seasonal model is based on the work of the Moonsighting Committee Worldwide (Khalid Shaukat).

License

MIT. The NREL SPA implementation carries its own terms (see LICENSE for details).