This commit is contained in:
Cade Scroggins
2018-09-13 22:39:50 -07:00
parent dc586460e3
commit 6dd12e678b
+12 -5
View File
@@ -164,8 +164,7 @@
} }
#am-pm { #am-pm {
font-size: 2rem; font-size: .5em;
margin-left: 0.3rem;
} }
#search-form { #search-form {
@@ -446,12 +445,20 @@
const date = new Date(); const date = new Date();
let hours = this._pad(date.getHours()); let hours = this._pad(date.getHours());
let amPm = ''; let amPm = '';
if (this._twelveHour) { if (this._twelveHour) {
hours = (date.getHours() > 12) ? date.getHours() - 12 : (date.getHours() === 0) ? 12 : date.getHours(); hours = date.getHours() > 12
amPm = (date.getHours() > 12) ? 'PM' : 'AM'; ? date.getHours() - 12
: date.getHours() === 0
? 12
: date.getHours();
amPm = `&nbsp;<span id="am-pm">` +
`${date.getHours() > 12 ? 'PM' : 'AM'}</span>`;
} }
const minutes = this._pad(date.getMinutes()); const minutes = this._pad(date.getMinutes());
this._el.innerHTML = hours + this._delimiter + minutes + '<span id="am-pm">' + amPm + '</span>'; this._el.innerHTML = `${hours}${this._delimiter}${minutes}${amPm}`;
this._el.setAttribute('datetime', date.toTimeString()); this._el.setAttribute('datetime', date.toTimeString());
} }