Closed LIII-XXII closed 5 years ago
The ugly workaround I am using now looks like this:
from skyfield.api import load
import skyfield, skyfield.timelib
import datetime
TS = load.timescale()
A : skyfield.timelib.Time = TS.now()
tmp: datetime = A.utc_datetime()
B: skyfield.timelib.Time = TS.utc(tmp.year, tmp.month, tmp.day, tmp.hour, tmp.minute-1, tmp.second)
I am worried that this will break with leap seconds though.
Good question! By "one minute" do you mean "exactly 60 seconds", or "however many seconds will get me back to the same second-number in the previous minute in UTC"? And if the latter, what do you want to happen if the current time is 23:59:60.5, in the middle of a leap second?
in this case I mean "exactly 60 seconds", the goal is to find the date B that was 60 seconds before A (which makes it sound like I should use tmp.second-60
instead...)
Yes, you should get good results if you subtract 1.0 / 24 / 60
from the Terrestrial Time. Something like:
minute = 1.0 / 24 / 60
t2 = ts.tt_jd(t.tt - minute)
By the way, were the :
characters in your sample code your own notation, or part of a framework you're using? They didn't work when I tried them in the version of Python on this laptop.
these are python 3 type declarations (available from python 3.5/3.6): https://docs.python.org/3/library/typing.html thanks for the hint. We can close this now.
Hi,
I am trying to compute
B: skyfield.Date
that is a minute beforeA: skyfield.Date
.How should I go about this?
I tried using
datetime.timedelta
to represent one minute and subtract it, but it is not supported.I couldn't find a good way to do this in the examples or in the source of
skyfield.timelib
(timelib.py
). Any idea?