X-Git-Url: https://code.wpia.club/?p=gigi.git;a=blobdiff_plain;f=static%2Fstatic%2FlocalDate.js;fp=static%2Fstatic%2FlocalDate.js;h=09358101ce71a3dc4982a589a8af59e29afb9b61;hp=0000000000000000000000000000000000000000;hb=2e2a2b842beac5c70b53ae379e97c8a1e688e12f;hpb=0e10cd72dd03e30a7e1f56387982bbf51a2aebbe diff --git a/static/static/localDate.js b/static/static/localDate.js new file mode 100644 index 00000000..09358101 --- /dev/null +++ b/static/static/localDate.js @@ -0,0 +1,29 @@ +(function() { + function init(){ + var elems = document.getElementsByTagName("time"); + for(var i = 0; i < elems.length; i++){ + elems[i].setAttribute("title", elems[i].textContent); + elems[i].removeChild(elems[i].firstChild); + var t = elems[i].getAttribute("datetime"); + elems[i].appendChild(document.createTextNode(new Date(t).toLocaleString(undefined, {timeZoneName: "short", + year: "numeric", + month: "2-digit", + day: "2-digit", + hour: "2-digit", + minute: "2-digit", + second: "2-digit"}) + )); + } + } + (function(oldLoad) { + if (oldLoad == undefined) { + window.onload = init; + } else { + window.onload = function() { + init(); + oldLoad(); + } + } + })(window.onload); + +})();