Last active
January 2, 2023 23:57
-
-
Save starlilyth/5113036a6a7fbe51ea0861254c822010 to your computer and use it in GitHub Desktop.
Current Stardate webpage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en-US"> | |
<head> | |
<meta charset="utf-8" /> | |
<title>Current Stardate</title> | |
<style> | |
body { | |
margin: 0px; | |
padding-top: 25%; | |
color: white; | |
background-color: darkblue; | |
font-family: Arial, sans-serif; | |
} | |
p { | |
text-align: center; | |
font-size: small; | |
} | |
.datebox { | |
display: flex; | |
justify-content: center; | |
align-items: center; | |
height: 20vh; | |
font-size: 10vw; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="datebox"> | |
<h1 id="stardate"></h1> | |
</div> | |
<p>Current Stardate</p> | |
<script> | |
// math from https://trekguide.com/Stardates.htm | |
function starDateNow (timeNow) { | |
var StardateOriginToday = new Date("July 15, 1987 00:00:00"); | |
var stardateToday = timeNow - StardateOriginToday.getTime(); | |
stardateToday = stardateToday / (1000 * 60 * 60 * 24 * 0.036525); | |
stardateToday = Math.floor(stardateToday + 410000); | |
stardateToday = stardateToday / 10 | |
document.getElementById("stardate").innerHTML = stardateToday; | |
} | |
window.onload = starDateNow (Date.now()); | |
setInterval( function () { | |
starDateNow (Date.now()); | |
}, 60 * 1000); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Such easy to read code lily! Thanks for sharing it.