// JavaScript Document //c //////////////////////////////////// //<<< le 27/05/2012 10:35:14 function get_date_with_format(format) { var Digital = new Date(); var field = new Array(Digital.getFullYear(),Digital.getMonth()+1,Digital.getDate(),Digital.getHours(),Digital.getMinutes(),Digital.getSeconds(),Digital.getMilliseconds()); var formatYmdHis = ''; var step = 9; for (i=0; i 0) msg = msg + '\n' + ' * Jour invalide'; /// } /// if (objmonth){ test = (monthvalue - 12); if (test > 0) msg = msg + '\n' + ' * Mois invalide'; /// } //? if((actu.getMonth()+1) >= monthvalue) { if((actu.getMonth() + 1) == monthvalue) { if(actu.getDate() >= dayvalue) { mois = (actu.getMonth() + 1) - monthvalue; ans = actu.getFullYear() - yearvalue; } else { mois = (12 - monthvalue) + (actu.getMonth() + 1); ans = actu.getFullYear() - yearvalue - 1; } } else { mois = (actu.getMonth() + 1) - monthvalue; ans = actu.getFullYear() - yearvalue; } } else { mois =(12 - monthvalue) + (actu.getMonth() + 1); ans = actu.getFullYear() - yearvalue - 1; } if(actu.getDate() > dayvalue) jours = actu.getDate() - dayvalue; else jours =(30 - dayvalue) + (actu.getDate()); while(jours > 30) { jours -= 30; mois += 1; } while(mois > 12) { mois -= 12; ans += 1; } ///result['ans'] = ans; ///result['msg'] = msg; return(ans+';'+msg); } //? function get_age_of_person(){ //? //? function bissextile(annee) { if (annee%4==0 && annee %100!=0 || annee%400==0) return true; else return false } function nb_01_01(date){ nb_mois=new Array(13); nb_mois=[,0,31,59,90,120,151,181,212,243,273,304,334]; j=eval(date[0]) ; m=eval(date[1]) ; a=eval(date[2]); nb=nb_mois[m]+j-1 ; if (bissextile(a) && m>2) nb++; return(nb); } //? function fCompareDate(pDateDebut,pDateFin) { //? format YYYY/MM/dd var DureeDebut = Date.parse(pDateDebut); var DureeFin = Date.parse(pDateFin); var iComparaison= DureeFin - DureeDebut; if (iComparaison > 0) return(">"); if (iComparaison == 0) return("="); if (iComparaison < 0) return("<"); return iComparaison; //? retourne la différence en secondes } function nb_jour_annee(a1,a2){ n=0; if (a1==a2) n=0 ; else for (i=a1; i //? ====================================================== function get_actual_hour(){ var Digital = new Date(); var hours = Digital.getHours(); var minutes = Digital.getMinutes(); var seconds = Digital.getSeconds(); if (hours <= 9) hours = "0"+hours; if (minutes <= 9) minutes = "0"+minutes; if (seconds <= 9) seconds = "0"+seconds; return(hours + ':' + minutes + ':' + seconds); } //? ====================================================== function js_get_actual_time(){ var d = new Date(); return(d.getHours()*3600+d.getMinutes()*60+d.getSeconds()); } //? =========================== function hours_selected(){ } //? ============================ function test_age_of_person(birthday){ //? controle de l'age ==================== var actu = new Date(); var age = birthday.split('-'); if(age.length<3)age = birthday.split('/'); if(age.length<3) return(0); var dayvalue = age[2]; var monthvalue = age[1]; var yearvalue = age[0]; var ans = '';var mois = '';var jours = ''; if((actu.getMonth()+1) >= monthvalue) { if((actu.getMonth() + 1) == monthvalue) { if(actu.getDate() >= dayvalue) { mois = (actu.getMonth() + 1) - monthvalue; ans = actu.getFullYear() - yearvalue; } else { mois = (12 - monthvalue) + (actu.getMonth() + 1); ans = actu.getFullYear() - yearvalue - 1; } } else { mois = (actu.getMonth() + 1) - monthvalue; ans = actu.getFullYear() - yearvalue; } } else { mois =(12 - monthvalue) + (actu.getMonth() + 1); ans = actu.getFullYear() - yearvalue - 1; } if(actu.getDate() > dayvalue) jours = actu.getDate() - dayvalue; else jours =(30 - dayvalue) + (actu.getDate()); while(jours > 30) { jours -= 30; mois += 1; } while(mois > 12) { mois -= 12; ans += 1; } return(ans); } //? test_age_of_person myApp.checkDate = function(_date){ var reg = new RegExp(/^[0-3]{1}[0-9]{1}[\/][0-1]{1}[0-9]{1}[\/][0-9]{4}$/); if(!reg.test(_date)){ // VERIFICATION DU FORMAT JJ/MM/AAAA return false; } var tabDate = _date.split('/'); var dateTest = new Date(tabDate[2], tabDate[1] - 1, tabDate[0]); if(parseInt(tabDate[0], 10) != parseInt(dateTest.getDate(), 10) || parseInt(tabDate[1], 10) != parseInt(dateTest.getMonth(), 10) + parseInt(1, 10) || parseInt(tabDate[2], 10) != parseInt(dateTest.getFullYear(), 10) ){ // VERIFICATION DE L'EXSISTANCE return false; } return true; } //myApp.checkDate = function(_date){ //////////////////////////////// myApp.get_age_from_date = function(_date){ // format JJ/MM/YYYY /* http://www.paulds.fr/2010/05/javascript-connaitre-le-nombre-de-jours-dun-mois/ http://www.paulds.fr/prestations-de-service/ portage salarial */ if(!myApp.checkDate(_date)) return; var days = ''; var msg = new Array(); msg['msg'] = ''; var actu = new Date(); // var nbrdaysinmonth = new Date(actu.getFullYear(), actu.getMonth()+1, -1).getDate()+1; var months = actu.getMonth(); var yearvalue = actu.getFullYear(); var tab = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); if ((yearvalue%4 == 0 && yearvalue%100 != 0) || (yearvalue%400 == 0)) tab[1] += 1; msg['nbrD'] = '31'; //tab[months]; //return nbrdaysinmonth[_month]; // 0 < mois <11 tab = _date.split('/'); var dayvalue = (tab[0] ? tab[0] : false); var monthvalue = (tab[1] ? tab[1] : false); yearvalue = (tab[2] ? tab[2] : false); if (!dayvalue || !monthvalue || !yearvalue) return(msg['msg']); if ((dayvalue - 31) > 0) msg['msg'] += '\n' + ' * Jour invalide'; if ((monthvalue - 12) > 0) msg['msg'] += '\n' + ' * Mois invalide'; if((actu.getMonth()+1) >= monthvalue) { if((actu.getMonth() + 1) == monthvalue) { if(actu.getDate() >= dayvalue) { months = (actu.getMonth() + 1) - monthvalue; msg['age'] = actu.getFullYear() - yearvalue; } else { months = (12 - monthvalue) + (actu.getMonth() + 1); msg['age'] = actu.getFullYear() - yearvalue - 1; } } else { months = (actu.getMonth() + 1) - monthvalue; msg['age'] = actu.getFullYear() - yearvalue; } } else { months =(12 - monthvalue) + (actu.getMonth() + 1); msg['age'] = actu.getFullYear() - yearvalue - 1; } if(actu.getDate() > dayvalue) days = actu.getDate() - dayvalue; else days =(30 - dayvalue) + (actu.getDate()); while(days > 30) { days -= 30; months += 1; } while(months > 12) { months -= 12; msg['age'] += 1; } return(msg); //ans+';'+msg); } //myApp.get_age_from_date = function(_date){ // format JJ/MM/YYYY /////////////////////////////////////////////////////////////////// //c ////////////////////////////////////