mars_time.datetime_to_marstime#
- mars_time.datetime_to_marstime(dt: datetime) MarsTime [source]#
Convert a
datetime.datetime
to aMarsTime
.- Parameters:
dt (datetime.datetime) – A datetime.datetime between Mars year -99 and 99. If it has no timezone info, this will assume the timezone is UTC.
- Returns:
The MarsTime associated with the input datetime.datetime.
- Return type:
Examples
Get the Mars time when MAVEN arrived at Mars. Wikipedia’s MAVEN page mentions the spacecraft successfully entered orbit on 2014-09-22 at 02:24 UTC.
>>> import mars_time, datetime >>> orbit_insertion = datetime.datetime(2014, 9, 22, 2, 24, 0) >>> datetime_to_marstime(orbit_insertion) MarsTime(year=32, sol=406.36)
Get the Mars time when the Perseverance rover landed. Wikipedia’s Perseverance page mentions the rover successfully landed on 2021-02-18 at 20:55 UTC.
>>> landing_date = datetime.datetime(2021, 2, 18, 20, 55, 0) >>> datetime_to_marstime(landing_date) MarsTime(year=36, sol=11.11)