1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
| function getFinDuMois(_date: TDateTime):TDateTime;
var d,m,y: word;
function getMaxDay(mois,annee: word):word;
begin
case mois of
4,6,9,11: result := 30;
2: if IsLeapYear(annee) then result := 29
else result := 28;
else result := 31;
end;
end;
begin
decodeDate(_date,y,m,d);
result := encodeDate(y,m,getMaxDay(m,y));
end;
function getFinDutrimestre(_date: TDateTime):TDateTime;
var d,m,y: word;
function getMaxtrimestre(mois: word):word;
begin
case mois of
1,2,3: result := 3;
4,5,6: result := 6;
7,8,9: result := 9;
else result := 12;
end;
end;
begin
decodeDate(_date,y,m,d);
case m of
1,2,3,10,11,12:result := encodeDate(y,getMaxtrimestre(m),31);
else result := encodeDate(y,getMaxtrimestre(m),30);
end;
end;
function getdebutDutrimestre(_date: TDateTime):TDateTime;
var d,m,y: word;
function getMaxtrimestre(mois: word):word;
begin
case mois of
1,2,3: result := 1;
4,5,6: result := 4;
7,8,9: result := 7;
else result := 10;
end;
end;
begin
decodeDate(_date,y,m,d);
result := encodeDate(y,getMaxtrimestre(m),1);
end;
function getdebutDusemestre(_date: TDateTime):TDateTime;
var d,m,y: word;
function getMaxsemestre(mois: word):word;
begin
case mois of
1,2,3,4,5,6: result := 1;
else result := 7;
end;
end;
begin
decodeDate(_date,y,m,d);
result := encodeDate(y,getMaxsemestre(m),1);
end;
function getfinsemestre(_date: TDateTime):TDateTime;
var d,m,y: word;
function getMaxsemestre(mois: word):word;
begin
case mois of
1,2,3,4,5,6: result := 6;
else result := 12;
end;
end;
begin
decodeDate(_date,y,m,d);
case m of
1,2,3,4,5,6: result := encodeDate(y,getMaxsemestre(m),30)
else result := encodeDate(y,getMaxsemestre(m),31);
end;
end; |