
Enables accurate Islamic prayer time calculations globally with customizable methods and configurations. Supports dynamic prayer tracking, various astronomical calculations, and extensive customization options.
A lightweight, accurate, and highly customizable Kotlin Multiplatform library for calculating Islamic prayer times across Android, iOS, JVM, and beyond. Inspired by the robust Adhan algorithm, this library provides precise astronomical calculations for all five daily prayers with support for multiple calculation methods, madhabs, and geographical scenarios.
Prayer Times KMM is designed for developers building Islamic applications that require reliable prayer time calculations. Whether you're creating a mobile app, desktop application, or server-side service, this library offers:
Perfect for prayer time apps, Qibla finders, Islamic calendars, mosque management systems, and any application requiring accurate salah timing.
dependencies {
implementation("io.github.alims-repo:prayer-times-kmm:1.0.4-beta")
}dependencies {
implementation 'io.github.alims-repo:prayer-times-kmm:1.0.4-beta'
}import io.github.alimsrepo.prayertimes.*
// 1. Define your location coordinates
val coordinates = Coordinates(
latitude = 21.4225, // Makkah
longitude = 39.8262
)
// 2. Specify the date
val dateComponents = DateComponents(
year = 2024,
month = 3,
day = 26
)
// 3. Configure calculation parameters
val calculationParameters = CalculationParameters(
method = CalculationMethod.UMM_AL_QURA,
madhab = Madhab.SHAFI,
rounding = RoundingType.NEAREST
)
// 4. Calculate prayer times
val prayerTimes = PrayerTimes(
coordinates = coordinates,
dateComponents = dateComponents,
calculationParameters = calculationParameters
)
// 5. Access individual prayer times
println("Fajr: ${prayerTimes.fajr}")
println("Sunrise: ${prayerTimes.sunrise}")
println("Dhuhr: ${prayerTimes.dhuhr}")
println("Asr: ${prayerTimes.asr}")
println("Maghrib: ${prayerTimes.maghrib}")
println("Isha: ${prayerTimes.isha}")val currentInstant = Clock.System.now()
// Find which prayer time it is now
val currentPrayer = prayerTimes.currentPrayer(currentInstant)
println("Current Prayer: $currentPrayer")
// Find the next upcoming prayer
val nextPrayer = prayerTimes.nextPrayer(currentInstant)
println("Next Prayer: $nextPrayer")
// Get time for a specific prayer
val fajrTime = prayerTimes.timeForPrayer(Prayer.FAJR)Fine-tune prayer times by adding or subtracting minutes:
val customParameters = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
// Adjust individual prayer times
prayerAdjustments = PrayerAdjustments(
fajr = 2, // Add 2 minutes to Fajr
dhuhr = -1, // Subtract 1 minute from Dhuhr
asr = 3, // Add 3 minutes to Asr
maghrib = 0, // No adjustment
isha = 0 // No adjustment
),
// Method-specific adjustments
methodAdjustments = MethodAdjustments(
fajr = 1, // Additional Fajr adjustment
isha = -2 // Additional Isha adjustment
)
)
val adjustedTimes = PrayerTimes(
coordinates = coordinates,
dateComponents = dateComponents,
calculationParameters = customParameters
)For locations with extreme latitudes (e.g., Scandinavia, Alaska):
val highLatitudeParams = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
highLatitudeRule = HighLatitudeRule.MIDDLE_OF_THE_NIGHT, // or SEVENTH_OF_THE_NIGHT, TWILIGHT_ANGLE
madhab = Madhab.SHAFI
)The library supports calculation methods from major Islamic authorities worldwide:
| Method | Organization | Region |
|---|---|---|
MUSLIM_WORLD_LEAGUE |
Muslim World League | Global |
EGYPTIAN |
Egyptian General Authority of Survey | Egypt, Middle East |
UMM_AL_QURA |
Umm Al-Qura University | Saudi Arabia |
GULF |
Gulf Region | UAE, Bahrain, Oman |
KUWAIT |
Ministry of Awqaf and Islamic Affairs | Kuwait |
QATAR |
Ministry of Awqaf and Islamic Affairs | Qatar |
SINGAPORE |
Majlis Ugama Islam Singapura | Singapore |
MOON_SIGHTING_COMMITTEE |
Moonsighting Committee Worldwide | North America |
KARACHI |
University of Islamic Sciences | Pakistan, Bangladesh |
TEHRAN |
Institute of Geophysics | Iran |
NORTH_AMERICA |
Islamic Society of North America | USA, Canada |
Create your own method with custom angles:
val customMethod = CalculationParameters(
fajrAngle = 18.0, // Fajr angle in degrees
ishaAngle = 17.0, // Isha angle in degrees
ishaInterval = 0, // Or use interval in minutes instead
method = CalculationMethod.OTHER
)Different Islamic schools of thought calculate Asr time differently:
Madhab.SHAFI - Asr begins when shadow length equals object height (earlier)Madhab.HANAFI - Asr begins when shadow length equals 2Γ object height (later)val hanafi = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
madhab = Madhab.HANAFI
)Control how prayer times are rounded:
enum class RoundingType {
NEAREST, // Round to nearest minute (default)
UP, // Always round up
DOWN, // Always round down
NONE // No rounding, keep exact time
}| Platform | Status | Notes |
|---|---|---|
| Android | β Full Support | API 21+ |
| iOS | β Full Support | iOS 13+ |
| JVM | β Full Support | Java 8+ |
| JS | π Planned | Future release |
| Native | π Planned | Future release |
Main class for calculating prayer times.
class PrayerTimes(
coordinates: Coordinates,
dateComponents: DateComponents,
calculationParameters: CalculationParameters
)Geographical location.
data class Coordinates(
val latitude: Double, // -90 to 90
val longitude: Double // -180 to 180
)Date specification.
data class DateComponents(
val year: Int,
val month: Int, // 1-12
val day: Int // 1-31
)Enumeration of prayer types.
enum class Prayer {
FAJR, SUNRISE, DHUHR, ASR, MAGHRIB, ISHA
}// Example test case
@Test
fun testMakkahPrayerTimes() {
val makkah = Coordinates(21.4225, 39.8262)
val date = DateComponents(2024, 1, 1)
val params = CalculationParameters(
method = CalculationMethod.UMM_AL_QURA
)
val times = PrayerTimes(makkah, date, params)
assertNotNull(times.fajr)
assertNotNull(times.dhuhr)
assertNotNull(times.asr)
assertNotNull(times.maghrib)
assertNotNull(times.isha)
}Contributions are welcome! Here's how you can help:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Prayer times are computational approximations based on astronomical calculations. While this library strives for accuracy, always consult local religious authorities and mosques for the official prayer times in your area, as they may account for local sighting conditions and community practices.
Proprietary Software
Copyright Β© 2025 Alim Sourav. All rights reserved.
This software is proprietary and may not be used, copied, modified, or distributed without explicit permission from the copyright holder.
Made with β€οΈ by Alim Sourav
If this library helps your project, please consider giving it a βοΈ!
A lightweight, accurate, and highly customizable Kotlin Multiplatform library for calculating Islamic prayer times across Android, iOS, JVM, and beyond. Inspired by the robust Adhan algorithm, this library provides precise astronomical calculations for all five daily prayers with support for multiple calculation methods, madhabs, and geographical scenarios.
Prayer Times KMM is designed for developers building Islamic applications that require reliable prayer time calculations. Whether you're creating a mobile app, desktop application, or server-side service, this library offers:
Perfect for prayer time apps, Qibla finders, Islamic calendars, mosque management systems, and any application requiring accurate salah timing.
dependencies {
implementation("io.github.alims-repo:prayer-times-kmm:1.0.4-beta")
}dependencies {
implementation 'io.github.alims-repo:prayer-times-kmm:1.0.4-beta'
}import io.github.alimsrepo.prayertimes.*
// 1. Define your location coordinates
val coordinates = Coordinates(
latitude = 21.4225, // Makkah
longitude = 39.8262
)
// 2. Specify the date
val dateComponents = DateComponents(
year = 2024,
month = 3,
day = 26
)
// 3. Configure calculation parameters
val calculationParameters = CalculationParameters(
method = CalculationMethod.UMM_AL_QURA,
madhab = Madhab.SHAFI,
rounding = RoundingType.NEAREST
)
// 4. Calculate prayer times
val prayerTimes = PrayerTimes(
coordinates = coordinates,
dateComponents = dateComponents,
calculationParameters = calculationParameters
)
// 5. Access individual prayer times
println("Fajr: ${prayerTimes.fajr}")
println("Sunrise: ${prayerTimes.sunrise}")
println("Dhuhr: ${prayerTimes.dhuhr}")
println("Asr: ${prayerTimes.asr}")
println("Maghrib: ${prayerTimes.maghrib}")
println("Isha: ${prayerTimes.isha}")val currentInstant = Clock.System.now()
// Find which prayer time it is now
val currentPrayer = prayerTimes.currentPrayer(currentInstant)
println("Current Prayer: $currentPrayer")
// Find the next upcoming prayer
val nextPrayer = prayerTimes.nextPrayer(currentInstant)
println("Next Prayer: $nextPrayer")
// Get time for a specific prayer
val fajrTime = prayerTimes.timeForPrayer(Prayer.FAJR)Fine-tune prayer times by adding or subtracting minutes:
val customParameters = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
// Adjust individual prayer times
prayerAdjustments = PrayerAdjustments(
fajr = 2, // Add 2 minutes to Fajr
dhuhr = -1, // Subtract 1 minute from Dhuhr
asr = 3, // Add 3 minutes to Asr
maghrib = 0, // No adjustment
isha = 0 // No adjustment
),
// Method-specific adjustments
methodAdjustments = MethodAdjustments(
fajr = 1, // Additional Fajr adjustment
isha = -2 // Additional Isha adjustment
)
)
val adjustedTimes = PrayerTimes(
coordinates = coordinates,
dateComponents = dateComponents,
calculationParameters = customParameters
)For locations with extreme latitudes (e.g., Scandinavia, Alaska):
val highLatitudeParams = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
highLatitudeRule = HighLatitudeRule.MIDDLE_OF_THE_NIGHT, // or SEVENTH_OF_THE_NIGHT, TWILIGHT_ANGLE
madhab = Madhab.SHAFI
)The library supports calculation methods from major Islamic authorities worldwide:
| Method | Organization | Region |
|---|---|---|
MUSLIM_WORLD_LEAGUE |
Muslim World League | Global |
EGYPTIAN |
Egyptian General Authority of Survey | Egypt, Middle East |
UMM_AL_QURA |
Umm Al-Qura University | Saudi Arabia |
GULF |
Gulf Region | UAE, Bahrain, Oman |
KUWAIT |
Ministry of Awqaf and Islamic Affairs | Kuwait |
QATAR |
Ministry of Awqaf and Islamic Affairs | Qatar |
SINGAPORE |
Majlis Ugama Islam Singapura | Singapore |
MOON_SIGHTING_COMMITTEE |
Moonsighting Committee Worldwide | North America |
KARACHI |
University of Islamic Sciences | Pakistan, Bangladesh |
TEHRAN |
Institute of Geophysics | Iran |
NORTH_AMERICA |
Islamic Society of North America | USA, Canada |
Create your own method with custom angles:
val customMethod = CalculationParameters(
fajrAngle = 18.0, // Fajr angle in degrees
ishaAngle = 17.0, // Isha angle in degrees
ishaInterval = 0, // Or use interval in minutes instead
method = CalculationMethod.OTHER
)Different Islamic schools of thought calculate Asr time differently:
Madhab.SHAFI - Asr begins when shadow length equals object height (earlier)Madhab.HANAFI - Asr begins when shadow length equals 2Γ object height (later)val hanafi = CalculationParameters(
method = CalculationMethod.MUSLIM_WORLD_LEAGUE,
madhab = Madhab.HANAFI
)Control how prayer times are rounded:
enum class RoundingType {
NEAREST, // Round to nearest minute (default)
UP, // Always round up
DOWN, // Always round down
NONE // No rounding, keep exact time
}| Platform | Status | Notes |
|---|---|---|
| Android | β Full Support | API 21+ |
| iOS | β Full Support | iOS 13+ |
| JVM | β Full Support | Java 8+ |
| JS | π Planned | Future release |
| Native | π Planned | Future release |
Main class for calculating prayer times.
class PrayerTimes(
coordinates: Coordinates,
dateComponents: DateComponents,
calculationParameters: CalculationParameters
)Geographical location.
data class Coordinates(
val latitude: Double, // -90 to 90
val longitude: Double // -180 to 180
)Date specification.
data class DateComponents(
val year: Int,
val month: Int, // 1-12
val day: Int // 1-31
)Enumeration of prayer types.
enum class Prayer {
FAJR, SUNRISE, DHUHR, ASR, MAGHRIB, ISHA
}// Example test case
@Test
fun testMakkahPrayerTimes() {
val makkah = Coordinates(21.4225, 39.8262)
val date = DateComponents(2024, 1, 1)
val params = CalculationParameters(
method = CalculationMethod.UMM_AL_QURA
)
val times = PrayerTimes(makkah, date, params)
assertNotNull(times.fajr)
assertNotNull(times.dhuhr)
assertNotNull(times.asr)
assertNotNull(times.maghrib)
assertNotNull(times.isha)
}Contributions are welcome! Here's how you can help:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)Prayer times are computational approximations based on astronomical calculations. While this library strives for accuracy, always consult local religious authorities and mosques for the official prayer times in your area, as they may account for local sighting conditions and community practices.
Proprietary Software
Copyright Β© 2025 Alim Sourav. All rights reserved.
This software is proprietary and may not be used, copied, modified, or distributed without explicit permission from the copyright holder.
Made with β€οΈ by Alim Sourav
If this library helps your project, please consider giving it a βοΈ!