ts.utc(...) != ts.now() when utc set to now.
See original GitHub issueHi there, I love your work! This is an excellent python package. I have also found ephem and pyephem to be useful, though I’m not sure I understand the difference between them all. They all work well.
I am running the following:
from skyfield.api import load
import datetime, time, re
planets = load('de421.bsp')
earth, mercury = planets['earth'], planets['mercury']
ts = load.timescale()
t1 = datetime.datetime.now()
precise_second_t1 = float(t1.strftime("%-S.%f"))
t_now = ts.now()
t_utc_now = ts.utc(t1.year, t1.month, t1.day, t1.hour, t1.minute, precise_second_t1)
astrometric1 = earth.at(t_now).observe(mercury)
astrometric2 = earth.at(t_utc_now).observe(mercury)
ra1, dec1, distance1 = astrometric1.radec()
ra2, dec2, distance2 = astrometric2.radec()
print('RA for ts.now():\t', ra1)
print('RA for ts.utc(...):\t', ra2)
These should print the same, but they are not. I am wondering if you know why this might be?
Thank you again for such an amazing package!
Ever yours, Jake Ireland.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Date.UTC() - JavaScript - MDN Web Docs
UTC() takes comma-delimited date and time parameters and returns the number of milliseconds between January 1, 1970, 00:00:00, universal time ...
Read more >How to convert a Date to UTC? - Stack Overflow
First, you must think of all Dates/Times as already being UTC with a timezone modifier for display purposes. Again, browsers may differ, however,...
Read more >Get the current Date and Time in UTC using JavaScript
Use the toUTCString() method to get the current date and time in utc, e.g. new Date().toUTCString() . The toUTCString method converts a date ......
Read more >UTC Time Now
UTC current date is 22nd Thursday December 2022. UTC: Coordinated Universal Time. About UTC Time.
Read more >Dates and Time — Skyfield documentation - Rhodes Mill
from skyfield.api import load # Asking the current date and time ts = load.timescale() t = ts.now() print(t.utc_jpl()). A.D. 2015-Oct-11 10:00:00.0000 UTC ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Correct! The
now()
routine does not attach a timezone. I’m glad you have the date working correctly now in your script, and, yes, hopefully if anyone else is confused thatdatetime.now()
does not return UTC, they will find this issue in a web search and learn about the difference.Ahh, I see. That does indeed work, thank you! So to clarify before we close the “issue”, datetime.datetime.now() lacks time zone information that datetime.datetime.utcnow()? Sorry to open an issue that wasn’t actually an issue. Hopefully this will help someone as naïve as myself in the future…