mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Possible fix for #181
This commit is contained in:
parent
bef5b48fce
commit
8793196bb3
@ -48,9 +48,18 @@ Module.register("clock",{
|
|||||||
secondsWrapper.className = "dimmed";
|
secondsWrapper.className = "dimmed";
|
||||||
|
|
||||||
// Set content of wrappers.
|
// Set content of wrappers.
|
||||||
var format = (this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a";
|
// The moment().format('h') method has a bug on the Raspberry Pi.
|
||||||
|
// So we need to generate the timestring manually.
|
||||||
|
// See issue: https://github.com/MichMich/MagicMirror/issues/181
|
||||||
|
var timeString = moment().format('HH:mm');
|
||||||
|
if (this.config.timeFormat !== 24) {
|
||||||
|
var now = new Date();
|
||||||
|
var hours = now.getHours() % 12 || 12;
|
||||||
|
timeString = hours + moment().format(':mm a');
|
||||||
|
}
|
||||||
|
|
||||||
dateWrapper.innerHTML = moment().format("dddd, LL");
|
dateWrapper.innerHTML = moment().format("dddd, LL");
|
||||||
timeWrapper.innerHTML = moment().format(format);
|
timeWrapper.innerHTML = timeString;
|
||||||
secondsWrapper.innerHTML = moment().format("ss");
|
secondsWrapper.innerHTML = moment().format("ss");
|
||||||
|
|
||||||
// Combine wrappers.
|
// Combine wrappers.
|
||||||
|
@ -198,19 +198,25 @@ Module.register("currentweather",{
|
|||||||
this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed));
|
this.windSpeed = this.ms2Beaufort(this.roundValue(data.wind.speed));
|
||||||
this.weatherType = this.config.iconTable[data.weather[0].icon];
|
this.weatherType = this.config.iconTable[data.weather[0].icon];
|
||||||
|
|
||||||
var now = moment();
|
var now = new Date();
|
||||||
var sunrise = moment(data.sys.sunrise * 1000);
|
var sunrise = new Date(data.sys.sunrise * 1000);
|
||||||
var sunset = moment(data.sys.sunset * 1000);
|
var sunset = new Date(data.sys.sunset * 1000);
|
||||||
var format = (this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a";
|
|
||||||
|
|
||||||
if (sunrise < now && sunset > now) {
|
// The moment().format('h') method has a bug on the Raspberry Pi.
|
||||||
this.sunriseSunsetTime = sunset.format(format);
|
// So we need to generate the timestring manually.
|
||||||
this.sunriseSunsetIcon = "wi-sunset";
|
// See issue: https://github.com/MichMich/MagicMirror/issues/181
|
||||||
} else {
|
var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise;
|
||||||
this.sunriseSunsetTime = sunrise.format(format);
|
var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
|
||||||
this.sunriseSunsetIcon = "wi-sunrise";
|
if (this.config.timeFormat !== 24) {
|
||||||
|
var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
|
||||||
|
timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.sunriseSunsetTime = timeString;
|
||||||
|
this.sunriseSunsetIcon = (sunrise < now && sunset > now) ? "wi-sunset" : "wi-sunrise";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
this.loaded = true;
|
this.loaded = true;
|
||||||
this.updateDom(this.config.animationSpeed);
|
this.updateDom(this.config.animationSpeed);
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user