HijrahDateTime
2.0.0-alpha07indexedHijrah calendar support with date/time types (date, datetime, year-month), arithmetic, DSL-based formatting and parsing, serialization, conversion to standard date/time types, and ranges/progressions.
Hijrah calendar support with date/time types (date, datetime, year-month), arithmetic, DSL-based formatting and parsing, serialization, conversion to standard date/time types, and ranges/progressions.

HijrahDateTime is a Kotlin Multiplatform library for working with the Hijrah calendar system. It provides a robust set of core classes and a modern set of Compose-based UI pickers to handle Hijrah dates and times across different platforms.
Starting from version 2.0, this library has been rewritten as a Kotlin Multiplatform project, providing first-class support for JVM, Android, iOS, and macOS.
Experimental / Alpha Notice (2.0.0-alpha07)
This release is experimental and provided "as-is". The API surface and behavior may change without notice. If you plan to use it in production, please share your feedback and suggestions.
Add the dependency to your commonMain source set:
kotlin {
sourceSets {
commonMain.dependencies {
// Core library
implementation("com.abdulrahman-b.hijrahdatetime:hijrahdatetime:2.0.0-alpha07")
// Compose Pickers (for UI)
implementation("com.abdulrahman-b.hijrahdatetime:hijrahdatetime-compose-pickers:2.0.0-alpha07")
}
}
}
Represents a date (year, month, day) in the Hijrah calendar.
val date = HijrahDate(1446, 10, 12)
val tomorrow = date plusDays 1
val localDate = date.toLocalDate()
Combines a HijrahDate with a LocalTime.
val dateTime = HijrahDateTime(1446, 10, 12, 12, 30, 0, 0)
Represents a specific year and month in the Hijrah calendar.
val yearMonth = HijrahYearMonth(1446, HijrahMonth.RAMADAN)
println(yearMonth.numberOfDays) // Number of days in Ramadan 1446
val date = HijrahDate(1446, 10, 12)
val formatted = date.format(HijrahDateTimeFormats.DATE_ISO) // "1446-10-12"
// Using DSL builder
val dslFormat = buildDateTimeFormat {
year(); char('/'); monthName(NameStyle.FULL); char('/'); dayOfMonth()
}
println(date.format(dslFormat)) // "1446/Shawwal/12"
Core types are annotated with @Serializable.
@Serializable
data class Event(val name: String, val date: HijrahDate)
val start = HijrahDate(1446, 9, 1)
val end = HijrahDate(1446, 9, 30)
for (day in start..end) { println(day) }
A modern and customizable set of Hijrah Date Pickers for Compose Multiplatform, inspired by Material3.
| Single Picker | Range Picker |
|---|---|
![]() | ![]() |
| Input Mode |
|---|
![]() |
![]() |
The library provides three main components: HijrahDatePicker, HijrahDateRangePicker, and HijrahMultiDatePicker.
val datePickerState = rememberHijrahDatePickerState()
var openDialog by remember { mutableStateOf(false) }
if (openDialog) {
DatePickerDialog(
onDismissRequest = { openDialog = false },
confirmButton = {
TextButton(onClick = {
val selected = datePickerState.selectedDate
openDialog = false
}) { Text("OK") }
}
) {
HijrahDatePicker(state = datePickerState)
}
}
val rangePickerState = rememberHijrahDateRangePickerState()
// ... inside a dialog
HijrahDateRangePicker(state = rangePickerState)
This project is licensed under the MIT License - see the LICENSE file for details.
If you find this project helpful, please consider supporting my work!
HijrahDate, HijrahDateTime, HijrahYearMonth, and HijrahMonth.plus and minus with DatePeriod and DateTimeUnit.HijrahDateTimeFormat and a DSL-based builder.kotlinx-serialization.kotlinx-datetime types (LocalDate, LocalDateTime, Instant).date1..date2, date1 downTo date2).
![]() |
Surfaced from shared tags and platforms — no rankings paid for.