92 lines
2.2 KiB
HTML
92 lines
2.2 KiB
HTML
<!doctype html>
|
|
<html>
|
|
<head>
|
|
<title>Arbitrary time systems</title>
|
|
<style>
|
|
html, body {
|
|
background-color: #000;
|
|
color: #fff;
|
|
font-family: "Consolas", monospace;
|
|
height: 100vh;
|
|
margin: 0;
|
|
padding: 0;
|
|
width: 100vw;
|
|
}
|
|
|
|
table {
|
|
font-size: 3vw;
|
|
margin: 0 auto;
|
|
}
|
|
|
|
td {
|
|
padding: 2rem;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div>
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>System</th>
|
|
<th>Value</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<tr>
|
|
<td>Actual time</td>
|
|
<td id="actual_time">Now</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Base 62 ISO</td>
|
|
<td id="base62_time">Now</td>
|
|
</tr>
|
|
<tr>
|
|
<td>Percentage of year, day</td>
|
|
<td id="percentage_time">Now</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<script>
|
|
const base62 = [];
|
|
const startOfYear = new Date();
|
|
startOfYear.setMonth(0, 1);
|
|
startOfYear.setHours(0, 0, 0);
|
|
|
|
const startOfDay = new Date();
|
|
startOfDay.setHours(0, 0, 0);
|
|
|
|
const cap = "A".charCodeAt(0);
|
|
const low = "a".charCodeAt(0);
|
|
for (let i = 0; i < 26; i++) {
|
|
base62[i] = String.fromCharCode(cap + i);
|
|
base62[i + 26] = String.fromCharCode(low + i);
|
|
if (i < 10) {
|
|
base62[i + 52] = i;
|
|
}
|
|
}
|
|
|
|
function getTimes() {
|
|
const now = new Date();
|
|
document.getElementById("actual_time").textContent = now.toString();
|
|
|
|
const base62d = base62[now.getDate()];
|
|
const base62m = base62[now.getMonth()];
|
|
const base62y = `${base62[Math.floor(now.getFullYear() / 62)]}${base62[now.getFullYear() % 62]}`;
|
|
const base62h = base62[now.getHours()];
|
|
const base62mi = base62[now.getMinutes()];
|
|
const base62s = base62[now.getSeconds()];
|
|
document.getElementById("base62_time").textContent = `${base62y}-${base62m}-${base62d} ${base62h}:${base62mi}:${base62s}`;
|
|
|
|
const daysPerYear = now.getFullYear() % 4 == 0 ? 366 : 365;
|
|
const pery = (now.getTime() - startOfYear.getTime()) / (daysPerYear * 24 * 60 * 60 * 10);
|
|
const perd = (now.getTime() - startOfDay.getTime()) / (24 * 60 * 60 * 10);
|
|
document.getElementById("percentage_time").textContent = `${pery.toFixed(2)}%, ${perd.toFixed(2)}%`;
|
|
}
|
|
|
|
getTimes();
|
|
setInterval(getTimes, 500);
|
|
</script>
|
|
</body>
|
|
</html> |