Cool this site..i didn't know it..thanks....
Il 24 Settembre 2023 05:00:45 CEST, Greg Wooledge <g...@wooledge.org> ha scritto: >On Sun, Sep 24, 2023 at 12:35:18AM +0000, Andy Smith wrote: >> $ curl -s >> 'https://api.sunrise-sunset.org/json?lat=51.509865&lng=-0.118092&formatted=0' >> | jq . >> { >> "results": { >> "sunrise": "2023-09-24T05:47:54+00:00", >> "sunset": "2023-09-24T17:57:14+00:00", >> "solar_noon": "2023-09-24T11:52:34+00:00", >> "day_length": 43760, >> "civil_twilight_begin": "2023-09-24T05:16:19+00:00", >> "civil_twilight_end": "2023-09-24T18:28:49+00:00", >> "nautical_twilight_begin": "2023-09-24T04:37:02+00:00", >> "nautical_twilight_end": "2023-09-24T19:08:06+00:00", >> "astronomical_twilight_begin": "2023-09-24T03:56:14+00:00", >> "astronomical_twilight_end": "2023-09-24T19:48:54+00:00" >> }, >> "status": "OK" >> } >> >> The documentation is here: >> >> https://sunrise-sunset.org/api > >Yes, that's pretty reasonable. The times are given in UTC, so they >must be converted. Fortunately, GNU date can do that for us. > >As a one-liner: > >unicorn:~$ curl -s >'https://api.sunrise-sunset.org/json?lat=41.4483&lng=-82.1689&formatted=0' | >jq -r .results.sunrise,.results.sunset | { read -r sunrise; read -r sunset; >date "+Sunrise: %R" -d "$sunrise"; date "+Sunset: %R" -d "$sunset"; } >Sunrise: 07:16 >Sunset: 19:24 > >As a script: > >#!/bin/sh >lat=41.4483 >lng=-82.1689 >curl -s "https://api.sunrise-sunset.org/json?lat=$lat&lng=$lng&formatted=0" | > jq -r .results.sunrise,.results.sunset | { > read -r sunrise > read -r sunset > date "+Sunrise: %R" -d "$sunrise" > date "+Sunset: %R" -d "$sunset" > } >