Skip to content

Instantly share code, notes, and snippets.

@sydlawrence
Last active December 23, 2015 23:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sydlawrence/6708113 to your computer and use it in GitHub Desktop.
Save sydlawrence/6708113 to your computer and use it in GitHub Desktop.
sunrise and sunset data for a country
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