Convertdate Library
The `convertdate` library provides methods and functions for converting dates between various calendar systems, including Gregorian, Hebrew, Islamic, Julian, Mayan, and many others. It is currently at version 2.4.1 and sees a few releases per year, indicating active development.
Warnings
- breaking Python 3.5 and 3.6 are no longer supported. Ensure your environment uses Python 3.7 or newer.
- breaking Timezone handling internally switched from `pytz.utc` to `datetime.timezone.utc`. While direct `pytz` interaction might not be common, be aware of this change if you were relying on specific `pytz` behaviors or objects interacting with `convertdate`.
- breaking The Persian calendar computation method changed from an algorithmic to an astronomical one. This might lead to different results for dates compared to previous versions.
- breaking Attempting to convert dates before the Mayan epoch will now raise a `ValueError` instead of potentially returning incorrect or undefined results.
- breaking Several calendar modules had their variable names regularized (e.g., `coptic.MONTH_NAMES` was renamed to `coptic.MONTHS`). Code accessing the old variable names will no longer function.
- breaking The Julian converter now uses astronomical notation for pre-Common Era dates (1 BCE is 0, 2 BCE is -1). This is a fundamental change in date representation for these periods.
- gotcha Date conversions return results for noon of the day in question. Be aware that some calendar systems begin the day at sundown, which might require an adjustment in your application logic.
Install
-
pip install convertdate
Imports
- french_republican
from convertdate import french_republican
- hebrew
from convertdate import hebrew
- julian
from convertdate import julian
- holidays
from convertdate import holidays
Quickstart
from convertdate import french_republican
from convertdate import hebrew
from convertdate import julian
# Convert Gregorian date to French Republican
fr_date = french_republican.from_gregorian(2014, 10, 31)
print(f"Gregorian 2014-10-31 in French Republican: {fr_date}")
# Convert Gregorian date to Hebrew
he_date = hebrew.from_gregorian(2014, 10, 31)
print(f"Gregorian 2014-10-31 in Hebrew: {he_date}")
# Generate a Julian month calendar for January 2015
julian_month_calendar = julian.monthcalendar(2015, 1)
print(f"Julian calendar for Jan 2015: {julian_month_calendar}")