diff --git a/index.html b/index.html index 8c60c04..bb5ce0e 100644 --- a/index.html +++ b/index.html @@ -174,6 +174,8 @@ const utcs = { "UTC-11" : "-11", "UTC-10" : "-10", "UTC-9" : "-9", "UTC+10" : "10", "UTC+11" : "11" }; var buttons = ""; var counter = 0; +var nextholiday = false; +var currentholiday = false; for (var u in utcs) { counter += 1; buttons += '"; - stringout += '' + formatedDate(ve[cy], timeoutput, UTC) + ""; + stringout += '' + formatedDate(Imbolc, timeoutput, UTC) + ""; + stringout += '' + formatedDate(ve[cy], timeoutput, UTC) + ""; var Beltane = new Date(ve[cy].getTime() + ((ns[cy].getTime() - ve[cy].getTime()) / 2)); - stringout += '' + formatedDate(Beltane, timeoutput, UTC) + ""; - stringout += '' + formatedDate(ns[cy], timeoutput, UTC) + ""; + stringout += '' + formatedDate(Beltane, timeoutput, UTC) + ""; + stringout += '' + formatedDate(ns[cy], timeoutput, UTC) + ""; var Lughnasadh = new Date(ns[cy].getTime() + ((ae[cy].getTime() - ns[cy].getTime()) / 2)); - stringout += '' + formatedDate(Lughnasadh, timeoutput, UTC) + ""; - stringout += '' + formatedDate(ae[cy], timeoutput, UTC) + ""; + stringout += '' + formatedDate(Lughnasadh, timeoutput, UTC) + ""; + stringout += '' + formatedDate(ae[cy], timeoutput, UTC) + ""; var Samhain = new Date(ae[cy].getTime() + ((ss[cy].getTime() - ae[cy].getTime()) / 2)); - stringout += '' + formatedDate(Samhain, timeoutput, UTC) + ""; - stringout += '' + formatedDate(ss[cy], timeoutput, UTC) + ""; - return stringout; + stringout += '' + formatedDate(Samhain, timeoutput, UTC) + ""; + stringout += '' + formatedDate(ss[cy], timeoutput, UTC) + ""; + + if (cy == now.getFullYear()) { + var wheeldaystime = [ ss[cy-1].getTime(), Imbolc.getTime(), ve[cy].getTime(), Beltane.getTime(), + ns[cy].getTime(), Lughnasadh.getTime(), ae[cy].getTime(), Samhain.getTime(), + ss[cy].getTime(), ve[cy+1].getTime()] + var wheeldays = [ "prev", "im", "os", "be", "ku", "lu", "ma", "sa", "yu", "next" ] + Number.prototype.isBetween = function (a, b) { + return a <= this && this <= b; + }; + for (let i = 1; i < 10; i++) { + if ((Date.now()).isBetween(wheeldaystime[i-1], wheeldaystime[i])) + nextholiday = i; + } + if ((wheeldaystime[nextholiday] - (Date.now())) < 86400000) + currentholiday = wheeldays[nextholiday]; + if (((Date.now()) - wheeldaystime[nextholiday-1]) < 43200000) + currentholiday = wheeldays[nextholiday-1]; + nextholiday = wheeldays[nextholiday]; + } + + return stringout; } function makeTable(UTC, timeoutput) { @@ -275,8 +297,9 @@ function makeTable(UTC, timeoutput) { for (var i = 1; i <= 15; i++) { var currentyear = (now.getFullYear() - 8 + i); if (currentyear == now.getFullYear()) fulltable += ''; - else if (i % 2 == 0 ) fulltable += ''; - else fulltable += '' + else if (currentyear == (now.getFullYear() + 1)) fulltable += ''; + else if (i % 2 == 0 ) fulltable += ''; + else fulltable += '' fulltable += tableRow(currentyear, timeoutput, UTC) + ""; } @@ -308,6 +331,12 @@ function makeTable(UTC, timeoutput) {