Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calculating julian date in python

I'm trying to create a julian date in python and having major struggles. Is there nothing out there as simple as:

jul = juliandate(year,month,day,hour,minute,second)

where jul would be something like 2457152.0 (the decimal changing with the time)?

I've tried jdcal, but can't figure out how to add the time component (jdcal.gcal2jd() only accepts year, month and day).

like image 423
edub Avatar asked Dec 14 '22 13:12

edub


1 Answers

Not a pure Python solution but you can use the SQLite in memory db which has a julianday() function:

import sqlite3
con = sqlite3.connect(":memory:")
list(con.execute("select julianday('2017-01-01')"))[0][0]

which returns: 2457754.5

like image 138
Janos Hajagos Avatar answered Jan 23 '23 15:01

Janos Hajagos