Skip to content
Discussion options

You must be logged in to vote

Alas, there is no method .utc_jd(), because I didn't want Skyfield to have to decide how to assign floating-point JD values to a non-uniform timescale like UTC, where some days are longer than others. But instead you can use the normal calendar-oriented .utc() method, telling it you want a date that's hundreds or thousands of days into 1970, and since it knows that some days are longer and have leap seconds in them, it will wind up successfully creating the date you want. Thus:

import datetime
from skyfield.api import load, utc

ts = load.timescale()

# Example timestamp: 2025 Jan 1 00:00:00.

y = 2025 - 1970
leaps = y // 4 + 1
timestamp = 60 * 60 * 24 * (365 * y + leaps)

# The approach …

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@roe-dl
Comment options

Answer selected by roe-dl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants