Converts between Gregorian dates and other calendar systems
Maintained. Last release 3 months ago, commits in 1 of the last 26 weeks. Weaker on commit activity and contributor spread.
pip install convertdateconvertdate
The convertdate package was originally developed as "Python Date Utils" by Phil Schwartz. It has been significantly updated and expanded.
Consult the complete docs for detailed usage info.
Available calendars:
- Armenian
- Bahai
- Coptic (Alexandrian)
- French Republican
- Gregorian
- Hebrew
- Indian Civil
- Islamic
- Julian
- Mayan
- Persian
- Positivist
- Mayan
- ISO
- Ordinal (day of year)
- Dublin day count
- Julian day count
The holidays module also provides some useful holiday-calculation,
with a focus on North American and Jewish holidays.
Installing
pip install convertdate
Or download the package and run python setup.py install.
Examples
>>> from convertdate import french_republican
>>> from convertdate import hebrew
>>> french_republican.from_gregorian(2014, 10, 31)
(223, 2, 9)
>>> hebrew.from_gregorian(2014, 10, 31)
(5775, 8, 7)
Note that in some calendar systems, the day begins at sundown. Convertdate gives the conversion for noon of the day in question.
Each module includes a monthcalendar function, which will generate a
calender-like nested list for a year and month (each list of dates runs
from Sunday to Saturday)
>>> hebrew.monthcalendar(5775, 8)
[
[None, None, None, None, None, None, 1],
[2, 3, 4, 5, 6, 7, 8],
[9, 10, 11, 12, 13, 14, 15],
[16, 17, 18, 19, 20, 21, 22],
[23, 24, 25, 26, 27, 28, 29]
]
>>> julian.monthcalendar(2015, 1)
[
[None, None, None, 1, 2, 3, 4],
[5, 6, 7, 8, 9, 10, 11],
[12, 13, 14, 15, 16, 17, 18],
[19, 20, 21, 22, 23, 24, 25],
[26, 27, 28, 29, 30, 31, None]
]
Special Options
Armenian
The Armenian calendar begins on 11 July 552 (Julian) and has two modes of reckoning. The first is the invariant-length version consisting of 12 months of 30 days each and five epagomenal days; the second is the version established by Yovhannes Sarkawag in 1084, which fixed the first day of the year with respect to the Julian calendar and added a sixth epagomenal day every four years.
By default the invariant calendar is used, but the Sarkawag calendar can be used beginning with the Armenian year 533 (11 August 1084) by passing the parameter to the relevant functions.