Skip to content

Instantly share code, notes, and snippets.

@imlinus
Created January 19, 2018 13:38
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 imlinus/2cb76a4563aebcf63200496d127acbeb to your computer and use it in GitHub Desktop.
Save imlinus/2cb76a4563aebcf63200496d127acbeb to your computer and use it in GitHub Desktop.
Sun Set Rise
<script>
var ymd = '2018-01-19',
lat = '59.10',
lng = '16.40';
Sun.info(ymd, lat, lng).then(function() {
console.log(Sun.rise);
console.log(Sun.set);
});
</script>
var Sun = {
rise: '',
set: '',
cb: '',
info: function(ymd, lat, lng) {
var that = this;
$.get('https://api.sunrise-sunset.org/json?lat=' + lat + '&lng=' + lng + '&date=' + ymd, function(data) {
that.rise = data.results.sunrise;
that.set = data.results.sunset;
that.cb();
});
return this;
},
then(cb) {
this.cb = cb;
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment