cs_Zeroc00l
Messages postés367Date d'inscriptionlundi 1 avril 2002StatutMembreDernière intervention11 février 2010 17 juil. 2007 à 21:58
Dur dur de se remettre au delphi apres si longtemps ...
(notement pour se rendre compte qu'il n'y a pas d'operateur ternaire x-D)
Enfin ! Voila la traduction brute de fonderie !
(donc à retester):
procedure AfficherDate(S : byte; Anne : Integer; L : TLabel; D : TLabel);
var A : Integer;
PeriodeJour : array[1..28] of Byte;
j : Byte;
t : Byte;
Lundi : Integer;
JourParMois : array[1..12] of Integer;
Mois : Byte;
begin
A :(Anne - 12) Mod 28; // (12 2000 mod 28 )
if (A = 0) Then A := 28;
j := 6;
for t := 1 To A do
begin
j :(j + 1 - Integer(((t - 1) Mod 4 0) And (t > 1))) Mod 7;
PeriodeJour[t] := j;
end;
Lundi := S * 7 - PeriodeJour[A] - 6;
If (Lundi < 0) Then begin
L.Caption := IntToStr(31) + IntToStr(Lundi) + '/' + IntToStr(12) + '/' + IntToStr(Anne - 1);
D.Caption := IntToStr(7 - PeriodeJour[A]) + '/' + IntToStr(11) + '/' + IntToStr(Anne);
end Else begin
j := 1;
Mois := 1;
While (Lundi > JourParMois[j]) do
begin
Lundi := Lundi - JourParMois[j];
j := j + 1;
Mois := Mois + 1;
end;
L.Caption := IntToStr(Lundi) + '/' + IntToStr(Mois) + '/' + IntToStr(Anne);
Lundi := Lundi + 6;
If (Lundi > JourParMois[j]) Then begin
D.Caption := IntToStr(Lundi - JourParMois[j]) + '/';
if (Mois = 12) then
D.Caption := D.Caption + '1'
else
D.Caption := D.Caption + IntToStr(Mois + 1);
if (Mois = 12) then
Dec(Anne);
D.Caption := D.Caption + '/' + IntToStr(Anne);
end Else
D.Caption := IntToStr(Lundi) + '/' + IntToStr(Mois) + '/' + IntToStr(Anne);
end;
end;
ericmaudouit
Messages postés8Date d'inscriptionjeudi 12 juillet 2007StatutMembreDernière intervention16 février 2009 16 juil. 2007 à 18:16
Salut je cherche a faire tourner cette routine sous pascal DELPHI y aurais t' il quelqun qui l'a deja fait.
cs_Zeroc00l
Messages postés367Date d'inscriptionlundi 1 avril 2002StatutMembreDernière intervention11 février 2010 20 janv. 2004 à 23:27
Ah oui !
Effectivement c'est une petite coquille ... Désolé pour ceux qui auraient utilisé ce code ...
Vala c'est corrigé ! Merci !
cs_jr62
Messages postés1Date d'inscriptionmardi 20 janvier 2004StatutMembreDernière intervention20 janvier 2004 20 janv. 2004 à 10:38
J'ai essayé le code mais il ne fonctionne pas toujours. Au lieu de mettre:
While Lundi > JourParMois(j)
j = j + 1
Lundi = Lundi - JourParMois(j)
Mois = Mois + 1
Wend
Il faudrait plutot mettre:
While Lundi > JourParMois(j)
Lundi = Lundi - JourParMois(j)
j = j + 1
Mois = Mois + 1
Wend
A plus
cs_Zeroc00l
Messages postés367Date d'inscriptionlundi 1 avril 2002StatutMembreDernière intervention11 février 2010 31 juil. 2003 à 22:07
Bon effectivement ca marche tres bien ... aussi bien voire mieux qu moi donc je vais mettre une autre source a la place de celle ci ! (quand je l'aurai fait !)
cs_Zeroc00l
Messages postés367Date d'inscriptionlundi 1 avril 2002StatutMembreDernière intervention11 février 2010 31 juil. 2003 à 21:32
Merci, c'est bien plus court ... mais bon maintenant que j'ai mis cette source, elle servira d'alternative ...
Renfield
Messages postés17287Date d'inscriptionmercredi 2 janvier 2002StatutModérateurDernière intervention27 septembre 202174 31 juil. 2003 à 20:35
Date du premier jour de la semaine a partir d'une date :
17 juil. 2007 à 21:58
(notement pour se rendre compte qu'il n'y a pas d'operateur ternaire x-D)
Enfin ! Voila la traduction brute de fonderie !
(donc à retester):
procedure AfficherDate(S : byte; Anne : Integer; L : TLabel; D : TLabel);
var A : Integer;
PeriodeJour : array[1..28] of Byte;
j : Byte;
t : Byte;
Lundi : Integer;
JourParMois : array[1..12] of Integer;
Mois : Byte;
begin
A :(Anne - 12) Mod 28; // (12 2000 mod 28 )
if (A = 0) Then A := 28;
j := 6;
for t := 1 To A do
begin
j :(j + 1 - Integer(((t - 1) Mod 4 0) And (t > 1))) Mod 7;
PeriodeJour[t] := j;
end;
Lundi := S * 7 - PeriodeJour[A] - 6;
If (Lundi < 0) Then begin
L.Caption := IntToStr(31) + IntToStr(Lundi) + '/' + IntToStr(12) + '/' + IntToStr(Anne - 1);
D.Caption := IntToStr(7 - PeriodeJour[A]) + '/' + IntToStr(11) + '/' + IntToStr(Anne);
end Else begin
JourParMois[1] := 31;
JourParMois[2] := 28;
if ((A Mod 4) = 0) then
Dec(JourParMois[2]);
JourParMois[3] := 31;
JourParMois[4] := 30;
JourParMois[5] := 31;
JourParMois[6] := 30;
JourParMois[7] := 31;
JourParMois[8] := 31;
JourParMois[9] := 30;
JourParMois[10] := 31;
JourParMois[11] := 30;
JourParMois[12] := 31;
j := 1;
Mois := 1;
While (Lundi > JourParMois[j]) do
begin
Lundi := Lundi - JourParMois[j];
j := j + 1;
Mois := Mois + 1;
end;
L.Caption := IntToStr(Lundi) + '/' + IntToStr(Mois) + '/' + IntToStr(Anne);
Lundi := Lundi + 6;
If (Lundi > JourParMois[j]) Then begin
D.Caption := IntToStr(Lundi - JourParMois[j]) + '/';
if (Mois = 12) then
D.Caption := D.Caption + '1'
else
D.Caption := D.Caption + IntToStr(Mois + 1);
if (Mois = 12) then
Dec(Anne);
D.Caption := D.Caption + '/' + IntToStr(Anne);
end Else
D.Caption := IntToStr(Lundi) + '/' + IntToStr(Mois) + '/' + IntToStr(Anne);
end;
end;
16 juil. 2007 à 18:16
20 janv. 2004 à 23:27
Effectivement c'est une petite coquille ... Désolé pour ceux qui auraient utilisé ce code ...
Vala c'est corrigé ! Merci !
20 janv. 2004 à 10:38
While Lundi > JourParMois(j)
j = j + 1
Lundi = Lundi - JourParMois(j)
Mois = Mois + 1
Wend
Il faudrait plutot mettre:
While Lundi > JourParMois(j)
Lundi = Lundi - JourParMois(j)
j = j + 1
Mois = Mois + 1
Wend
A plus
31 juil. 2003 à 22:07
31 juil. 2003 à 21:32
31 juil. 2003 à 20:35
dateadd ( "d" , -Weekday ( DATEDEPART, vbMonday )+1 , DATEDEPART )