function numgiorno(data) {



 var mesi = new Array (31,28,31,30,31,30,31,31,30,31,30,31);



 var num = data.getDate();



 for (var i = 0; i<(data.getMonth()); i++) { num += mesi[i] };



 return(--num);



};







function datatostard() {







 var data = new Date( (parseInt(document.form.anno.value)), (parseInt(document.form.mese.value) - 1), (parseInt(document.form.giorno.value)), (parseInt(document.form.hh.value)), (parseInt(document.form.mm.value)), 00);



 document.form.stardate.value = ( data.getYear() - 2323 + ( ( numgiorno(data) + ( (data.getHours() + (data.getMinutes()/60)) /24 ) ) / 365) )*1000



};







function rd(stard,coeff) {



 stard -= Math.floor(stard);



 stard = stard * coeff;



 return(stard);



};







function stardtodata() {



 var stard = parseFloat(document.form.stardate.value);



 var mesi = new Array (31,28,31,30,31,30,31,31,30,31,30,31);



 var i = 0;



 document.form.anno.value = Math.floor(stard/1000) + 2323;



 stard -= Math.floor(stard/1000) * 1000;



 stard = stard * 365 / 1000;



 while (stard > mesi[i]) {



 stard -= mesi[i];



 i++;



 };



 document.form.mese.value = i+1;



 document.form.giorno.value= Math.floor(stard) +1;



 stard = rd(stard,24);



 document.form.hh.value = Math.floor(stard);



 stard = rd(stard, 60);



 document.form.mm.value = Math.floor(stard);



};


