MediaWiki:EthTime.js: Difference between revisions

From Thorildsby Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 19: Line 19:
     }  
     }  
     catch (error) {
     catch (error) {
         //lol
         try {
            if (ethTimeLinkedDiv.innerHTML != null) ethTimeLinkedDiv.innerHTML = result +
                "<a href=\"https://thorildsby.com/index.php?title=%C4%90-Time\">Ð</a>";
        }
        catch (error2) {
            //LOL
        }
     }
     }
    if (ethTimeLinkedDiv.innerHTML != null) ethTimeLinkedDiv.innerHTML = result +
        "<a href=\"https://thorildsby.com/index.php?title=%C4%90-Time\">Ð</a>";
}());
}());

Revision as of 06:33, 6 October 2025

$(function () {
    var ethTimeDiv = document.getElementById('eth-time');
    var ethTimeLinkedDiv = document.getElementById('eth-time-linked');
    const now = new Date();
    const year = now.getUTCFullYear();

    var result = year - 2000;
    var decimal = Math.ceil((now - new Date(year,0,1)) / 86400000);

    decimal = decimal/((year % 4 == 0 && year % 100 != 0) || year % 400 == 0? 366 : 365);

    result += decimal;
    result *= 100;
    result = Math.round(result);
    result /= 100;

    try {
        if (ethTimeDiv.innerHTML != null) ethTimeDiv.innerHTML = result + "Ð";
    } 
    catch (error) {
        try {
            if (ethTimeLinkedDiv.innerHTML != null) ethTimeLinkedDiv.innerHTML = result + 
                "<a href=\"https://thorildsby.com/index.php?title=%C4%90-Time\">Ð</a>";
        }
        catch (error2) {
            //LOL
        }
    }
}());