mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
fixed beaufortwindspeed for imperial units
This commit is contained in:
parent
cc274ffebe
commit
88d862303d
@ -13,7 +13,8 @@
|
|||||||
// As soon as we start implementing the forecast, mode properties will be added.
|
// As soon as we start implementing the forecast, mode properties will be added.
|
||||||
|
|
||||||
class WeatherObject {
|
class WeatherObject {
|
||||||
constructor() {
|
constructor(units) {
|
||||||
|
this.units = units;
|
||||||
this.date = null;
|
this.date = null;
|
||||||
this.windSpeed = null;
|
this.windSpeed = null;
|
||||||
this.windDirection = null;
|
this.windDirection = null;
|
||||||
@ -26,7 +27,7 @@ class WeatherObject {
|
|||||||
this.humidity = null;
|
this.humidity = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
cardinalWindDirection () {
|
cardinalWindDirection() {
|
||||||
if (this.windDirection > 11.25 && this.windDirection <= 33.75){
|
if (this.windDirection > 11.25 && this.windDirection <= 33.75){
|
||||||
return "NNE";
|
return "NNE";
|
||||||
} else if (this.windDirection > 33.75 && this.windDirection <= 56.25) {
|
} else if (this.windDirection > 33.75 && this.windDirection <= 56.25) {
|
||||||
@ -62,20 +63,18 @@ class WeatherObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
beaufortWindSpeed () {
|
beaufortWindSpeed() {
|
||||||
var kmh = this.windSpeed * 60 * 60 / 1000;
|
const windInKmh = this.units === "imperial" ? this.windSpeed * 1.609344 : this.windSpeed * 60 * 60 / 1000;
|
||||||
var speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000];
|
const speeds = [1, 5, 11, 19, 28, 38, 49, 61, 74, 88, 102, 117, 1000];
|
||||||
for (var beaufort in speeds) {
|
for (const [index, speed] of speeds.entries()) {
|
||||||
var speed = speeds[beaufort];
|
if (speed > windInKmh) {
|
||||||
if (speed > kmh) {
|
return index;
|
||||||
return beaufort;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 12;
|
return 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
nextSunAction () {
|
nextSunAction() {
|
||||||
var now = new Date();
|
return moment().isBetween(this.sunrise, this.sunset) ? "sunset" : "sunrise";
|
||||||
return (this.sunrise < now && this.sunset > now) ? "sunset" : "sunrise";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user