Skip to content

Instantly share code, notes, and snippets.

@levinotik
Created January 20, 2014 01:57
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levinotik/8513701 to your computer and use it in GitHub Desktop.
Save levinotik/8513701 to your computer and use it in GitHub Desktop.
private def getForecast:Try[JsValue] = {
val ts = date.getTime / 1000
val u = {
if (date == new Date()) new URL(s"https://api.forecast.io/forecast/$apiKey/$lat,$lon?units=$units")
else new URL(s"https://api.forecast.io/forecast/$apiKey/$lat,$lon,$ts?units=$units")
}
val s = new Scanner(u.openStream(), "UTF-8")
Try{s.useDelimiter("\\A").next().asJson}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment