PrayerTimesManager 1.0.3

dotnet add package PrayerTimesManager --version 1.0.3
                    
NuGet\Install-Package PrayerTimesManager -Version 1.0.3
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PrayerTimesManager" Version="1.0.3" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PrayerTimesManager" Version="1.0.3" />
                    
Directory.Packages.props
<PackageReference Include="PrayerTimesManager" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PrayerTimesManager --version 1.0.3
                    
#r "nuget: PrayerTimesManager, 1.0.3"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PrayerTimesManager@1.0.3
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PrayerTimesManager&version=1.0.3
                    
Install as a Cake Addin
#tool nuget:?package=PrayerTimesManager&version=1.0.3
                    
Install as a Cake Tool

PrayerTimesManager

NuGet License: MIT

A lightweight .NET library for calculating Islamic prayer times (Imsak, Fajr, Sunrise, Dhuhr, Asr, Sunset, Maghrib, Isha, and Midnight) for any location, date, and time zone.

It supports 20+ built-in calculation methods used around the world (MWL, ISNA, Umm Al-Qura, Egypt, Karachi, Moonsighting Committee, and more), configurable juristic schools (Standard/Hanafi) for Asr, latitude adjustment methods for high-latitude locations, custom methods, and multiple output formats.

Features

  • Accurate astronomical calculation of prayer times based on latitude, longitude, elevation, and date
  • 20+ built-in calculation methods (e.g. MWL, ISNA, EGYPT, KARACHI, MAKKAH, MOONSIGHTING, TURKEY, RUSSIA, INDONESIA, ...) plus support for defining your own custom method
  • Asr juristic school selection (STANDARD / HANAFI)
  • High-latitude adjustment methods (angle-based, one-seventh, middle-of-the-night, or none)
  • Multiple time output formats: 24-hour, 12-hour, 12-hour without suffix, floating point, or ISO 8601
  • Per-prayer time tuning/offsets
  • Strongly-typed PrayerTimesResult output, or raw Hashtable if you need the original keys
  • Convenience NowResult / TomorrowResult helpers, with TimeProvider support for testability
  • Targets net10.0 with nullable reference types enabled

Installation

Install the PrayerTimesManager package from NuGet:

dotnet add package PrayerTimesManager

Or via the NuGet Package Manager:

Install-Package PrayerTimesManager

Getting started

using PrayerTimesManager;
using PrayerTimesManager.Enums;

var prayerTimes = new PrayerTimes(PrayerCalculationMethods.MWL, Schools.STANDARD);

PrayerTimesResult result = prayerTimes.GetTimesResult(
    latitude: 51.5074,
    longitude: -0.1278,
    dateTime: new DateTimeOffset(2024, 6, 15, 0, 0, 0, TimeSpan.Zero),
    timeZone: TimeZoneInfo.Utc);

Console.WriteLine($"Fajr:    {result.Fajr}");
Console.WriteLine($"Sunrise: {result.Sunrise}");
Console.WriteLine($"Dhuhr:   {result.Dhuhr}");
Console.WriteLine($"Asr:     {result.Asr}");
Console.WriteLine($"Maghrib: {result.Maghrib}");
Console.WriteLine($"Isha:    {result.Isha}");

Getting times for today and tomorrow

var prayerTimes = new PrayerTimes();

PrayerTimesResult today = prayerTimes.NowResult(latitude: 51.5074, longitude: -0.1278);
PrayerTimesResult tomorrow = prayerTimes.TomorrowResult(latitude: 51.5074, longitude: -0.1278);

Using the PrayerTimesInputs record

var inputs = new PrayerTimesInputs(
    Latitude: 21.4225,
    Longitude: 39.8262,
    DateTime: new DateTimeOffset(2024, 6, 15, 0, 0, 0, TimeSpan.Zero),
    TimeZone: TimeZoneInfo.Utc,
    Format: TimeFormats.TIME_FORMAT_24H);

var prayerTimes = new PrayerTimes(PrayerCalculationMethods.MAKKAH);
PrayerTimesResult result = prayerTimes.GetTimesResult(inputs);

Raw Hashtable output

If you need the original key-based output (e.g. PrayerTimes.FAJR, PrayerTimes.ISHA), use GetTimes instead of GetTimesResult:

Hashtable times = prayerTimes.GetTimes(latitude: 51.5074, longitude: -0.1278);
Console.WriteLine(times[PrayerTimes.FAJR]);

Choosing a calculation method and school

var prayerTimes = new PrayerTimes(PrayerCalculationMethods.ISNA, Schools.HANAFI);

// or change them later
prayerTimes.SetMethod(PrayerCalculationMethods.EGYPT);
prayerTimes.SetSchool(Schools.HANAFI);

Custom calculation methods

var customMethod = PrayerCalculationMethod.Custom with
{
    Param = new Hashtable
    {
        [PrayerTimes.FAJR] = 16d,
        [PrayerTimes.ISHA] = 15d
    }
};

prayerTimes.SetCustomMethod(customMethod);

Fine-tuning individual prayer times

prayerTimes.SetTuneTimeOffset(new Dictionary<string, double>
{
    [PrayerTimes.FAJR] = 2,   // add 2 minutes to Fajr
    [PrayerTimes.ISHA] = -3   // subtract 3 minutes from Isha
});

Moonsighting.com method offsets

The MOONSIGHTING method (Moonsighting Committee Worldwide) automatically applies two default offsets, as defined at moonsighting.com/how-we.html:

  • Dhuhr: 5 minutes after zenith
  • Maghrib: 3 minutes after theoretical sunset for the Sunni convention, or 17 minutes for the Shi'a convention

The Maghrib offset and the Isha twilight (Shafaq) are chosen automatically based on the selected School:

School Maghrib offset Isha Shafaq
STANDARD (Shafi'i, Maliki, Hanbali) 3 minutes (Sunni) General
HANAFI 3 minutes (Sunni) Abyad (whiteness)
JAFARI 17 minutes (Shi'a) Ahmer (redness)

These defaults are applied via the same tune-offset mechanism as SetTuneTimeOffset, and are exposed through the read-only TuneTimeOffsets property:

var prayerTimes = new PrayerTimes(PrayerCalculationMethods.MOONSIGHTING, Schools.JAFARI);

// Inspect the currently active offsets (Dhuhr = 5, Maghrib = 17 for Ja'fari)
foreach (var (key, minutes) in prayerTimes.TuneTimeOffsets)
    Console.WriteLine($"{key}: {minutes} min");

You can still override either default directly with SetTuneTimeOffset; explicit values you set always take precedence over the built-in defaults:

prayerTimes.SetTuneTimeOffset(new Dictionary<string, double>
{
    [PrayerTimes.MAGHRIB] = 20 // overrides the default Moonsighting Maghrib offset
});

The default offset values themselves are available as constants on MoonsightingOffsets (ZuhrOffsetMinutes, SunniMaghribOffsetMinutes, ShiaMaghribOffsetMinutes).

Testable time-dependent calls

PrayerTimes accepts a TimeProvider, so NowResult/TomorrowResult can be tested deterministically:

var fakeTime = new FakeTimeProvider(startDateTime: new DateTimeOffset(2024, 6, 15, 0, 0, 0, TimeSpan.Zero));
var prayerTimes = new PrayerTimes(timeProvider: fakeTime);

Calculation methods

Method Description
JAFARI Shia Ithna-Ashari, Leva Institute, Qum
KARACHI University of Islamic Sciences, Karachi
ISNA Islamic Society of North America
MWL Muslim World League (default)
MAKKAH Umm Al-Qura University, Makkah
EGYPT Egyptian General Authority of Survey
TEHRAN Institute of Geophysics, University of Tehran
GULF Gulf Region
KUWAIT Kuwait
QATAR Qatar
SINGAPORE Majlis Ugama Islam Singapura, Singapore
FRANCE Union Organization Islamic de France
TURKEY Diyanet İşleri Başkanlığı, Turkey
RUSSIA Spiritual Administration of Muslims of Russia
MOONSIGHTING Moonsighting Committee Worldwide
ALGERIA Algerian Minister of Religious Affairs and Wakfs
BASQUE Basque Country
JAKIM Jabatan Kemajuan Islam Malaysia
TUNISIA Tunisian Ministry of Religious Affairs
INDONESIA Indonesia (Kementerian Agama)
CUSTOM User-defined parameters

Requirements

  • .NET 10.0 or later

Repository

Source code and issue tracker: https://github.com/arahmancsd/PrayerTimesManager

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.3 167 8/21/2026
1.0.2 128 8/20/2026
1.0.1 116 8/19/2026
1.0.0 116 8/18/2026