Código PHP:
function getFormat() {
var calF = calFormat;
calF = calF.replace(//g, '\\\\');
calF = calF.replace(///g, '\\\/');
calF = calF.replace(/[/g, '\\\[');
calF = calF.replace(/]/g, '\\\]');
calF = calF.replace(/(/g, '\\\(');
calF = calF.replace(/)/g, '\\\)');
calF = calF.replace(/{/g, '\\\{');
calF = calF.replace(/}/g, '\\\}');
calF = calF.replace(/</g, '\\\<');
calF = calF.replace(/>/g, '\\\>');
calF = calF.replace(/|/g, '\\\|');
calF = calF.replace(/*/g, '\\\*');
calF = calF.replace(/?/g, '\\\?');
calF = calF.replace(/+/g, '\\\+');
calF = calF.replace(/^/g, '\\\^');
calF = calF.replace(/$/g, '\\\$');
calF = calF.replace(/dd/i, '\\d\\d');
calF = calF.replace(/mm/i, '\\d\\d');
calF = calF.replace(/yyyy/i, '\\d\\d\\d\\d');
calF = calF.replace(/day/i, '\\w\\w\\w');
calF = calF.replace(/mon/i, '\\w\\w\\w');
return new RegExp(calF);
}
function getDateNumbers(date) {
var y, m, d;
var yIdx = calFormat.search(/yyyy/i);
var mIdx = calFormat.search(/mm/i);
var m3Idx = calFormat.search(/mon/i);
var dIdx = calFormat.search(/dd/i);
y=date.substring(yIdx,yIdx+4)-0;
if (mIdx != -1) {
m=date.substring(mIdx,mIdx+2)-1;
}
else {
var m = getMonthFromName(date.substring(m3Idx,m3Idx+3));
}
d=date.substring(dIdx,dIdx+2)-0;
return new Array(y,m,d);
}
function hideCal() {
calWin.close();
calWin = null;
window.status = "";
}
function getLeftIE(x,m) {
var dx=0;
if (x.tagName=="TD"){
dx=x.offsetLeft;
}
else if (x.tagName=="TABLE") {
dx=x.offsetLeft;
if (m) { dx+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
}
return dx+(x.parentElement.tagName=="BODY"?0:getLeftIE(x.parentElement,m));
}
function getTopIE(x,m) {
var dy=0;
if (x.tagName=="TR"){
dy=x.offsetTop;
}
else if (x.tagName=="TABLE") {
dy=x.offsetTop;
if (m) { dy+=(x.cellPadding!=""?parseInt(x.cellPadding):2); m=false; }
}
return dy+(x.parentElement.tagName=="BODY"?0:getTopIE(x.parentElement,m));
}
function getLeftN4(l) { return l.pageX; }
function getTopN4(l) { return l.pageY; }
function getLeftN6(l) { return l.offsetLeft; }
function getTopN6(l) { return l.offsetTop; }
function lastDay(d) {
var yy=d.getFullYear(), mm=d.getMonth();
for (var i=31; i>=28; i--) {
var nd=new Date(yy,mm,i);
if (mm == nd.getMonth()) {
return i;
}
}
}
function firstDay(d) {
var yy=d.getFullYear(), mm=d.getMonth();
var fd=new Date(yy,mm,1);
return fd.getDay();
}
function dayDisplay(i) {
if (dayDigits == 0) {
return yxDays[i];
}
else {
return yxDays[i].substring(0,dayDigits);
}
}
function calTitle(d) {
var yy=d.getFullYear(), mm=yxMonths[d.getMonth()];
var s;
if (titleMode == 2) {
s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-10)'> «</a> "+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'>‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+yy+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'> ›</a> "+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(10)'>» </a></b>"+span2+"</td></tr><tr align='center' valign='middle'><td align='right'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'> ‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><b>"+span1("title")+mm+span2+"</b></td><td align='left'>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> › </a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
}
else {
s="<tr align='center' bgcolor='"+titleColor+"'><td colspan='7'>\n<table cellpadding='0' cellspacing='0' border='0'><tr align='center' valign='middle'><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(-1)'> «</a> "+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.prepMonth) window.opener.prepMonth("+d.getMonth()+")'>‹ </a></b>"+span2+"</td><td width='"+titleWidth+"'><nobr><b>"+span1("title")+mm+" "+yy+span2+"</b></nobr></td><td>"+span1("title")+"<b>"+a1("titlea")+"'javascript:if (window.opener && !window.opener.closed && window.opener.nextMonth) window.opener.nextMonth("+d.getMonth()+")'> ›</a> "+a1("titlea")+"'javascript:if(window.opener && !window.opener.closed && window.opener.moveYear) window.opener.moveYear(1)'>» </a></b>"+span2+"</td></tr></table>\n</td></tr><tr align='center' bgcolor='"+daysColor+"'>";
}
for (var i=weekDay; i<weekDay+7; i++) {
s+="<td width='"+dayWidth+"'>"+span1("days")+dayDisplay(i)+span2+"</td>";
}
s+="</tr>";
return s;
}