-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
189 lines (159 loc) · 6.06 KB
/
index.html
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>currentmilli</title>
<style>
html {
font-family: sans-serif;
color: #222;
font-weight: lighter;
padding: 1rem;
}
h1,
h2,
h3 {
font-weight: lighter;
}
p {
font-weight: 300;
}
output {
font-size: 1.25rem;
}
label {
font-size: 1rem;
color: #666;
}
.spin:hover {
rotate: 15deg;
}
</style>
<!-- Cloudflare Web Analytics -->
<script defer src="https://static.cloudflareinsights.com/beacon.min.js" data-cf-beacon='{"token": "32874c41646546228187987b520ec49a"}'></script>
<!-- End Cloudflare Web Analytics -->
</head>
<body style="min-width: 280px">
<div style="position: absolute; right: 40px; top: 40px">
<a href="https://github.com/nchudleigh/currentmilli" title="currentmilli repository" target="_blank" style="text-decoration: none">
<img src="/github.svg" alt="" class="spin" aria-hidden />
</a>
</div>
<header style="margin: 3rem 0">
<h1 style="margin: 0"><span aria-hidden="true">∲</span> currentmilli</h1>
<h2 style="font-size: 1.25rem; margin: 0.5rem 0 0 0">
A simple website to help with time
</h2>
<p style="margin: 0.25rem 0">
Put a desired timestamp, year or date string into the path.
</p>
<p>https://currentmilli.com/<right here my friend🙃></p>
<div style="margin-top: 1rem">
<label title="The time in Unix epoch time. The number of milliseconds since January 1st 1970">
Epoch
</label>
<br />
<a href="/741398400000"> /741398400000 </a>
</div>
<div style="margin-top: 1rem">
<label> ISO-8601 </label>
<br />
<a href="/2000-01-20T12:34:56.777Z"> /2000-01-20T12:34:56.777Z </a>
</div>
<div style="margin-top: 1rem">
<label for="iso8601"> Date </label>
<br />
<a href="/1987-08-27"> /1987-08-27 </a>
</div>
</header>
<!-- Output -->
<div style="border: 1px solid #ccc; padding: 1rem">
<div style="height: 17px">
<a id="resume" href="/">Resume</a>
</div>
<span style="color: #ccc">var now = new Date(<span id="path-value"></span>)</span>
<div style="margin-top: 1rem">
<label for="human-local"> For Humans (Local) </label>
<output id="human-local" title="Human readable in your timezone" style="display: block; margin-top: 0.25rem" onclick="setPathValue()">
...
</output>
<span style="color: #ccc">now.toString()</span>
</div>
<div style="margin-top: 1rem">
<label for="human"> For Humans (UTC) </label>
<output id="human" title="Human readable in UTC" style="display: block; margin-top: 0.25rem" onclick="setPathValue()">
...
</output>
<span style="color: #ccc">now.toUTCString()</span>
</div>
<div style="margin-top: 1rem">
<label for="epoch" title="The time in Unix epoch time. The number of milliseconds since January 1st 1970">
Epoch (UTC)
</label>
<output id="epoch" style="display: block; margin-top: 0.25rem" onclick="setPathValue()">
...
</output>
<span style="color: #ccc">now.getTime().toString()</span>
</div>
<div style="margin-top: 1rem">
<label for="iso8601"> ISO-8601 (UTC) </label>
<output id="iso8601" title="The time in ISO-8601 format" style="display: block; margin-top: 0.25rem" onclick="setPathValue()">
...
</output>
<span style="color: #ccc">now.toISOString()</span>
</div>
</div>
</body>
<script>
var epochElement = document.getElementById("epoch");
var iso8601Element = document.getElementById("iso8601");
var humanElement = document.getElementById("human");
var humanLocalElement = document.getElementById("human-local");
var resumeElement = document.getElementById("resume");
var pathValueElement = document.getElementById("path-value");
const REFRESH_RATE_MS = 333;
function getPathValue() {
const result = window.location.pathname.slice(
1,
window.location.pathname.length
);
// Attempt to cast to number
const numericResult = Number(result);
// If numeric result is NaN, return the value string
if (numericResult.toString() == "NaN") return result;
// Range for year-only input 🗿
else if (numericResult >= 0 && numericResult < 3000) return result;
// Is probably epoch, return as number
else return numericResult;
}
var pathValue = getPathValue();
function setPathValue() {
if (pathValue) return;
window.location = new Date().getTime().toString();
}
function render() {
if (pathValue) var now = new Date(pathValue);
else var now = new Date();
var epoch = now.getTime().toString();
var iso8601 = now.toISOString();
var human = now.toUTCString();
var humanLocal = now.toString();
if (pathValue) {
resumeElement.innerHTML = "Resume";
} else {
resumeElement.innerHTML = "Pause";
resumeElement.href = "/" + epoch;
}
epochElement.innerHTML = epoch;
iso8601Element.innerHTML = iso8601;
humanElement.innerHTML = human;
humanLocalElement.innerHTML = humanLocal;
pathValueElement.innerHTML = pathValue;
}
render();
// If there is not a set date, render the current time on an interval
if (!pathValue) setInterval(render, REFRESH_RATE_MS);
</script>
</html>