fix rain amount information for different units and providers, documentation

This commit is contained in:
fewieden
2018-12-30 20:46:25 +01:00
parent 8dd7621f29
commit de04c12d3c
7 changed files with 150 additions and 18 deletions

View File

@@ -194,6 +194,12 @@ Module.register("weather",{
value += "K";
}
}
} else if (type === "rain") {
if (isNaN(value)) {
value = "";
} else {
value = `${value.toFixed(2)} ${this.config.units === "imperial" ? "in" : "mm"}`;
}
}
return value;
@@ -202,17 +208,5 @@ Module.register("weather",{
this.nunjucksEnvironment().addFilter("roundValue", function(value) {
return this.roundValue(value);
}.bind(this));
this.nunjucksEnvironment().addFilter("formatRain", function(value) {
if (isNaN(value)) {
return "";
}
if(this.config.units === "imperial") {
return `${(parseFloat(value) / 25.4).toFixed(2)} in`;
} else {
return `${parseFloat(value).toFixed(1)} mm`;
}
}.bind(this));
}
});