API Reference
This page contains auto-generated API reference documentation for the main classes of HijriDate package.
-
class Hijri(year, month, day, *, validate=True)[source]
Bases: object
A Hijri object represents a date in lunar Hijri calendar.
- Parameters:
-
- 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.
- Parameters:
date_string (str) – Hijri date in ISO format YYYY-MM-DD.
- Return type:
Hijri
-
classmethod today()[source]
Construct Hijri object from today’s date.
- Return type:
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
-
year_length()[source]
Return number of days in year.
- Return type:
int
-
month_length()[source]
Return number of days in month.
- Return type:
int
-
month_name(language='en')[source]
Return month name.
- Parameters:
language (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized month name.
- 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 (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized day name.
- Return type:
str
-
static notation(language='en')[source]
Return calendar era notation.
- Parameters:
language (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized era notation.
- 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:
Gregorian
-
class Gregorian[source]
Bases: date
A Gregorian object represents a date in Gregorian calendar.
- Parameters:
year (int) – Gregorian year.
month (int) – Gregorian month.
day (int) – Gregorian day.
-
classmethod fromdate(date_object)[source]
Construct Gregorian object from a Python date object.
- Parameters:
date_object (date) – Python date object.
- Return type:
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 (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized month name.
- Return type:
str
-
day_name(language='en')[source]
Return day name.
- Parameters:
language (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized day name.
- Return type:
str
-
static notation(language='en')[source]
Return calendar era notation.
- Parameters:
language (Literal['en', 'ar', 'bn', 'tr']) – Two-letter language code for localized era notation.
- 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
The following are the supported ranges by the Umm al-Qura calendar (defined at hijridate.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).