Suggestion to display datetimes in local format
[gigi.git] / static / static / localDate.js
1 (function() {
2         function init(){
3                 var elems = document.getElementsByTagName("time");
4                 for(var i = 0; i < elems.length; i++){
5                         elems[i].setAttribute("title", elems[i].textContent);
6                         elems[i].removeChild(elems[i].firstChild);
7                         var t = elems[i].getAttribute("datetime");
8                         elems[i].appendChild(document.createTextNode(new Date(t).toLocaleString(undefined, {timeZoneName: "short",
9                                 year: "numeric",
10                                 month: "2-digit",
11                                 day: "2-digit",
12                                 hour: "2-digit",
13                                 minute: "2-digit",
14                                 second: "2-digit"})
15                                 ));
16                 }
17         }
18         (function(oldLoad) {
19                 if (oldLoad == undefined) {
20                         window.onload = init;
21                 } else {
22                         window.onload = function() {
23                                 init();
24                                 oldLoad();
25                         }
26                 }
27         })(window.onload);
28
29 })();