git-svn-id: https://192.168.0.254/svn/Proyectos.Tecsitel_FactuGES2/trunk@3 0c75b7a4-871f-7646-8a2f-f78d34cc349f
42 lines
951 B
ObjectPascal
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.
|