Add Sunrise sunset search

This commit is contained in:
sriramsv
2023-02-20 16:38:04 -08:00
parent 003b8d7cbb
commit 6421810891
2 changed files with 39 additions and 3 deletions

View File

@@ -8,13 +8,12 @@
local json = require "json"
local date = require "date"
function on_alarm()
local location=system:location()
url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1"
http:get(url)
get_sun_info(location)
end
function on_network_result(result)
local t = json.decode(result)
local table = {
@@ -22,4 +21,9 @@ function on_network_result(result)
{ "sunset:", date(t.results.sunset):tolocal():fmt("%r") },
}
ui:show_table(table, 2)
end
function get_sun_info(location)
url="https://api.sunrise-sunset.org/json?lat="..location[1].."&lng="..location[2].."&date=today&formatted=1"
http:get(url)
end