-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
193 lines (155 loc) · 6.9 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
190
191
192
193
<!DOCTYPE html>
<html>
<head>
<title>Planck Clock</title>
</head>
<style>
table {
border-collapse:collapse;
margin-left: auto;
margin-right: auto;
}
td {
padding: 4px;
}
</style>
<script type = "text/javascript" src = "js/MathContext.js"></script>
<script type = "text/javascript" src = "js/BigDecimal.js"></script>
<script type = "text/javascript" src = "js/biginteger.js"></script>
<script type="text/javascript">
function timeToString(bigTime, secQ = true, short = false, coloroverride = false) {
timeString = bigTime.toString(16);
if (bigTime < 0) timeString = timeString.substring(1, timeString.length);
year = date = minute = second = "";
if (timeString.length >= 43) {
year = "<small>" + timeString.substring(timeString.length - 44, timeString.length - 42) + "</small> ";
}
if (timeString.length >= 41) {
date = "<big>" + timeString.substring(timeString.length - 42, timeString.length - 40) + "</big>:";
}
if (timeString.length >= 39) {
minute = "<big>" + timeString.substring(timeString.length - 40, timeString.length - 38) + "</big> ";
}
if (secQ && timeString.length >= 37) {
if (!short || date == "") {
second = "<small>" + timeString.substring(timeString.length - 38, timeString.length - 36) + "</small>";
} else {
second = "<small><font style = \"opacity: .0\">00</font></small>"
}
}
result = year + date + minute + second;
if ((result == "") || (result == "<small>-</small>")) result = "<big>0</big>";
return result;
}
function fullTimeToString(bigTime) {
timeString = bigTime.toString(16);
era = "<small>" + timeString.substring(timeString.length - 51, timeString.length - 48) + "</small> ";
age = "<small>" + timeString.substring(timeString.length - 48, timeString.length - 44) + "</small> ";
year = "<small>" + timeString.substring(timeString.length - 44, timeString.length - 42) + "</small> ";
date = "<big>" + timeString.substring(timeString.length - 42, timeString.length - 40) + "</big>:";
minute = "<big>" + timeString.substring(timeString.length - 40, timeString.length - 38) + "</big> ";
second = "<small>" + timeString.substring(timeString.length - 38, timeString.length - 36) + "</small>";
return era + age + year + date + minute + second;
}
function bigTime(today) {
var b = BigInteger.parse(String(today.getTime()));
b = b.multiply(new BigDecimal("1.85488921611077614362073522501613984835872810662879E40"));
b = b.add(new BigDecimal("8071833529780809902742760646451040575040216335127996084558318"));
return b;
}
function time(today, subsec = true) {
return '<font size = "2" face = "courier">' + timeToString(bigTime(today), subsec, false, true) + '</font>';
}
function fulltime(today) {
return '<font size = "10" face = "courier">' +
fullTimeToString(bigTime(today)) +
' <font size = "-1">·10<sup>24</sup> ± 2·10<sup>30</sup></font>' +
'</font>';
}
function diff(today, coloroverride = false) {
return '<font size = "2" face = "courier">' +
timeToString(bigTime(today).subtract(bigTime(new Date())), true, true, coloroverride) +
'</font>';
}
function diff2(date1, date2, coloroverride = false) {
return '<font size = "2" face = "courier">' +
timeToString(bigTime(date2).subtract(bigTime(date1)), true, true, coloroverride) + '</font>';
}
function fraction(date1, date2) {
result = '<font size = "2" face = "courier">';
if (date1 <= new Date() && new Date() < date2) {
result += '.';
duration = bigTime(date2).subtract(bigTime(date1));
passedDuration = bigTime(new Date()).subtract(bigTime(date1));
result += '<big><b>' +
passedDuration.multiply(4096).divide(duration).add(4096).toString(16).substring(1, 4) +
'</big>';
} else if (date1 > new Date()) {
result += 'future';
} else {
result += 'past';
}
result += '</font>';
return result;
}
function event(name, dateBegin, dateEnd) {
rightAlignSeparator = "</td><td style = 'text-align: right;'>";
nameStyle = "";
color = "white";
if (dateBegin < new Date() && new Date() < dateEnd) {
color = "#CEDDA4";
rightAlignSeparator += "<b>";
nameStyle += "<b>";
}
if (dateEnd < new Date()) {
nameStyle += "<font color = \"gray\">";
rightAlignSeparator = "</td><td style = 'text-align: right;'><font color = \"gray\">";
}
coloroverride = false;
if (dateEnd < new Date()) coloroverride = true;
return "<tr bgcolor = " +
color +
"><td>" +
nameStyle +
name + rightAlignSeparator +
time(dateBegin, false) + rightAlignSeparator +
time(dateEnd, false) + rightAlignSeparator +
diff(dateBegin, coloroverride) + rightAlignSeparator +
diff(dateEnd, coloroverride) + rightAlignSeparator +
fraction(dateBegin, dateEnd) + rightAlignSeparator +
diff2(dateBegin, dateEnd, true) +
"</td></tr>";
}
// month should start with 1, i.e., for January, month = 1, as is conventional.
function dateFromUTC(year, month, day, hour = 0, minute = 0, second = 0) {
return new Date(Date.UTC(year, month - 1, day, hour, minute, second));
}
function startTime(first) {
if (first) lastUpd = new Date();
ftstrmaxpi = fulltime(new Date());
document.getElementById('curtimemaxpi').innerHTML = ftstrmaxpi;
if (diff(lastUpd).length > 49) first = 1;
var eventTable = "";
eventTable +=
"<tr><td width = '250'>Event</td>" +
"<td width = '100' style = 'text-align: right;'>Begin</td>" +
"<td width = '200' style = 'text-align: right;'>End</td>" +
"<td width = '200' style = 'text-align: right;'>Till Begin</td>" +
"<td width = '200' style = 'text-align: right;'>Till End</td>" +
"<td style = 'text-align: right' width = '200'>Fraction</td>" +
"<td width = '200' style = 'text-align: right;'>Duration</td></tr>";
eventTable += event('COVID-19 Pandemic (estimate)', dateFromUTC(2019, 12, 1, 0, 0), dateFromUTC(2021, 7, 1, 0, 0));
eventTable += "<tr><td></td></tr>";
eventTable += event('M2:SRaSPOT', dateFromUTC(2020, 11, 20, 23, 30), dateFromUTC(2020, 11, 21, 23, 30));
eventTable += event('M3:GSMNP', dateFromUTC(2020, 11, 25, 23, 30), dateFromUTC(2020, 11, 29, 23, 30));
document.getElementById('eventtable').innerHTML = eventTable;
lastUpd = new Date();
t = setTimeout("startTime(0)", 75);
}
</script>
</head>
<body onload = "startTime(1)">
<h1 style = "text-align: center;"><div id = "curtimemaxpi"> </div></h1>
<font size = "3"><table id = "eventtable"> </table></font>
</body>
</html>