Re: Sunrise and Sunset from terminal
Hi,
sudo apt install python3-ephem
And in one line:
"""
(LATITUDE=51.5; LONGITUDE=0.12; python3 -c "import ephem; o=ephem.Observer(); o.lat, o.lon = $LATITUDE, $LONGITUDE; print('Sunrise:', o.next_rising(ephem.Sun()).datetime(), 'Sunset:', o.next_setting(ephem.Sun()).datetime())")
"""
The output:
Sunrise: 2023-09-28 05:34:38.906872 Sunset: 2023-09-27 17:14:27.209178
It fits in an alias :-)
The () is to avoid leaving LATITUDE and LONGITUDE defined.
I wouldn't use an external service for this, it can be avoided.
On 23 Sep 2023 at 23:51:44, sl91@gmx.com wrote:
> Is there a way to get sunrise and sunset time from command interpreter?
> I want to use its output for a script!
--
Carles Pina i Estany
https://carles.pina.cat || Wiktionary translations: https://kamus.pina.cat
Reply to: