<!DOCTYPE html>
<!-- https://gitlab.com/zlax/solarwheeloftheyear -->
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!--
                                                                      ;
                                                                      ;=
                                                                      .=;                    .X
                                                                       ...                   ;;.
                                                                       ; .;                  ;.=
                                                 ==                    =. =                  . ;
                                      .           X=.                  ;.  =                 = ;.
                                      +           .;;;                 ..  .;               ..  .
                                      +.           ;..;                 .   =                   =
                                      X;           .; .=                =   .;              =   =.                 .
                                      =;;           ;. .+.              =    =              ;   .                 .=
                                      ; ;            =   =.             =     X            =     ;                ;;
                                      .;.;           ;.   ;.            =     ..           ;     =                ;;
                                       = =            ;    =.           =      ;          ;.     =               = ;
                                       + .=           =     =.          =      ;;         ;      .              .. ;
                                       ;  .;           =     =.         =       =        .;       .             = .;
                                       ;   =           =     .=         =       ;        ;       .;            .. ;=
                                       ;.   =          ;.      ;        .       .=       ;       .;            =  ;.
                                        =   .=         .=      .;      ..        ;      =        .+           ;   ;
                                        =    .;         ;       ;;     ..        ;.    .;        .X          ;.
                                        ;     ;.        =.       =     ;.        .;    ;.        .X         ;;    ;
                      .                 =.     .;       ..       .=    =.         +    =          =        .;     +
                       +.               ..      .;       ;        .    ;          +   ;.          ;       .=      =
                       .+.               =       .;      =         ;   ;          ;   =           +      ;.       .
                        ;;               +        .;     X         .;  ;           =  =          .X     ;.       =
                         ;...            ..        .+    ;          =  ;           X .           .+    =.        X
                          ; ..            =          +   .          .. ;           ; +           .;   ;.         ;
                          .; .;           ;          .;   ;          X ;           ; ;           .;   ;         ..
                           .. ...         ;.          .;  +          .;;           . .           .   ;          =.                .;;
                            ;   ;;         ;           ;; ;           ==.          ;=;           =  =           ;              ;;.;=.
                            ;.    ;;       =            = ;.          =;.          ;=            X ;.          .;           .+.   =.
                             ;     .=.     ;.            ;.;          .=.          ;=            ;..           .         ..;     =
                             ..      =+     =            .;;           +.          ;=           ..=            =       ...      =
                              ;       .=;   ;             .+.          ;.          ;=           +=            ..     .=.       =.
                              ;.        =;   ;             X.           +          ;=           =;            =    .;.        .;
                               ;         .=  ;             ;+           +          ;.          ;+            ;.   =.          =
            =                  ..          +  ;             =           ;          ;.          ;=            ;   =           =
            ;;                  ;           =.;              =          .;                     =            .; ..           =
             .;                  ;           ;.;             ;          .X                     =            + =;           .;
             ; =.                ..           ;=.            .=                               +            ; ..           .+
              ; ;.                =            =X             =.                              ;           .=;             +
              .  .=               ;.            ;;            .                                           X;             ;.
              .;   ;;.             ;             =.                                                      ;+              =
               ;     ; ;            ;             =.                                                    .+              =                   ==;;;
                =      ;.=.         .;             =                        ;;;;;                       +              =.           ;;+=; ;;;..=.
                ..         == .      ..             =                 .;+M##########M;;.               +              ..       .;;X=.       .=;
                 ;.           ;=.;    ;             .=              ;X###M++++==++++M##M+;.==.        ;.             .=     ..=..          ;=
                  =              ..=.  ;             .            =M##X=;...........;==+M#M##=                       =   .= .            .;.
                   ;                .;. ;                       =##M+.................;M#####+                     .= .;=               ;=
                    ;                 .;..                    ;M##+.................=X########+                   .=; ;               .=.
                     ;                  .+=                  =M#M;.................X###########M.                .X..                .;
                      ;                   =+                X#M=.................+#############M#=              =X.                 =;
                       ;                   .+.             X#M;................=M##############=M#;            =;                 .;.
                        =                    ==           M#M................;X################X;MM;         .+.                 .=
                         =.                   .          X#M................+###M#=############X..M#;       .=                  .=
                          .=                            +#M................X###MM#+#############..;M#.                         .=
                            =;                         ;##;...............+####=#M=#############...;#M                        ;;
                             .=                        M#=................X###.;#==#############;...;#+                      ;.
                               =;                     +#X.................###X X#=X#############.....X#.                    =.
                                .==                  .MM=................X###M.## X############M.....;#+                  .;
                                   .;.               M#X..........;=;.;X######X#X X############X......X#.                ;.
                        .. ;;;;=+X;;====..          .##........;XM###M##########X X############+......;#X              ;=   ...=;;;;.....
                    ;..=;;             .=+.         X#X......;X##################.X############........M#.           ;;=; ;==;..    ..;.+=;.;;
                 ;= ;.                             .##;.....XM###################XM###########=........;#=         .++.;                    ;;.;=+=;.
              .+;.                                 =#M....=M############;+#M#################X..........MX      .;X..                            ... .;+X=
           ..=.                                    X#+..;M##############X;#XX###############X=..........=#.    .=                                    ;;;
         ;=.                                      .M#.;M################M.X#==#############X;X..........;#=                                       .+..
        =                                         .##X###################;;#X.;XM########M=.=+...........MX                                     .;;
     .=.                                          .#####M#M##############=.X#+...=X##XXX=...==...........X#.                                  .;.
     ;.;.  .=X;.                                  M####+MM+##############X.;#MX+...;X;......=+...........X#;                                .=.
                ==..                             X####M;#=X##############X..;++XX...X;......;+.......+...X#;                             ..X
                   .=.;;                        =#####=;#.M##############+......=.;+=........X=.....+=...X#;                           ;.;
                       .; .;;;;;;;;;;;+=;       .M####.+M ###############=........X=.......;M#M+=;=X=....X#;                        ==.
                                ..==.             M###+X= ##############M........=M......;+M+#;;+==......X#;                  ..;=+
                             ..;.                 +#####= ##############X.......;X+....;+#M=+#;..........X#;     ;;.;==;;.  ;==.
                           ;.;                    +#####X ##############;..XX+=+M+...;X##M=;+M...........X#;         ...=;
                        .=.                       =######;#############MM+X;;XMX...=M###+=;;MM...........X#;              .=..
                      ;.;                         .#XX###M############+.+=........=###M+;;;=#+...........XM                  ;;.
                    .;.                           .##.=##############+.........=XX###M=;;;;+#+...........MX                    ..;.
                   ;.                              M#;.=M##########M=........;X#####X=;;;;;M#=..........=#=                       .;
                 ;;                                =#+...+X######M+.........;M####M+;;;;;;+##...........+#.                         ..;
                =.                                 ;#M.....;=======........+M###X+;;;;;;;=M#M...........MM                            ..==
              ;=                          .;+       M#=.........=;=X=....;M##M==;;;;;;;;=MM#X..........;#=                                .=+. ...    ....
            .=.                         ;==         =#X.............+X.;+#MX=;;;;;;;;;;+#= M+..........M#.                                    ..=+==;=++;
           .+                         =X=            M#;.............XXX+=;;;;;;;;;;;=X#= =#..........;#X      ==                                    .;.
          ;;                    .. ;;;=              =#X.............=#M+=;;;;;;;;;=+MX. =#;..........X#.        ;X;.                             ..=
         =.       .;===;.==;; .;;. .=                 M#;............;X+M#XX+=;;=+X#X=  +M=..........;#X            =;==                       ;=.;
        =. ;X=..;;;;;;;;;;.       ;;                  ;#M............;=..=M##MMMM#+.  ;MM;...........MM.              .==.;+;             .=+; ;
       +=.;.                     ;.                    X#=...........+;...;=M####;  .+MX;...........=#+                 .=. .;;.  ..;;  ;;;
       .                       ;;                      .MM;.........;M.......;=XMM+MMX;........=...;MX                    .=
                              =.                        ;MM;......;+M;...........;==...........=..;M#                       =;
                             ;.                          ;#M;....++=..........................;;..X#;                        .=
                           .=                             =#M.................................X.;M#=      ;                    ;.
                          .;                  .=           =MM;..............................===##=       ;=                    ;.
                         ;;                  =;             ;#M=.............................X+##;          =.                   ..
                        ..                  =                ;M#X;................+;.......;M##M;            ;;                   ..
                       ;;                 ;;                   +##X;...............++=...=X##M=                =.                  ..
                      ;.                .+.                     ;X##X=..............;=+MM###+.                  =;                  .;
                     =                 ;+.                        .XM#MX;;;.........;;XM#MX.                     ;.=.                .;
                    ;               ..;+                             +X####M+====+MM###X=                         ; ;;;               ;.
                  ;.              ... ;               +.               .;;XX######MX;;.             .              ;  ..=.             ;
                 ;.             ;.   ;               =.                     ......                   =             ;;     ==            =
               .=           ..=.    ;              .+                                                .=             ;.       =;;        ..
              ..         ;; ;      ;               X.                                                 .;             ;         ..;       ;.
            +.     . ;=+          ;               ++                                                   ;;             .            +      ;
          ;.   .;;;;             ;              ..=           .                            .            +=            .              =.   ..
       ;;=;=. ;;                ;.             . ;.          .;                             ;           .;;            ;              .;   ;
      .                         ;             ;  ;           X           +                  ;            ;;=            =               .; ..
                               =            .;  ;           .=          .=         ;         ;            = =.          ..               .= ;
                              ;.          ;;    ;           ==          .;         +         ;.            . ..          ;                 ==.
                              =         .;     =           ..;          =;         X          +            ;  .=          .                 ;=
                             ;       . .       ;           ;            =;         =          =;            ;   =.        =                  =
                            ..     .;.        ;           ..;           .;         =;         .;            .    .=        ;
                            ;    .;           ;           . +          ;.;         .           ;.            ;     =.      .
                           ..   .            ;           =  +          . .         .;          .;            ;      ...     ;
                           ;  .;             ;          ;   ;          . .           .         . .           ..       ;;    ..
                          .. =              ..         .    ;         .  .           ;         ;; =           ;         ;.   =
                          ;.=               =         ;.              ;  =         .  ;         . .;          .           ;;  =
                         .+.                ;        ;.              ..  +         ;  .            ;.          .           ;;  .
                         .                 =        ;.               ;   ;         ;   .        =   ;          =             ;.=
                                           ;       ;.               ..   .         ;   ;.       ;.   ;         ;              .=.
                                          ;       ..                ;              +    ;       ..    .        .;              .+
                                          ;      ;                 .;    ;         ;     ;             .        .                +
                                         =      =                  ;     .;        ;     ;.      ;      .       ;
                                        .      ;                   =      .               ;      ;       .       .
                                       .;    =.             ;      =      .       =        ;     ;        ;.     .
                                       =   ..               ;     ;       ;       =        ;     ;         ;     =
                                      ;  .;                 +     +       =.      .         ;    +          ;    ;
                                     .. ;;                  ;     .       .      ..         ;    X
                                    .==.                         .         .     ;           ;   =                ;
                                   .+.                       .   =         ;                 =   ;            .   +
                                                             =   .         +    .;           ..  ;             ;  .
                                                             ;   .         =    .             ;  ;              ;
                                                                 ;         ;    ;             =                  ;..
                                                              . ;              ..             ..                 ;.=
                                                              . ;              .               =..                =.
                                                                               .               ;;                 .;
                                                              ;.;             =                .;                  +
                                                               .;                              ..
                                                               +X            =                 ;=
                                                                +            .                 .;
                                                                .           .
                                                                           =;
                                                                           .
    -->
    <link rel="icon" href="favicon.ico" type="image/x-icon"><link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
    <link rel="stylesheet" type="text/css" href="anthrstlsht.css">
    <script type="text/javascript" src="dtime.js"></script>
    <script type="text/javascript" src="vernal_equinox.js"></script>
    <script type="text/javascript" src="autumnal_equinox.js"></script>
    <script type="text/javascript" src="southern_solstice.js"></script>
    <script type="text/javascript" src="northern_solstice.js"></script>
    <title>solar wheel of the year</title>
  </head>
  <body>
    <br><p align="center"><input type="button" onclick="document.getElementById('soltable').innerHTML = makeTable(0, 'erisian');" value="Erisian time"/></p>
    <p align="center"><input type="button" onclick="document.getElementById('soltable').innerHTML = makeTable(0, 'auto');" value="Christian time"/>:<br>
  <div align = "center" id="utcbuttons"></div></p>

<script type="text/javascript">

const utcs = { "UTC-11" : "-11", "UTC-10" : "-10", "UTC-9" : "-9",
  "UTC-8" : "-8", "UTC-7" : "-7", "UTC-6" : "-6", "UTC-5" : "-5",
  "UTC-4" : "-4", "UTC-3:30" : "-3.5", "UTC-3" : "-3", "UTC-0" : "0",
  "UTC+1" : "1", "UTC+2" : "2", "UTC+3" : "3", "UTC+3:30" : "3.5",
  "UTC+5" : "5", "UTC+5:30" : "5.5", "UTC+6" : "6", "UTC+6:30" : "6.5",
  "UTC+7" : "7", "UTC+8" : "8", "UTC+9" : "9", "UTC+9:30" : "9.5",
  "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 += '<input type="button" onclick="document.getElementById(' + "'soltable'" + ').innerHTML = makeTable(';
  buttons += utcs[u] + ", '" + u + "');" + '" value="' + u + '"/>'
  if (counter % 5 == 0) buttons += "<br>";
}
document.getElementById("utcbuttons").innerHTML = buttons;

</script>

  <div align = "center" id="soltable"></div><br><div align = "center" id="oneyearrow"></div>

<script type="text/javascript">

function formatedDate(datein, timeoutput, UTC) {
  if (timeoutput == 'erisian') var dateout = dtime(datein, 'timeofyold');
    else {
      var timein = new Date ( datein.getTime() + ( UTC * 60 * 60 * 1000 ));
      var dateout = ("0" + ( timein.getUTCDate())).slice(-2) + "." + ("0" + ( timein.getUTCMonth() + 1)).slice(-2) + " ";
      dateout += ("0" + timein.getUTCHours()).slice(-2) + ":" + ("0" + timein.getUTCMinutes()).slice(-2) + ":" + ("0" + timein.getUTCSeconds()).slice(-2);
      }
  return dateout;
}

function oneyearChange(value) {
  if (timeout == "erisian") outyear = value - 1166;
    else outyear = value;
  document.getElementById("oneyearrow").innerHTML = makeOneYearRow();
}

function makeOneYearRow() {
  var fullrow = "<table><tr>";
  fullrow += tableRow(outyear, timeout, utcoff, true);
  fullrow += "</tr></table>";
  return fullrow;
}

function tableRow(cy, timeoutput, UTC, oneyearinp = false) {
  var stringout = "<td>";
  if (oneyearinp) {
    if (timeoutput == 'erisian') {
      cury = cy + 1166; miny = 1583 + 1166; maxy = 2999 + 1583;
    } else {
      cury = cy; miny = 1583; maxy = 2999;
    }
  stringout += '<input type="number" name="oneyearinput" value="' + cury + '" min="' + miny;
  stringout += '" max="' + maxy + '" step="1" size="5" onchange="oneyearChange(this.value)">';
  } else {
    if (timeoutput == 'erisian') stringout += cy + 1166;
      else stringout += cy;
  }
    var Imbolc = new Date(ss[cy-1].getTime() + ((ve[cy].getTime() - ss[cy-1].getTime()) / 2));
  stringout += '<td class="even im">' + formatedDate(Imbolc, timeoutput, UTC) + "</td>";
  stringout += '<td class="os">' + formatedDate(ve[cy], timeoutput, UTC) + "</td>";
    var Beltane = new Date(ve[cy].getTime() + ((ns[cy].getTime() - ve[cy].getTime()) / 2));
  stringout += '<td class="even be">' + formatedDate(Beltane, timeoutput, UTC) + "</td>";
  stringout += '<td class="ku">' + formatedDate(ns[cy], timeoutput, UTC) + "</td>";
    var Lughnasadh = new Date(ns[cy].getTime() + ((ae[cy].getTime() - ns[cy].getTime()) / 2));
  stringout += '<td class="even lu">' + formatedDate(Lughnasadh, timeoutput, UTC) + "</td>";
  stringout += '<td class="ma">' + formatedDate(ae[cy], timeoutput, UTC) + "</td>";
    var Samhain = new Date(ae[cy].getTime() + ((ss[cy].getTime() - ae[cy].getTime()) / 2));
  stringout += '<td class="even sa">' + formatedDate(Samhain, timeoutput, UTC) + "</td>";
  stringout += '<td class="yu">' + formatedDate(ss[cy], timeoutput, UTC) + "</td>";

  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) {

  if (timeoutput == 'auto') {
    UTC = -(now.getTimezoneOffset()/60);
    Object.keys(utcs).forEach(key => {
      if (UTC == utcs[key]) timeoutput = key;
    })
  }
  utcoff = UTC; timeout = timeoutput;
  var fulltable = "<table><caption>";
  fulltable += 'Accurate (according to <a href="https://www.imcce.fr">IMCCE</a>) astronomical ';
  fulltable += '<a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year">Wheel of the Year</a> - ';
  if (timeoutput == 'erisian') {
      fulltable += '<a href="https://discordia.fandom.com/wiki/Erisian_Time">Erisian time</a></br>';
      window.location.hash = "";
    } else {
      fulltable += '<b>' + timeoutput + '</b> (<a href="https://en.wikipedia.org/wiki/Coordinated_Universal_Time">Coordinated Universal Time</a>)<br>';
      window.location.hash = "#" + timeoutput;
    }
  fulltable += '</caption><tr><th>';
  if (timeoutput == 'erisian') fulltable += 'YOLD';
    else fulltable += 'Gregorian Year';
  fulltable += '</th><th><a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year#Imbolc_(Candlemas)">Imbolc</a></th><th><a';
  fulltable += ' href="https://en.wikipedia.org/wiki/Wheel_of_the_Year#Spring_Equinox_(Ostara)">Ostara</a></th><th>';
  fulltable += '<a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year#Beltane_(May_Eve)">Beltane</a></th><th><a href="https://en.wikipedia.org/wiki/';
  fulltable += 'Wheel_of_the_Year#Summer_Solstice_(Litha)">Kupala</a></th><th><a href="https://en.wikipedia.org/wiki/';
  fulltable += 'Wheel_of_the_Year#Lughnasadh_(Lammas)">Lunasa</a></th><th><a href="https://en.wikipedia.org/wiki/';
  fulltable += 'Wheel_of_the_Year#Autumn_Equinox_(Mabon)">Mabon</a></th><th><a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year#Samhain">';
  fulltable += 'Samhain</a></th><th><a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year#Winter_Solstice_(Yule)">Yule</a></th></tr>';

  if (timeoutput == 'erisian') UTC = 0;

  for (var i = 1; i <= 15; i++) {
    var currentyear = (now.getFullYear() - 8 + i);
    if (currentyear == now.getFullYear()) fulltable += '<tr class = "currentyear">';
    else if (currentyear == (now.getFullYear() + 1)) fulltable += '<tr class = "odd nextyear">';
    else if (i % 2 == 0 ) fulltable += '<tr class = "even">';
    else fulltable += '<tr class = "odd">'
    fulltable += tableRow(currentyear, timeoutput, UTC) + "</tr>";
  }

  fulltable += "</table>";

  document.getElementById("oneyearrow").innerHTML = makeOneYearRow();

  return fulltable;
}

  var now = new Date();
  var utcoff = 0;
  var timeout = "erisian";
  if (window.location.hash.slice(0,4) == "#UTC") {
    if (utcs[window.location.hash.slice(1,9)]) {
      utcoff = utcs[window.location.hash.slice(1,9)]
      timeout = window.location.hash.slice(1,9);
    }
  } else if (window.location.hash.slice(0,5) == "#auto") timeout = "auto";
  var outyear = (now.getFullYear() - 100);
  var defaultTable = makeTable(utcoff, timeout);

  document.getElementById("soltable").innerHTML = defaultTable;

</script>

<br><p align="center"><font size="6">&#9660;</font></a>
<br><a href="https://en.wikipedia.org/wiki/Wheel_of_the_Year"><img id="wheel" src="0.5.0_octosol.png" alt="Octosol by DougInAMug"></a></p>

<script type="text/javascript">

  if (nextholiday == "next") var nextselector = ".nextyear>." + nextholiday;
  else var nextselector = ".currentyear>." + nextholiday;
  if (currentholiday) var curselector = ".currentyear>." + currentholiday;
  document.querySelector(nextselector).style.color = "yellow";
  document.querySelector(curselector).style.color = "red";

  const dayOfYear = date => Math.floor((date - new Date(date.getFullYear(),
                    0, 0)) / (1000 * 60 * 60 * 24));
  var daynumber = dayOfYear(new Date());
  var degree = Math.round((360 / 365) * (daynumber + 10));
  var rotatestring = "rotate(" + degree + "deg)"
  document.getElementById("wheel").style.transform = rotatestring;

</script>

<br><p align="center"><a href="https://gitlab.com/zlax/solarwheeloftheyear">source code</a></p>

  </body>
</html>