Search packages, repositories and app categories

GitHub repositoryahmedoid/hijri_date

hijri_date

Convert between Hijri Calendar and Gregorian Calendar date.

hijri_date project cover
Stars
22
Forks
33
Last push (UTC)
May 22, 2026
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Hijri

Hijri Calendar Converter

Usage
//Suppose current gregorian data/time is: Mon May 29 00:27:33  2018
  var _today = HijriCalendar.now();
  print(_today.hYear); // 1439
  print(_today.hMonth); // 9
  print(_today.hDay); // 14
  print(_today.getDayName()); // 14
  // Get month length in days
  print(_today.lengthOfMonth); // 30 days
  print(_today.toFormat("MMMM dd yyyy")); //Ramadan 14 1439
Change Local
  HijriCalendar.setLocal(locale);
Add New Locale
  HijriCalendar.addLocale(locale, {
    'long': ...,
    'short': ...,
    'days': ...,
    'short_days': ...
  });
  HijriCalendar.setLocal(locale);
From Gregorian to Ummalqura
var h_date = HijriCalendar.fromDate(DateTime(2018, 11, 12));
print(h_date.toString()); //04/03/1440H
print(h_date.getShortMonthName()); //Rab1
print(h_date.getLongMonthName()); //Rabi' al-awwal
print(h_date.lengthOfMonth); // 29 days
Check if date is valid
  //
  var _check_date = HijriCalendar();
  _check_date.hYear = 1439;
  _check_date.hMonth = 11;
  _check_date.hDay = 30;
  print(_check_date.isValid()); // false -> This month is only 29 days
From Ummalqura to Gregorian
  //From Ummalqura to Gregorian
  var g_date = HijriCalendar();
  print(g_date.hijriToGregorian(1415, 7, 27)); //1994-12-29 00:00:00.000
Format
  var _format = HijriCalendar.now();
  print(_format.fullDate()); //Thulatha, Ramadan 14, 1439 h
  print(_format.toFormat("mm dd yy")); //09 14 39
Compare
  //Suppose current hijri data is: Thulatha, Ramadan 14, 1439 h
  print(_today.isAfter(1440, 11, 12)); // false
  print(_today.isBefore(1440, 11, 12)); // true
  print(_today.isAtSameMomentAs(1440, 11, 12)); // false

Ahmed Aljuaid GitHub avatar
GitHub author

Ahmed Aljuaid ↗

Data Scientist.

Saudi Arabia, Riyadh
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 1 items

  • testDevelopment^1.14.3

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗