 # how long till our cached data expires?
 ttl = (data) ->
   now = new Date
-  retrieved = Date.parse(data.retrieved)
-  data.lifetime * 1000 - (now.getTime() - retrieved)
+  if not data.lifetime? or not data.retrieved?
+    -1
+  else
+    retrieved = Date.parse(data.retrieved)
+    data.lifetime * 1000 - (now.getTime() - retrieved)
 
 alternative_place = (item) ->
   return '' if item.country != 'US' || item.state == "" || item.city == ""

    msg
      .http("http://api.wunderground.com/api/#{process.env.HUBOT_WUNDERGROUND_API_KEY}/#{service}/q/#{query}.json")
      .get() (err, res, body) ->
        data = JSON.parse(body)

        # probably an unknown place

  robot.brain.data.wunderground or= {}

  data = robot.brain.data.wunderground[cache_key]
  if data? and ttl(data) <= 0
    #console.log 'needs refresh'
    robot.brain.data.wunderground[cache_key] = data = null
  if data?
