From c84417fc666aca6f7b745e43652bb01f5a623d25 Mon Sep 17 00:00:00 2001 From: zlax Date: Wed, 12 Jun 2024 11:22:53 +0300 Subject: [PATCH] erisian time calculation algorithm is accelerated several times faster --- README.md | 2 +- dtime.js | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 2793983..68f1b96 100644 --- a/README.md +++ b/README.md @@ -9,4 +9,4 @@ https://en.wikipedia.org/wiki/Discordian_calendar Discordian time is the decimal time without time zones, where the beginning of the day coincides with the beginning of the Christian winter day on Easter Island (UTC-5): -https://en.wikipedia.org/wiki/Decimal_time +https://discordia.fandom.com/wiki/Erisian_Time \ No newline at end of file diff --git a/dtime.js b/dtime.js index 3fb8991..e323c27 100644 --- a/dtime.js +++ b/dtime.js @@ -92,17 +92,15 @@ function dtime(gregorianDate,resultar="default") { } else { var ddatestr = M+" "+az(D)+", "+Y+" YOLD"; } - var h = date.getUTCHours(); - var m = date.getUTCMinutes(); - var s = date.getUTCSeconds(); - var ms = date.getUTCMilliseconds(); - var e = h*3600000+m*60000+s*1000+ms; - var ds = Math.round(e/864); - h = Math.floor(ds/10000); + + var christianMSDay = date.valueOf() % 86400000; + var ds = (1 / (864 / christianMSDay)); + var h = Math.floor(ds/10000); ds%= 10000; - m = Math.floor(ds/100); + var m = Math.floor(ds/100); ds%= 100; - s = ds; + var s = Math.floor(ds); + switch (resultar) { case "shortsec": return [ddatestr, h+":"+az(m), ":"+az(s), ddaystr];