Advertisement
wariat

sunrise-sunset.sh

Mar 13th, 2023
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.88 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # https://sunrise-sunset.org/api
  4. # MANUAL xD
  5. # ./sunrise-sunset.sh | tee  slonce-poznan-2023.csv
  6.  
  7. # Poznań
  8. Lat=52.4006632
  9. Lon=16.91973259178088
  10.  
  11. # date
  12. year=2023
  13.  
  14. echo "date, civil twilight begin [UTC], sunrise [UTC], sunset [UTC], civil twilight end [UTC]"
  15. for d in {0..364}
  16. do
  17.   date=`date --date="${year}0101 +${d}days" -I"date"` # CUDO xD
  18.   url="https://api.sunrise-sunset.org/json?lat=${Lat}&lng=${Lon}&date=${date}&formatted=1"
  19.   j=`curl --silent ${url}`
  20.   #echo ${j} | jq .results.civil_twilight_begin
  21.   printf "%s, %s, %s, %s, %s\n"                         \
  22.     ${date}                                             \
  23.     "`echo ${j} | jq .results.civil_twilight_begin`"    \
  24.     "`echo ${j} | jq .results.sunrise`"                 \
  25.     "`echo ${j} | jq .results.sunset`"                  \
  26.     "`echo ${j} | jq .results.civil_twilight_end`"
  27.   sleep 2
  28. done
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement