Skip to main content

hijri_toolkit 0.2.0 copy "hijri_toolkit: ^0.2.0" to clipboard
hijri_toolkit: ^0.2.0 copied to clipboard

Convert between Gregorian and Hijri dates and format them in Arabic or English. Pure Dart and Flutter with no dependencies and no platform plugins.

hijri_toolkit #

hijri_toolkit banner

pub package License: MIT

Convert between Gregorian and Hijri dates and format them in Arabic or English. Pure Dart and Flutter — no dependencies, no native code, no platform plugins.

Features #

  • Convert DateTime ↔ HijriDate using the deterministic tabular civil Hijri calendar (30-year cycle).
  • Arabic month and weekday names, plus English transliterations.
  • Arabic-Indic (٠١٢٣٤٥٦٧٨٩) or Western (0..9) digits.
  • Pattern-based formatting (yyyy, MMMM, EEEE, …).
  • Date arithmetic (addDays, differenceInDays, copyWith).
  • A small HijriText widget with automatic RTL for Arabic.

Usage #

import 'package:hijri_toolkit/hijri_toolkit.dart';

final hijri = HijriDate.fromDateTime(DateTime(2023, 7, 18));
print(hijri); // HijriDate(1445-1-1)

final gregorian = HijriDate(1445, 1, 1).toDateTime();
print(gregorian); // 2023-07-18 00:00:00.000

final formatter = HijriFormatter(
  pattern: 'EEEE، d MMMM yyyy',
  locale: HijriLocale.ar,
  digits: HijriDigits.arabic,
);
print(formatter.format(hijri)); // الثلاثاء، ١ محرم ١٤٤٥

In a widget tree:

HijriText(
  HijriDate.now(),
  formatter: HijriFormatter(pattern: 'd MMMM yyyy'),
)

Accuracy note #

This package implements the tabular civil Hijri calendar, which is based on a fixed arithmetic cycle. It does not use moon sighting, so dates can differ by one day from observation-based calendars such as Umm al-Qura. It is well suited for deterministic formatting, tests and non-critical UI display.

License #

MIT — see LICENSE.

2
likes
150
points
158
downloads

Documentation

API reference

Publisher

verified publisherthodz.com

Weekly Downloads

Convert between Gregorian and Hijri dates and format them in Arabic or English. Pure Dart and Flutter with no dependencies and no platform plugins.

Repository (GitHub)
View/report issues

Topics

#flutter #hijri #date #formatter #arabic

License

MIT (license)

Dependencies

flutter

More

Packages that depend on hijri_toolkit