Python has a package for converting Julian calendar to Gregorian calendar called jdcal . It simplifies conversion between both of systems so much that by only a few lines of code are sufficient to reach the functionality.
There are mainly four functions in jdcal:
- gcal2jd : converts Gregorian calendar to Julian date. Takes Year, month and day as integer arguments and returns 2 float tuples.
- jd2gcal : converts Julian date to Gregorian calendar. Takes two integers as arguments and returns four element tuple containing year(int), month(int), day(int) and the fractional part of the day in the Gregorian calendar(float).
- jcal2jd : converts Julian calendar date to Julian date. Takes all integer value as an args array and returns a float tuple.
- jd2jcal : converts Julian calendar date for the given Julian date. Returns tuple of four elements containing year(int), month(int), day(int) and the fractional part of the day in the Julian calendar(float) format.
To install, run the following command in your terminal
pip install jdcal
Example 1: (gcal2jd)
Example 2 :(jd2gcal)
(2020, 12, 15, 0.0)
Example 3 :(jcal2jd)
Example 4: (jd2jcal)
(2000, 2, 6, 0.0)
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course