61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
|
const aiMonths = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
||
|
const aiPendor = [0, 1, 25, 49, 73, 97, 121, 145, 146, 147, 171, 195, 211, 243, 267, 291, 292];
|
||
|
const asWNames = ["Seren", "Anar", "Noren", "Aldea", "Erwer", "Elenya"];
|
||
|
const asMNames = [
|
||
|
"Yestar",
|
||
|
"Narrin",
|
||
|
"Nenim",
|
||
|
"Sulim",
|
||
|
"Virta",
|
||
|
"Lothess",
|
||
|
"Narnya",
|
||
|
"Attendes",
|
||
|
"Loende",
|
||
|
"Cerim",
|
||
|
"Urim",
|
||
|
"Yavar",
|
||
|
"Narquel",
|
||
|
"Hiss",
|
||
|
"Ring",
|
||
|
"Mettare",
|
||
|
];
|
||
|
|
||
|
const p = (n: number): string => {
|
||
|
const t = n.toFixed(0);
|
||
|
return n < 10 ? `0${t}` : `${t}`;
|
||
|
};
|
||
|
|
||
|
const pendorClock = () => {
|
||
|
const theDiv: HTMLSpanElement = document.getElementById("pendordate")!;
|
||
|
let timer = 0;
|
||
|
|
||
|
const update = () => {
|
||
|
const now = new Date();
|
||
|
const days =
|
||
|
aiMonths[now.getMonth()]! +
|
||
|
now.getDate() +
|
||
|
(now.getMonth() > 2 && now.getUTCFullYear() % 4 === 0 ? 1 : 0);
|
||
|
const tHours = days * 24 + now.getHours() - 16;
|
||
|
const tSeconds = (now.getSeconds() + now.getMinutes() * 60) / 2.25;
|
||
|
const [doy, hours, year, minutes, seconds] = [
|
||
|
tHours / 30,
|
||
|
tHours % 30,
|
||
|
now.getUTCFullYear() - 1884,
|
||
|
tSeconds / 40,
|
||
|
tSeconds % 40,
|
||
|
];
|
||
|
const mIndex = aiPendor.findIndex((k) => k > doy);
|
||
|
const dayOfMonth = doy - aiPendor[mIndex - 1]!;
|
||
|
const dayOfWeek = (Math.ceil(dayOfMonth) - 1) % 6;
|
||
|
theDiv.innerHTML = `${asWNames[dayOfWeek]!}, ${asMNames[mIndex - 1]!} ${dayOfMonth.toFixed(
|
||
|
0
|
||
|
)}, 00${year.toFixed(0)}, ${p(hours)}:${p(minutes)}:${p(seconds)}`;
|
||
|
window.clearTimeout(timer);
|
||
|
timer = window.setTimeout(update, 1250);
|
||
|
};
|
||
|
|
||
|
timer = window.setTimeout(update, 125);
|
||
|
};
|
||
|
|
||
|
window.addEventListener("load", pendorClock);
|