From 745110f8c644a2c91dc28a9ba49c484b26e86bd0 Mon Sep 17 00:00:00 2001 From: zlaxy Date: Wed, 4 Mar 2020 17:46:16 +0300 Subject: [PATCH] Easter Island winter time binding and separating of files --- README.md | 10 ++- dtime.css | 31 +++++++++ dtime.js | 125 ++++++++++++++++++++++++++++++++++++ index.html | 185 ++++------------------------------------------------- 4 files changed, 176 insertions(+), 175 deletions(-) create mode 100644 dtime.css create mode 100644 dtime.js diff --git a/README.md b/README.md index ded7149..2793983 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,12 @@ # dtime-js dtime - Erisian (Discordian) time and date -based on REAL-TIME CLOCK by Tiago Madeira \ No newline at end of file +based on REAL-TIME CLOCK by Tiago Madeira + +Discordian date: +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 diff --git a/dtime.css b/dtime.css new file mode 100644 index 0000000..b4dbd02 --- /dev/null +++ b/dtime.css @@ -0,0 +1,31 @@ +* { + margin:0; + padding:0; +} + +html { + width:100%; + height:100%; + position:relative; + background:#f1f1f1; + color:#326f0c; + font-size: 55px; +} + +#wrap { + position:absolute; + text-align:center; + position: absolute; + top: 50%; + left: 50%; + margin-right: -50%; + transform: translate(-50%, -50%); +} + +#ddate { + text-transform:uppercase; +} + +#dtime { + font-size: 305%; +} diff --git a/dtime.js b/dtime.js new file mode 100644 index 0000000..1fb3684 --- /dev/null +++ b/dtime.js @@ -0,0 +1,125 @@ +/* +* https://gitlab.com/zlax/dtime-js +* based on: +* +* REAL-TIME CLOCK (c) 2009 por Tiago Madeira (http://tiagomadeira.com/) +* Idealizado por Santaum (http://santaum.org/) +* +* All Hail Eris! +* +* This program is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +function az(x) { + if (x < 10) + return "0"+x; + return x; +} + +function ly(Y) { + return (Y % 4 == 0 && !(Y % 100 == 0 && Y % 400 != 0)); +} + +function dy(D, M, Y) { + var dm = Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); + if (ly(Y)) { + dm[1] = 29; + } + var d = D; + for (var i = 0; i < M-1; i++) { + d+= dm[i] + } + return d; +} + +function dtime(gregorianDate) { + // Easter Island Winter Time Zone offset (-5*60*60*1000) + var date = new Date(gregorianDate.getTime()-18000000); + + var D = date.getUTCDate(); + var M = date.getUTCMonth()+1; + var Y = date.getUTCFullYear(); + var d = dy(D, M, Y); + var sttiby = 0; + if (ly(Y)) { + if (d == 60) { + sttiby = 1; + } else if (d > 60) { + d--; + } + } + M = Math.floor(d/73); + D = d % 73; + if (D == 0) { + M--; + D = 73; + } + switch (M) { + case 0: + M = "Chaos"; + break; + case 1: + M = "Discord"; + break; + case 2: + M = "Confusion"; + break; + case 3: + M = "Bureaucracy"; + break; + case 4: + M = "Aftermath"; + break; + default: + M = "fnord"; + } + Y+= 1166; + if (sttiby) { + var ddatestr = "St. Tib's Day, "+Y+" YOLD"; + } 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); + ds%= 10000; + m = Math.floor(ds/100); + ds%= 100; + s = ds; + var dtimestr = az(h)+":"+az(m)+":"+az(s); + + return [ddatestr, dtimestr]; +} + +function go() { + var iddate = document.getElementById("ddate"); + var idtime = document.getElementById("dtime"); + // Current date-time with any time zone offset + var ddatetime = new Date(); + ddatetime = dtime(ddatetime); + iddate.innerHTML = ddatetime[0]; + idtime.innerHTML = ddatetime[1]; +} + +window.onload = function() { + go(); + // 1 discordian decimal second = 864 christian milliseconds + setInterval(go, 864); +} diff --git a/index.html b/index.html index 9c46242..6b8cc64 100644 --- a/index.html +++ b/index.html @@ -1,174 +1,11 @@ - - - - - - - -
-

Ative o JavaScript.

-

00:00:00

-
-




- - + + + + + + +
+

Need javascript enabled

+

00:00:00

+
+