$(showLastEditTime);
function showLastEditTime(){
var lastmod, current, suffix = '';
//var cached = document.body.innerHTML.match(/and timestamp (\d+) -->/)
//if (cached) cached = cached[1]
if (lastmod = document.getElementById('lastmod')){
lastmod = parseSigStamp(lastmod.innerHTML.match(/\d[^.]+/)[0]);
current = new Date();
if (window.myTZOffset) current.setHours(current.getHours()-myTZOffset);
}else if (mw.config.get('wgAction') == 'edit' && document.editform){
lastmod = parseTimestamp(document.editform.wpEdittime.value);
current = parseTimestamp(document.editform.wpStarttime.value);
suffix = ' (UTC)';
} else return;
//var ss, mm, hh, dd, msg = ''
var ss = (current - lastmod)/1000;
var mm = Math.floor(ss/60);
var hh = Math.floor(mm/60); mm = mm % 60;
var dd = Math.floor(hh/24); hh = hh % 24;
if (dd>10) hh = 0;
var msg = ' <span style="color:gray; font-size:80%; padding-left:10px"';
+' title="last edited: ' + showDate(lastmod) + suffix + '">( ';
if (dd) msg += (dd? dd + 'd ' :'') + (hh && (dd<10) ? hh + 'h' :'');
else msg +='<span style="color:#333333">' + hh + ':' + zz(mm) + '</span>';
//+ ' ' + document.lastModified
document.getElementById('siteSub').innerHTML += msg + ' )</span>';
}
function parseSigStamp(stamp){ // '05:53, 7 марта 2007' -> date
var s = stamp.split(' ');
var d = new Date();
var month_name = s[2].substring(0,3).toLowerCase();
var month = 'янвфевмарапрмаяиюниюлавгсеноктноядек'.indexOf(month_name);
if (month == -1) month = 'janfebmaraprmayjunjulaugsepoctnovdec'.indexOf(month_name);
if (month == -1) return null;
d.setYear(s[3]);
d.setMonth(month/3);
d.setDate(s[1]);
d.setHours(s[0].substring(0,2));
d.setMinutes(s[0].substring(3,5));
return d;
}
function parseTimestamp(ts){ //20071226220605 -> date
var d = new Date();
d.setYear(ts.substring(0,4));
d.setMonth(ts.substring(4,6)-1);
d.setDate(ts.substring(6,8));
d.setHours(ts.substring(8,10));
d.setMinutes(ts.substring(10,12));
d.setSeconds(ts.substring(12,14));
return d;
}
function showDate(d){ //Date ->
return zz(d.getHours())+':'+zz(d.getMinutes()) + ', ' + d.getDate() + ' '
+'JanFebMarAprMayJunJulAugSepOctNovDec'.substr(d.getMonth()*3, 3)
+ ' ' + d.getFullYear();
}
function zz(n){
return n<10 ? '0'+n : n;
}