Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next_setting Sun always shows today - 1 #251

Open
dmoore19 opened this issue Jan 26, 2023 · 1 comment
Open

next_setting Sun always shows today - 1 #251

dmoore19 opened this issue Jan 26, 2023 · 1 comment

Comments

@dmoore19
Copy link

Maybe I'm missing something here, but when I try to get sunrise and sunset for a particular date, sunset always gives a datestamp of the prior day's sunset.

location = ephem.Observer() 
location.lat = '28.03' 
location.long = '-97.07' 
location.date = '2023/03/01' 

sun = ephem.Sun() 
sun.compute(location) 
sunrise = location.next_rising(sun)
sunset = location.next_setting(sun)

print ("Sunrise ", ephem.localtime(sunrise) )
print ("Sunset ", ephem.localtime(sunset))

Output:
Sunrise 2023-03-01 06:52:46.682412
Sunset 2023-02-28 18:28:08.477292

I've tried with many dates, sunset always showing the prior day. What am I doing wrong?

@brandon-rhodes
Copy link
Owner

You are setting the date to UTC midnight, which appears to be before your local sunset. Try midnight in your own timezone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants