Last active
December 23, 2015 23:09
-
-
Save sydlawrence/6708113 to your computer and use it in GitHub Desktop.
sunrise and sunset data for a country
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var country = "UK"; | |
// fetch results from yql | |
var url = "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20location%20in%20(select%20id%20from%20weather.search%20where%20query%20%3D%20%22"+country+"%22)&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=?"; | |
$.getJSON(url, function(data) { | |
var sunData = {} | |
// if there are results | |
if (data.query.results.channel.length > 0) { | |
var result = data.query.results.channel[0]; | |
sunData.rise = result.astronomy.sunrise; | |
sunData.set = result.astronomy.sunset; | |
} | |
// do something with the data | |
console.log(sunData) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment