From 8adb16e1f613e5cedb6ee4e47eeae542fde24c2e Mon Sep 17 00:00:00 2001 From: Michael Teeuw Date: Sat, 16 Apr 2016 21:42:44 +0200 Subject: [PATCH] Change formatting. #181 --- modules/default/clock/clock.js | 3 ++- modules/default/currentweather/currentweather.js | 10 +++------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/default/clock/clock.js b/modules/default/clock/clock.js index 3acdf53d..3ab7a248 100644 --- a/modules/default/clock/clock.js +++ b/modules/default/clock/clock.js @@ -48,8 +48,9 @@ Module.register("clock",{ secondsWrapper.className = "dimmed"; // Set content of wrappers. + var format = (this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a"; dateWrapper.innerHTML = moment().format("dddd, LL"); - timeWrapper.innerHTML = moment().format((this.config.timeFormat === 24) ? "HH:mm" : ("hh:mm")); + timeWrapper.innerHTML = moment().format(format); secondsWrapper.innerHTML = moment().format("ss"); // Combine wrappers. diff --git a/modules/default/currentweather/currentweather.js b/modules/default/currentweather/currentweather.js index c033848f..887270b8 100644 --- a/modules/default/currentweather/currentweather.js +++ b/modules/default/currentweather/currentweather.js @@ -201,18 +201,14 @@ Module.register("currentweather",{ var now = moment(); var sunrise = moment(data.sys.sunrise * 1000); var sunset = moment(data.sys.sunset * 1000); + var format = (this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a"; if (sunrise < now && sunset > now) { - if (sunrise.isValid()) { - this.sunriseSunsetTime = sunset.format((this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a"); - } + this.sunriseSunsetTime = sunset.format(format); this.sunriseSunsetIcon = "wi-sunset"; } else { - if (sunset.isValid()) { - this.sunriseSunsetTime = sunrise.format((this.config.timeFormat === 24) ? "HH:mm" : "hh:mm a"); - } + this.sunriseSunsetTime = sunrise.format(format); this.sunriseSunsetIcon = "wi-sunrise"; - } this.loaded = true;