-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrenderer.js
More file actions
42 lines (32 loc) · 1.46 KB
/
Copy pathrenderer.js
File metadata and controls
42 lines (32 loc) · 1.46 KB
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
34
35
36
37
38
39
40
41
42
/**
* This file is loaded via the <script> tag in the index.html file and will
* be executed in the renderer process for that window. No Node.js APIs are
* available in this process because `nodeIntegration` is turned off and
* `contextIsolation` is turned on. Use the contextBridge API in `preload.js`
* to expose Node.js functionality from the main process.
*/
let lastDateString = '';
window.addEventListener('DOMContentLoaded', () => {
})
function updateClock() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');
const minutes = String(now.getMinutes()).padStart(2, '0');
const seconds = String(now.getSeconds()).padStart(2, '0');
document.getElementById('hours').textContent = hours;
document.getElementById('minutes').textContent = minutes;
document.getElementById('seconds').textContent = seconds;
const day = String(now.getDate()).padStart(2, '0');
const month = String(now.getMonth() + 1).padStart(2, '0');
const year = String(now.getFullYear()).slice(-2);
const weekday = new Intl.DateTimeFormat('en-US', { weekday: 'short' }).format(now);
const currentDateString = `${day} / ${month} ${year} ${weekday}`;
if (currentDateString !== lastDateString) {
document.getElementById('date').textContent = currentDateString;
lastDateString = currentDateString;
}
const msUntilNextSecond = 1000 - now.getMilliseconds();
setTimeout(updateClock, msUntilNextSecond);
}
// Start the clock
updateClock();