Possible fix for #181

This commit is contained in:
Michael Teeuw 2016-05-10 16:18:35 +02:00
parent 80c0e6a4e0
commit 5be5741ac3
4 changed files with 12080 additions and 11 deletions

View File

@ -41,22 +41,27 @@ Module.register("clock",{
dateWrapper.className = "date normal medium"; dateWrapper.className = "date normal medium";
timeWrapper.className = "time bright large light"; timeWrapper.className = "time bright large light";
secondsWrapper.className = "dimmed"; secondsWrapper.className = "dimmed";
// Set content of wrappers. // Set content of wrappers.
// The moment().format("h") method has a bug on the Raspberry Pi. // The moment().format("h") method has a bug on the Raspberry Pi.
// So we need to generate the timestring manually. // So we need to generate the timestring manually.
// See issue: https://github.com/MichMich/MagicMirror/issues/181 // See issue: https://github.com/MichMich/MagicMirror/issues/181
var timeString;
if (this.config.clockBold === true) { if (this.config.clockBold === true) {
var timeString = moment().format("HH[<span class=\"bold\">]mm[</span>]"); timeString = moment().format("HH[<span class=\"bold\">]mm[</span>]");
} else { } else {
var timeString = moment().format("HH:mm"); timeString = moment().format("HH:mm");
} }
if (this.config.timeFormat !== 24) { if (this.config.timeFormat !== 24) {
var now = new Date(); // var now = new Date();
var hours = now.getHours() % 12 || 12; // var hours = now.getHours() % 12 || 12;
if (this.config.clockBold === true) { if (this.config.clockBold === true) {
timeString = hours + moment().format("[<span class=\"bold\">]mm[</span>]"); //timeString = hours + moment().format("[<span class=\"bold\">]mm[</span>]");
timeString = moment().format("h[<span class=\"bold\">]mm[</span>]");
} else { } else {
timeString = hours + moment().format(":mm"); //timeString = hours + moment().format(":mm");
timeString = moment().format("h:mm");
} }
} }
dateWrapper.innerHTML = moment().format("dddd, LL"); dateWrapper.innerHTML = moment().format("dddd, LL");

View File

@ -226,15 +226,18 @@ Module.register("currentweather",{
var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise; var sunriseSunsetDateObject = (sunrise < now && sunset > now) ? sunset : sunrise;
var timeString = moment(sunriseSunsetDateObject).format('HH:mm'); var timeString = moment(sunriseSunsetDateObject).format('HH:mm');
if (this.config.timeFormat !== 24) { if (this.config.timeFormat !== 24) {
var hours = sunriseSunsetDateObject.getHours() % 12 || 12; //var hours = sunriseSunsetDateObject.getHours() % 12 || 12;
if (this.config.showPeriod) { if (this.config.showPeriod) {
if (this.config.showPeriodUpper) { if (this.config.showPeriodUpper) {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm A'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
timeString = moment(sunriseSunsetDateObject).format('h:mm A');
} else { } else {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm a'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
timeString = moment(sunriseSunsetDateObject).format('h:mm a');
} }
} else { } else {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm'); //timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
timeString = moment(sunriseSunsetDateObject).format('h:mm');
} }
} }

12061
vendor/moment/moment-with-locales.js vendored Normal file

File diff suppressed because it is too large Load Diff

2
vendor/vendor.js vendored
View File

@ -8,7 +8,7 @@
*/ */
var vendor = { var vendor = {
'moment.js' : 'moment/moment-with-locales.min.js', 'moment.js' : 'moment/moment-with-locales.js',
'weather-icons.css': 'weather-icons/weather-icons.css', 'weather-icons.css': 'weather-icons/weather-icons.css',
'font-awesome.css': 'font-awesome-4.5.0/css/font-awesome.min.css' 'font-awesome.css': 'font-awesome-4.5.0/css/font-awesome.min.css'
}; };