Skip to content

Commit

Permalink
Fixed 12/24 hour time format for sunrise/sunset time
Browse files Browse the repository at this point in the history
  • Loading branch information
jclarke0000 committed Jul 7, 2017
1 parent 57132fd commit 39af54e
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions MMM-MyWeather.js
Original file line number Diff line number Diff line change
Expand Up @@ -905,20 +905,25 @@ Module.register("MMM-MyWeather", {
this.sendNotification("CURRENTWEATHER_DATA", complimentIconJson);
}

var timeString = moment(sunriseSunsetDateObject).format("HH:mm");

if (this.config.timeFormat !== 24) {
if (this.config.showPeriod) {
if (this.config.showPeriodUpper) {
timeString = moment(sunriseSunsetDateObject).format("h:mm A");
} else {
timeString = moment(sunriseSunsetDateObject).format("h:mm a");
}
} else {
timeString = moment(sunriseSunsetDateObject).format("h:mm");
}
var timeString;
if (this.config.timeFormat.indexOf("H") != -1) {
timeString = moment(sunriseSunsetDateObject).format("HH:mm");
} else {
timeString = moment(sunriseSunsetDateObject).format("h:mm a");
}

// if (this.config.timeFormat !== 24) {
// if (this.config.showPeriod) {
// if (this.config.showPeriodUpper) {
// timeString = moment(sunriseSunsetDateObject).format("h:mm A");
// } else {
// timeString = moment(sunriseSunsetDateObject).format("h:mm a");
// }
// } else {
// timeString = moment(sunriseSunsetDateObject).format("h:mm");
// }
// }

this.sunriseSunsetTime = timeString;
this.sunriseSunsetIcon = (sunrise < now && sunset > now) ? "wi-sunset" : "wi-sunrise";
this.iconTable = (sunrise < now && sunset > now) ? this.config.iconTableDay : this.config.iconTableNight;
Expand Down

0 comments on commit 39af54e

Please sign in to comment.