erisian time calculation algorithm is accelerated several times faster

This commit is contained in:
ivan 2024-06-12 11:22:53 +03:00
parent 5657b28280
commit c84417fc66
2 changed files with 8 additions and 10 deletions

View File

@ -9,4 +9,4 @@ https://en.wikipedia.org/wiki/Discordian_calendar
Discordian time is the decimal time without time zones, where the Discordian time is the decimal time without time zones, where the
beginning of the day coincides with the beginning of the Christian beginning of the day coincides with the beginning of the Christian
winter day on Easter Island (UTC-5): winter day on Easter Island (UTC-5):
https://en.wikipedia.org/wiki/Decimal_time https://discordia.fandom.com/wiki/Erisian_Time

View File

@ -92,17 +92,15 @@ function dtime(gregorianDate,resultar="default") {
} else { } else {
var ddatestr = M+" "+az(D)+", "+Y+" YOLD"; var ddatestr = M+" "+az(D)+", "+Y+" YOLD";
} }
var h = date.getUTCHours();
var m = date.getUTCMinutes(); var christianMSDay = date.valueOf() % 86400000;
var s = date.getUTCSeconds(); var ds = (1 / (864 / christianMSDay));
var ms = date.getUTCMilliseconds(); var h = Math.floor(ds/10000);
var e = h*3600000+m*60000+s*1000+ms;
var ds = Math.round(e/864);
h = Math.floor(ds/10000);
ds%= 10000; ds%= 10000;
m = Math.floor(ds/100); var m = Math.floor(ds/100);
ds%= 100; ds%= 100;
s = ds; var s = Math.floor(ds);
switch (resultar) { switch (resultar) {
case "shortsec": case "shortsec":
return [ddatestr, h+":"+az(m), ":"+az(s), ddaystr]; return [ddatestr, h+":"+az(m), ":"+az(s), ddaystr];