DaysInMonth Routines |
Unit
QESBPCSDateTime
Overloaded Variants |
Function DaysInMonth(const DT: TDateTime): Byte; |
Function DaysInMonth(const Month, Year: Word): Byte; |
Function DaysInMonth(const Month, Year: Integer): Byte; |
Declaration
Function DaysInMonth(const DT: TDateTime): Byte;
Description
Alternatively for a given Month Year.
Parameters |
DT | Date/Time to process. |
Month | Month in given year, 1 = Jan, 12 = Dec. |
Year | 4-digit Year, such as 1999. |
Category
Date/Time Arithmetic Routines
Month Based Arithmetic RoutinesImplementation
function DaysInMonth (const DT: TDateTime): Byte; begin case Date2Month (DT) of 2: if DateIsLeapYear (DT) then Result := 29 else Result := 28; 4, 6, 9, 11: Result := 30; else Result := 31; end; End; |
Declaration
Function DaysInMonth(const Month, Year: Word): Byte;Implementation
function DaysInMonth (const Month, Year: Word): Byte; begin if (Month < 1) or (Month > 12) then raise EConvertError.Create (rsInvalidMonth); case Month of 2: if IsLeapYear (Year) then Result := 29 else Result := 28; 4, 6, 9, 11: Result := 30; else Result := 31; end; End; |
Declaration
Function DaysInMonth(const Month, Year: Integer): Byte;Implementation
function DaysInMonth (const Month, Year: Integer): Byte; begin if (Month < 1) or (Month > 12) then raise EConvertError.Create (rsInvalidMonth); case Month of 2: if IsLeapYear (Year) then Result := 29 else Result := 28; 4, 6, 9, 11: Result := 30; else Result := 31; end; End; |
|