This commit is contained in:
Michael Teeuw 2016-04-20 11:42:01 +02:00
parent 287452169b
commit d778f2dd8b

View File

@ -43,6 +43,7 @@ Module.register("clock",{
var dateWrapper = document.createElement("div");
var timeWrapper = document.createElement("div");
var secondsWrapper = document.createElement("sup");
var periodWrapper = document.createElement("span");
// Style Wrappers
dateWrapper.className = "date normal medium";
@ -57,27 +58,30 @@ Module.register("clock",{
if (this.config.timeFormat !== 24) {
var now = new Date();
var hours = now.getHours() % 12 || 12;
if (this.config.showPeriod) {
if (this.config.showPeriodUpper) {
timeString = hours + moment().format(':mm A');
} else {
timeString = hours + moment().format(':mm a');
}
} else {
timeString = hours + moment().format(':mm');
}
timeString = hours + moment().format(':mm');
}
dateWrapper.innerHTML = moment().format("dddd, LL");
timeWrapper.innerHTML = timeString;
secondsWrapper.innerHTML = moment().format("ss");
if (this.config.showPeriodUpper) {
periodWrapper.innerHTML = moment().format('A');
} else {
periodWrapper.innerHTML = moment().format('a');
}
// Combine wrappers.
wrapper.appendChild(dateWrapper);
wrapper.appendChild(timeWrapper);
if (this.config.displaySeconds) {
timeWrapper.appendChild(secondsWrapper);
}
if (this.config.showPeriod) {
timeWrapper.appendChild(periodWrapper);
}
// Return the wrapper to the dom.
return wrapper;