Tecsitel_FactuGES2/Source/Base/Utiles/uDateUtils.pas
2007-09-04 17:25:54 +00:00

42 lines
951 B
ObjectPascal

unit uDateUtils;
interface
uses
SysUtils, Classes;
function DarFechaPrimerDia(Date: TDateTime): TDateTime;
function DarFechaUltimoDia(Date: TDateTime): TDateTime;
function EsFechaVacia(AFecha : TDateTime): Boolean;
implementation
const
FECHA_NULA = -700000;
function EsFechaVacia(AFecha : TDateTime): Boolean;
begin
Result := (AFecha = FECHA_NULA) or (AFecha = 0);
end;
function DarFechaPrimerDia(Date: TDateTime): TDateTime;
var
Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
Result := EncodeDate(Year, Month, 1);
end;
function DarFechaUltimoDia(Date: TDateTime): TDateTime;
var
Year, Month, Day: Word;
begin
DecodeDate(Date, Year, Month, Day);
// (if Month < 12 then inc(Month)
// else begin Month := 1; inc(Year) end;
// Result := EncodeDate(Year, Month, 1) - 1;
Result := EncodeDate(Year, Month,
MonthDays[IsLeapYear(Year), Month]);
end;
end.