unit uDateUtils; interface uses SysUtils, Classes; function DarFechaPrimerDia(Date: TDateTime): TDateTime; function DarFechaUltimoDia(Date: TDateTime): TDateTime; function EsFechaVacia(AFecha : TDateTime): Boolean; function NumberDayOfTheWeek(const ADay : String) : Word; function NumberMonthOfTheYear(const AMonth : String) : Word; implementation uses DateUtils; const FECHA_NULA = -700000; function NumberDayOfTheWeek(const ADay : String) : Word; begin if (ADay = 'Monday') or (ADay = 'Lunes') then Result := DayMonday; if (ADay = 'Tuesday') or (ADay = 'Martes') then Result := DayTuesday; if (ADay = 'Wednesday') or (ADay = 'Miercoles') or (ADay = 'Miércoles') then Result := DayWednesday; if (ADay = 'Thursday') or (ADay = 'Jueves') then Result := DayThursday; if (ADay = 'Friday') or (ADay = 'Viernes') then Result := DayFriday; if (ADay = 'Saturday') or (ADay = 'Sabado') or (ADay = 'Sábado') then Result := DaySaturday; if (ADay = 'Sunday') or (ADay = 'Domingo') then Result := DaySunday; end; function NumberMonthOfTheYear(const AMonth : String) : Word; begin if (AMonth = 'January') or (AMonth = 'Enero') then Result := 1; if (AMonth = 'February') or (AMonth = 'Febrero') then Result := 2; if (AMonth = 'March') or (AMonth = 'Marzo') then Result := 3; if (AMonth = 'April') or (AMonth = 'Abril') then Result := 4; if (AMonth = 'May') or (AMonth = 'Mayo') then Result := 5; if (AMonth = 'June') or (AMonth = 'Junio') then Result := 6; if (AMonth = 'July') or (AMonth = 'Julio') then Result := 7; if (AMonth = 'August') or (AMonth = 'Agosto') then Result := 8; if (AMonth = 'September') or (AMonth = 'Septiembre') or (AMonth = 'Setiembre') then Result := 9; if (AMonth = 'October') or (AMonth = 'Octubre') then Result := 10; if (AMonth = 'November') or (AMonth = 'Noviembre') then Result := 11; if (AMonth = 'December') or (AMonth = 'Diciembre') then Result := 12; end; 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.