Skip to content

Instantly share code, notes, and snippets.

@sunmockyang
Created November 2, 2016 16:21
Show Gist options
  • Select an option

  • Save sunmockyang/4ca4a3f0a5113179baf23b46f81f1793 to your computer and use it in GitHub Desktop.

Select an option

Save sunmockyang/4ca4a3f0a5113179baf23b46f81f1793 to your computer and use it in GitHub Desktop.
Outputs today's sunrise time
require "JSON"
require 'net/http'
require 'uri'
def open(url)
Net::HTTP.get(URI.parse(url))
end
# Put in your own latitude and longitude
puts JSON.parse(open('http://api.sunrise-sunset.org/json?lat=45.4215000&lng=-75.6972000&formatted=0&date=today'))["results"]["sunrise"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment