summaryrefslogtreecommitdiff
path: root/tempo.js
diff options
context:
space:
mode:
Diffstat (limited to 'tempo.js')
-rw-r--r--tempo.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/tempo.js b/tempo.js
index 87393db..682cb75 100644
--- a/tempo.js
+++ b/tempo.js
@@ -1,6 +1,7 @@
let timefmt = null;
-const months = ['January', 'February', 'March', 'April', 'May', 'June',
- 'July', 'August', 'September', 'October', 'November', 'December'];
+
+const MONTHS = Array.from({ length: 12 }, (_, i) =>
+ new Date(0, i).toLocaleString(undefined, { month: 'long' }));
function padTime(x) {
return (x < 10) ? '0' + x : x;
@@ -18,14 +19,14 @@ function updateTime() {
let dy = date.getFullYear();
if (timefmt == 12) // default to 24
- h = (h + 11) % 12 + 1;
-
- let str_t = padTime(h) + '\u00A0\u00A0' + padTime(m) +
- '\u00A0\u00A0' + padTime(s);
- let str_d = dd + ' ' + months[dm] + ' ' + dy;
-
- document.getElementById('time').textContent = str_t;
- document.getElementById('date').textContent = str_d;
+ h = h % 12 || 12;
+
+ document.getElementById('time').textContent =
+ padTime(h) + '\u00A0\u00A0' +
+ padTime(m) + '\u00A0\u00A0' +
+ padTime(s);
+ document.getElementById('date').textContent =
+ dd + ' ' + MONTHS[dm] + ' ' + dy;
}
function startTempo() {