question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Skyfield time arithmetic

See original GitHub issue

Hi,

I am trying to compute B: skyfield.Date that is a minute before A: 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.

from skyfield.api import load
from datetime import timedelta
ts = load.timescale()
A = ts.now()
B = A - datetime.timedelta(minutes=1) #TypeError: unsupported operand type(s) for -: 'Time' and 'datetime.timedelta'

I couldn’t find a good way to do this in the examples or in the source of skyfield.timelib (timelib.py). Any idea?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
brandon-rhodescommented, Dec 12, 2018

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.

0reactions
LIII-XXIIcommented, Dec 13, 2018

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dates and Time — Skyfield documentation - Rhodes Mill
Date arithmetic becomes very simple as we leave UTC behind and consider completely uniform time scales. Days are always 24 hours, hours always...
Read more >
Adding a timedelta to a skyfield Time - python - Stack Overflow
What if I just wanted to use one (start) date and set the next date to be exactly one day after? I can't...
Read more >
How to convert skyfield Time into datetime at specific timezone
When you have a skyfield Time object like. convert-skyfield-time-into-datetime-at-specific-timezone.py 📋 Copy to clipboard⇓ Download.
Read more >
The Art of Time-Keeping, Part 1: Years and Dates - Quantum
It proves awfully convenient for time-based arithmetic, ... I was able to find algorithms in the Python library skyfield that works for ...
Read more >
Python timescale Examples
t = Time('1980-03-25 00:00') location = None # skyfield ephemeris planets = load('de421.bsp') ts = load.timescale() mercury, jupiter, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found