User:Where/commentLocalize.js

//Localized time/date script function numToMonth(num) { if (num==0) {return "January";} else if (num==1) {return "February";} else if (num==2) {return "March";} else if (num==3) {return "April";} else if (num==4) {return "May";} else if (num==5) {return "June";} else if (num==6) {return "July";} else if (num==7) {return "August";} else if (num==8) {return "September";} else if (num==9) {return "October";} else if (num==10) {return "November";} else if (num==11) {return "December";} } function monthToNum(month) { var tmp = new Date(month + " 1, 2006"); return tmp.getMonth; } function adjustTime(str, hour, minute, day, month, year, offset, s) { var time = new Date; time.setUTCHours(hour); time.setUTCMinutes(minute); time.setUTCDate(day); time.setUTCMonth(monthToNum(month)); time.setUTCFullYear(year); var timeStr = ""; if (time.getHours<10) {timeStr += "0";} timeStr += parseInt(time.getHours) + ":"; if (time.getMinutes<10) {timeStr += "0";} timeStr += parseInt(time.getMinutes); timeStr += ", "; timeStr += time.getDate; timeStr += " "; timeStr += numToMonth(time.getMonth); timeStr += " "; timeStr += time.getFullYear; timeStr += " (UTC"; var offset = -1*time.getTimezoneOffset/60; if (offset >= 0) {timeStr += "+";} timeStr += offset + ")"; return timeStr; } function adjustTime2(str, hour, minute, month, day, year, offset, s) { return adjustTime(str, hour, minute, day, month, year, offset, s); } $(function { if (document.title.indexOf("Editing ") == 0) { return; } if (document.title.indexOf("Edit conflict") == 0) { return; } if (document.location.href.indexOf("action=history") != -1) { return; } if (document.title.indexOf("Talk:") == 0 || document.title.indexOf("talk:") != -1 || document.title.indexOf("Wikipedia:") == 0) { var newDoc = document.getElementById("column-content").innerHTML.replace(/(\d\d):(\d\d), (\d{1,2}) ([A-Z][a-z]+) (\d{4}) \(UTC\)/g, adjustTime); document.getElementById("column-content").innerHTML = newDoc; } /*  if (document.location.href.indexOf("&action=history") != -1) { var newDoc = document.body.innerHTML.replace(/(\d\d):(\d\d), ([A-Z][a-z]+) (\d{1,2}), (\d{4})/g, adjustTime2); document.getElementById("bodyContent").innerHTML = newDoc; }*/ }); //User:Where/commentLocalize