blob: 55165c7197446bd4404001983259e433c386e687 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
import Mustache from 'mustache';
var template;
var days = ['SUNDAY', 'MONDAY', 'TUESDAY', 'WEDNESDAY', 'THURSDAY', 'FRIDAY', 'SATURDAY'];
function formatAMPM(date) {
var hours = date.getHours();
var minutes = date.getMinutes();
var ampm = hours >= 12 ? 'PM' : 'AM';
hours = hours % 12;
hours = hours ? hours : 12;
minutes = minutes < 10 ? '0'+minutes : minutes;
var strTime = hours + ':' + minutes + ' ' + ampm;
return strTime;
}
function initInterval() {
setInterval(function() {
var date = new Date();
document.getElementById('timeContainer').innerHTML = Mustache.render(template, {
day: days[date.getDay()],
hour: formatAMPM(date)
});
}, 1000);
}
export function init() {
template = document.getElementById('time-template').innerHTML;
Mustache.parse(template);
initInterval();
}
|