skyfield: Time in datetime mit spezifischer Zeitzone umwandeln
English
Deutsch
Wenn Sie ein skyfield Time-Objekt wie dieses haben
skyfield_time_example.py
t = ts.now()
# Beispiel: <Time tt=2459750.027604357>können Sie es mit .astimezone() und der pytz-Bibliothek in eine Python-datetime in einer spezifischen Zeitzone (in diesem Beispiel Europe/Berlin) umwandeln:
skyfield_astimezone_example.py
t.astimezone(pytz.timezone("Europe/Berlin"))
# Beispiel: datetime.datetime(2022, 6, 19, 14, 38, 35, 832445, tzinfo=<DstTzInfo 'Europe/Berlin' CEST+2:00:00 DST>)Vollständiges Beispiel
skyfield_time_conversion_example.py
from skyfield import api
from datetime import datetime
import pytz
ts = api.load.timescale()
t = ts.now()
dt = t.astimezone(pytz.timezone("Europe/Berlin"))
print(dt) # z. B. 2022-06-19 14:42:47.406786+02:00If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow