Allow 12 hour period config

Allow for configuring the 12 hour format period (AM/PM).
This commit is contained in:
Cody 2016-04-18 19:53:34 -04:00
parent 16a7ea2b75
commit b4df63f37f

View File

@ -17,6 +17,8 @@ Module.register("currentweather",{
updateInterval: 10 * 60 * 1000, // every 10 minutes updateInterval: 10 * 60 * 1000, // every 10 minutes
animationSpeed: 1000, animationSpeed: 1000,
timeFormat: config.timeFormat, timeFormat: config.timeFormat,
showPeriod: true,
showPeriodUpper: false,
lang: config.language, lang: config.language,
initialLoadDelay: 0, // 0 seconds delay initialLoadDelay: 0, // 0 seconds delay
@ -209,8 +211,16 @@ Module.register("currentweather",{
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.showPeriodUpper) {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm A');
} else {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm a'); timeString = hours + moment(sunriseSunsetDateObject).format(':mm a');
} }
} else {
timeString = hours + moment(sunriseSunsetDateObject).format(':mm');
}
}
this.sunriseSunsetTime = timeString; this.sunriseSunsetTime = timeString;
this.sunriseSunsetIcon = (sunrise < now && sunset > now) ? "wi-sunset" : "wi-sunrise"; this.sunriseSunsetIcon = (sunrise < now && sunset > now) ? "wi-sunset" : "wi-sunrise";