API Reference

This page contains auto-generated API reference documentation for the main classes of hijri-converter package.

class Hijri(year, month, day, validate=True)[source]

Bases: object

A Hijri object represents a date (year, month and day) in lunar Hijri calendar.

Parameters
  • year (int) – Hijri year.

  • month (int) – Hijri month.

  • day (int) – Hijri day.

  • validate (bool) – Whether to validate Hijri input or not. It’s recommended to keep the default for accurate conversion.

Raises
  • OverflowError – When year is out of supported Hijri range.

  • ValueError – When month is not within the range of 1..12.

  • ValueError – When day is not within the range of 1..month_length for month.

classmethod fromisoformat(date_string)[source]

Construct Hijri object from an ISO formatted Hijri date YYYY-MM-DD.

Parameters

date_string (str) – Hijri date in ISO format YYYY-MM-DD.

Return type

hijri_converter.convert.Hijri

classmethod today()[source]

Construct Hijri object from today’s date.

Return type

hijri_converter.convert.Hijri

property year: int

Return year as an integer.

property month: int

Return month as an integer.

property day: int

Return day as an integer.

datetuple()[source]

Return date as a tuple of (year, month, day).

Return type

Tuple[int, int, int]

isoformat()[source]

Return date in ISO format i.e. YYYY-MM-DD.

Return type

str

dmyformat(separator='/', padding=True)[source]

Return date in day-month-year format (DD/MM/YYYY by default).

Parameters
  • separator (str) – String that separates the day, month, and year values.

  • padding (bool) – Whether to add a leading zero as a padding character to fill day and month values when less than 10.

Return type

str

month_length()[source]

Return number of days in month.

Return type

int

month_name(language='en')[source]

Return month name.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

weekday()[source]

Return day of week, where Monday is 0 and Sunday is 6.

Return type

int

isoweekday()[source]

Return day of week, where Monday is 1 and Sunday is 7.

Return type

int

day_name(language='en')[source]

Return day name.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

static notation(language='en')[source]

Return calendar era notation.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

to_julian()[source]

Return corresponding Julian day number (JDN).

Return type

int

to_gregorian()[source]

Return Gregorian object for the corresponding Hijri date.

Return type

hijri_converter.convert.Gregorian

class Gregorian[source]

Bases: datetime.date

A Gregorian object represents a date (year, month and day) in Gregorian calendar.

classmethod fromdate(date_object)[source]

Construct Gregorian object from a Python date object.

Parameters

date_object (datetime.date) – Python date object.

Return type

hijri_converter.convert.Gregorian

datetuple()[source]

Return date as a tuple of (year, month, day).

Return type

Tuple[int, int, int]

dmyformat(separator='/', padding=True)[source]

Return date in day-month-year format (DD/MM/YYYY by default).

Parameters
  • separator (str) – String that separates the day, month, and year values.

  • padding (bool) – Whether to add a leading zero as a padding character to fill day and month values when less than 10.

Return type

str

month_name(language='en')[source]

Return month name.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

day_name(language='en')[source]

Return day name.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

static notation(language='en')[source]

Return calendar era notation.

Parameters

language (str) – Language tag for localized month name. Full locale name can be used, e.g. en-US or en_US.UTF-8. Supported languages are en, ar and bn.

Return type

str

to_julian()[source]

Return corresponding Julian day number (JDN).

Return type

int

to_hijri()[source]

Return Hijri object for the corresponding Gregorian date.

Raises

OverflowError – When date is out of supported Gregorian range.

Return type

hijri_converter.convert.Hijri


The following are the supported ranges by the Umm al-Qura calendar (defined at hijri_converter.ummalqura module):

HIJRI_RANGE: Tuple[Tuple[int, int, int], Tuple[int, int, int]] = ((1343, 1, 1), (1500, 12, 30))

Inclusive range of supported Hijri dates (year, month and day).

GREGORIAN_RANGE: Tuple[Tuple[int, int, int], Tuple[int, int, int]] = ((1924, 8, 1), (2077, 11, 16))

Inclusive range of supported Gregorian dates (year, month and day).