RetroFed Forum
Your home away from modern life.
Is there a script I can use to pull the sunrise and sunset for a latitude/longitude without having to use my location services?
Post Reply
AuthorMessage
cheese_greater lemmy.world cheese_greater@lemmy.world
Joined: 2023-07-11
(edited) Quote

I'd like to ideally have some script I can hard-code my latitude/longitude in and have it return the correct sunrise and sunset times for that location throughout the year, maybe even print up a schedule for the week/month/year but at least be able to know for the curren day

Where is that weather data available to scrape?

8   Original
tal lemmy.today tal@lemmy.today
Joined: 2023-10-04
#2 · Quote Reply

Searching apt packages in Debian, it looks like there's a Python library "suntime".

https://pypi.org/project/suntime/

4
sin_free_for_00_days sopuli.xyz sin_free_for_00_days@sopuli.xyz
Joined: 2023-07-28
#3 · Quote Reply

hdate should be available on your system:

$ hdate -s -l 64 -L -21 -z 0   # iceland, timezone is +0 utc
Tuesday, 6 October 2026, eve of 26 Tishrei 5787
sunrise: 07:46
sunset: 18:36
hdate: ALERT: The information displayed is for today's Hebrew date.
              Because it is now after sunset, that means the data is
              for the Gregorian day beginning at midnight.

Gives a little more info than you want, but it is pretty easy to clean up.

$ hdate -q -s -l 64 -L -21 -z 0 | grep sun
sunrise: 07:46
sunset: 18:36

I don't think it handles daylight savings, but you can adjust for that.

5
cheese_greater lemmy.world cheese_greater@lemmy.world
Joined: 2023-07-11
#4 · Quote Reply

hdate should be available on your system: $ hdate -s -l 64 -L -21 -z 0 # iceland, timezone is +0 utc Tuesday, 6 October 2026, eve of 26 Tishrei 5787 sunrise: 07:46 sunset: 18:36 hdate: ALERT: The information displayed is for today's Hebrew date. Because it is now after sunset, that means the data is for the Gregorian day beginning at midnight. Gives a little more info than you want, but it is p...

Thanks!

3
Post Reply
Back to top