yr-lib
Advanced tools
Comparing version 1.0.12 to 1.0.13
31
index.js
@@ -45,16 +45,27 @@ var fs = require('fs'), | ||
fs.readFile(__dirname + '/weatherjson.json', 'utf8', function(err, data) { | ||
var parsedData = JSON.parse(data); | ||
if(!err) { | ||
var parsedData; | ||
try { | ||
parsedData = JSON.parse(data); | ||
} catch(err) { | ||
callback({"Error": "unable to parse the json weather file"}); | ||
} | ||
if(local_time != null) { | ||
var time = moment(local_time).utc().add(1, 'h').startOf('hour').format(); | ||
time = time.substring(0, 13); | ||
if(local_time != null) { | ||
var time = moment(local_time).utc().add(1, 'h').startOf('hour').format(); | ||
time = time.substring(0, 13); | ||
filterdData = _.remove(parsedData.weatherdata.product.time, function(n) { | ||
return n.from.substring(0,13) && n.to.substring(0,13) === time; | ||
}); | ||
callback(filterdData); | ||
filterdData = _.remove(parsedData.weatherdata.product.time, function(n) { | ||
return n.from.substring(0,13) && n.to.substring(0,13) === time; | ||
}); | ||
callback(filterdData); | ||
} else { | ||
callback(parsedData.weatherdata.product.time); | ||
} | ||
} else { | ||
callback(parsedData.weatherdata.product.time); | ||
callback({"Error": "unable to read the weather json file"}); | ||
} | ||
@@ -61,0 +72,0 @@ }) |
{ | ||
"name": "yr-lib", | ||
"version": "1.0.12", | ||
"version": "1.0.13", | ||
"description": "yr.no api", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
3429
57