A continuación puedes calcular si eres Indefinido o no, dependiente de si has tenido una concatenación de contratos o uno solamente.
Recuerda que no cuentan los contratos formativos, interinidad o de relevo.
Resultado : Sin calcular
var _jslib_isIE=document.all?true:false; var _jslib_isNS=document.layers?true:false; var _jslib_isNS6=document.getElementById&&!document.all?true:false; function ap_getObj(name) { if(_jslib_isIE) { return document.all[name]; } else if(_jslib_isNS) { return document.layers[name]; } else if (_jslib_isNS6) { return document.getElementById(name); } return null; } function selectShow(Name) { var selectObj = ap_getObj(Name); selectObj.style.display=''; } function selectHide(Name) { var selectObj = ap_getObj(Name); selectObj.style.display='none'; } function esFecha(dateStr) { var datePat = /^(\d{1,2})(\/|)(\d{1,2})(\/|)(\d{4})$/; var matchArray = dateStr.match(datePat); // is the format ok? if (matchArray == null) { alert("Formato Valido:\ndd/mm/yyyy"); return false; } month = matchArray[3]; // parse date into variables day = matchArray[1]; year = matchArray[4]; if (month < 1 || month > 12) { // check month range alert("Mes entre 1 y 12."); return false; } if (day < 1 || day > 31) { alert("Dias entre 1 y 31."); return false; } if ((month==4 || month==6 || month==9 || month==11) && day==31) { alert("Mes "+month+" no tiene 31 dias!") return false; } if (month == 2) { // check for february 29th var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)); if (day > 29 || (day==29 && !isleap)) { alert("Febrero " + year + " no tiene " + day + " dias!"); return false; } } return true; // date is valid } function validarFecha(dia, mes, anyo) {
if (anyo==''){return false;}
if (anyo<1850){ return false;}
if (mes==''){ return false;}
if (dia==''){ return false;}
if(ValidacionFecha(dia+'-'+mes+'-'+anyo,"-")==''){
return false;
}else{
return true;
}
}
function ValidacionFecha(fecha, sep) {
var numeros = "0123456789";
var pos1 = fecha.indexOf(sep);
var pos2 = fecha.indexOf(sep, pos1+1);
var dia, mes, ano;
var i;
if ((pos1 == -1)||(pos2 == -1)) {
return "";
}
dia = fecha.substring(0, pos1);
mes = fecha.substring(pos1+1, pos2);
ano = fecha.substring(pos2+1, fecha.length);
if ((dia.length < 1)||(dia.length > 2)) {
return "";
}
for(i=0;i if (mes < 1 || mes >12) { return ""; } if ((mes.length < 1)||(mes.length > 2)) {
return "";
}
for(i=0;i var splitfecha1=fecha1.split("/"); var fecha2=ap_getObj('fecha_fin_2').value; if(!esFecha(fecha2)){ result="Fecha fin no valida"; ap_getObj('resultado').innerHTML="Resultado : " + result; return false; } var splitfecha2=fecha2.split("/"); if (!validarFecha(splitfecha1[0],splitfecha1[1],splitfecha1[2])){ alert("Fecha Inicio Incorrecta"); return false; } if (!validarFecha(splitfecha2[0],splitfecha2[1],splitfecha2[2])){ alert("Fecha Fin Incorrecta"); return false; } var select = document.getElementById("lista_fechas"); var strselect=(fecha1 + " - " + fecha2); if(select.options[0].value==-1){ select.options[0]=null; ap_getObj('cal2').disabled=false; } var dateString=splitfecha2[1] + "/" + splitfecha2[0] + "/" + splitfecha2[2]; var myDatef = new Date(dateString); var myDatecompare = new Date("06/15/2006"); if(myDatef } dias = Math.floor(diferencia / (1000 * 60 * 60 * 24)); diastotal=diastotal+ parseInt(dias); } } return diastotal; } function calcular(){ var result; var today = new Date(); if (ap_getObj("contenido1").style.display==''){ if(!esFecha(ap_getObj('fecha_inicio_1').value)){ result="Fecha no valida"; ap_getObj('resultado').innerHTML="Resultado : " + result; return false; } var fecha=ap_getObj('fecha_inicio_1').value.split("/"); if (!validarFecha(fecha[0],fecha[1],fecha[2])){ result="Fecha Incorrecta"; ap_getObj('resultado').innerHTML="Resultado : " + result; return false; } var dateString=fecha[1] + "/" + fecha[0] + "/" + fecha[2]; var dateStringlimite=fecha[1] + "/" + fecha[0] + "/" + (parseInt(fecha[2])+4); var myDate = new Date(dateString); var myDatecompare = new Date("06/18/2010"); var myDatelimite = new Date(dateStringlimite); if(myDate if (dias>365){
result="Ta faltan "+ dias + " dias para ser indefinido result="Ta faltan "+ dias + " dias para ser indefinido } } }else{ ndias=recalculardiasfechas(); if (ndias>720){ result="Ya eres Indefinido"; }else{ var meses=((720- parseInt(ndias))/30).toFixed(0); if (meses>12){
result="Ta faltan "+ (720- parseInt(ndias)) + " dias para ser indefinido result="Ta faltan "+ (720- parseInt(ndias)) + " dias para ser indefinido } ap_getObj('resultado').innerHTML="Resultado : " + result; } ap_getObj('fecha_fin_1').value=fHoy(); |