forked from khushi-purwar/WebDev-ProjectKart
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
27 lines (22 loc) · 760 Bytes
/
script.js
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
const clockElement = document.querySelector('.clock');
const extraInfoElement = document.querySelector('.extra-info');
const clockBorderElement = document.querySelector('.clock-border');
// helper functions
const format = (str) => str.toString().padStart(2, '0');
const dateFn = () => {
const dt = new Date();
const hr = dt.getHours();
const min = dt.getMinutes();
clockElement.textContent = `${format(hr)}:${format(min)}`;
extraInfoElement.textContent = luxon.DateTime.local().toFormat(
'cccc, MMM dd',
);
};
dateFn();
setInterval(dateFn, 1000);
let deg = 0;
// animation spin
setInterval(() => {
clockBorderElement.style.background = `linear-gradient(${deg}deg, #ffb703, #fb8500)`;
deg = (deg + 1) % 360;
}, 1);