fix date format DAE
[auf_rh_dae.git] / project / assets / js / dae.js
... / ...
CommitLineData
1/* string to float */
2function clean_float(value){
3 if (isNaN(value) || value == undefined || value == "") {
4 output = 0;
5 }
6 else {
7 output = parseFloat(value);
8 output = Math.round(output*100)/100;
9 }
10 return output;
11}
12
13function roundNumber(num, dec) {
14 var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec);
15 return result;
16}
17
18/* stocker le texte par défaut à afficher */
19var note_duree_indeterminee = "";
20
21function contrat_mois() {
22 if (note_duree_indeterminee == "")
23 note_duree_indeterminee = $("#note-duree").html();
24 var debut = $("#id_date_debut, #id_contrat_date_debut").val();
25 var fin = $("#id_date_fin, #id_contrat_date_fin").val();
26 if (debut == "" || fin == "")
27 note = note_duree_indeterminee;
28 else {
29 var d = debut.split('-');
30 j = d[0]; m = d[1];a = d[2];
31 var d1 = new Date(a, m, j);
32
33 var d = fin.split('-');
34 j = d[0]; m = d[1];a = d[2];
35 var d2 = new Date(a, m, j);
36
37 var duree = Math.round((d2-d1) / (1000*60*60*24) / (365/12));
38 note = duree + " mois";
39 }
40 $("#note-duree").html(note);
41}
42