Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with entrees_sorties; use entrees_sorties;
- procedure jour is
- moisBissex : array(1..12) of Integer := (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
- moisPasBissex : array(1..12) of Integer := (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
- joursSemaine : array(1..7) of String(1..8) := ("Lundi ", "Mardi ", "Mercredi", "Jeudi ", "Vendredi", "Samedi ", "Dimanche");
- dateString : String(1..255);
- dateStringLen : Integer;
- jourEntre : Integer;
- moisEntre : Integer;
- anneeEntree : Integer;
- jourRef : Integer := 8;
- moisRef : Integer := 10;
- anneeRef : Integer := 2012;
- ij, im, ia : Integer;
- nbJours : Integer := 0;
- sens : Integer := -1;
- function estBissextile(annee : Integer) return Boolean is
- begin
- if(((annee mod 4)=0) AND (((annee mod 100)/=0) OR ((annee mod 400)=0))) then
- return true;
- else
- return false;
- end if;
- end estBissextile;
- function minJour(mois, annee, sens : Integer) return Integer is
- begin
- if(sens < 0) then
- return 1;
- else
- if(estBissextile(annee)) then
- return moisBissex(mois);
- else
- return moisPasBissex(mois);
- end if;
- end if;
- end minJour;
- function maxJour(mois, annee, sens : Integer) return Integer is
- begin
- if(sens > 0) then
- return 1;
- else
- if(estBissextile(annee)) then
- return moisBissex(mois);
- else
- return moisPasBissex(mois);
- end if;
- end if;
- end maxJour;
- function minMois(sens : Integer) return Integer is
- begin
- if(sens < 0) then
- return 1;
- else
- return 12;
- end if;
- end minMois;
- function maxMois(sens : Integer) return Integer is
- begin
- if(sens > 0) then
- return 1;
- else
- return 12;
- end if;
- end maxMois;
- begin
- put("Entrez une date (JJ/MM/AAAA) : ");
- get_line(dateString, dateStringLen);
- new_line;
- if(dateStringLen = 10) then
- if(dateString(3)='/' AND dateString(6)='/') then
- jourEntre := Integer'Value(dateString(1..2));
- moisEntre := Integer'Value(dateString(4..5));
- anneeEntree := Integer'Value(dateString(7..10));
- --put("Date : ");put(jourEntre, 0);put('/');put(moisEntre, 0);put('/');put(anneeEntree, 0);new_line;
- if(anneeEntree = anneeRef) then
- if(moisEntre = moisRef) then
- if(jourEntre < jourRef) then
- sens := -1;
- else
- sens := 1;
- end if;
- else
- if(moisEntre < moisRef) then
- sens := -1;
- else
- sens := 1;
- end if;
- end if;
- else
- if(anneeEntree < anneeRef) then
- sens := -1;
- else
- sens := 1;
- end if;
- end if;
- ij := jourRef;
- im := moisRef;
- ia := anneeRef;
- while(not(ij = jourEntre AND im = moisEntre AND ia = anneeEntree)) loop
- ij := ij + sens;
- --put(Integer'Image(ij)&"/"&Integer'Image(im)&"/"&Integer'Image(ia));new_line;
- if(ij*sens > minJour(im, ia, sens)*sens) then
- im := im + sens;
- if(im*sens > minMois(sens)*sens) then
- ia := ia + sens;
- im := maxMois(sens);
- end if;
- ij := maxJour(im, ia, sens);
- end if;
- --put(Integer'Image(ij)&"/"&Integer'Image(im)&"/"&Integer'Image(ia));
- --new_line;
- nbJours := nbJours + sens;
- end loop;
- put("Nombre de jours [depuis 08/10/2012 !] ="&Integer'Image(nbJours*sens));
- new_line;
- put("Jour de la semaine : "&joursSemaine((nbJours mod 7) + 1));
- else
- put("Mauvais format de date !");
- end if;
- else
- put("Mauvais format de date !");
- end if;
- end jour;
Advertisement
Add Comment
Please, Sign In to add comment