Best way to convert a Unix epoch timestamp to a Skyfield time #1027
-
What is the best way to convert a Unix epoch timestamp to a Skyfield time? By definition the Unix epoch timestamp is UTC, and the leap seconds are ignored. So the day and the time of day can simply be distinguished by dividing the value by 86400. The quotient is the day, the remainder the seconds within the day. Assuming
But this seams to me complicated, as it involves using the So there is an alternative, but I am not sure, whether it is correct or not:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Alas, there is no method
The output:
I wonder if I should add a method that does this, to help out other folks who deal with UNIX timestamps. |
Beta Was this translation helpful? Give feedback.
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: