Unit DateUtil

*****************************************************} { } { Delphi VCL Extensions (RX) } { } { Copyright (c) 1995, 1996 AO ROSNO } { Copyright (c) 1997, 1998 Master-Bank } { } {

Classes

Functions

CurrentYear -
CutTime -
DateDiff -
DaysBetween - Count days between Date1 and Date2 + 1, so if Date1 = Date2 result = 1
DaysInPeriod -
DaysPerMonth -
DefDateFormat -
DefDateMask -
ExtractDay -
ExtractMonth -
ExtractYear -
FirstDayOfNextMonth - leap-year Feb is special
FirstDayOfPrevMonth -
FourDigitYear -
GetDateOrder - String to date conversions
IncDate -
IncDay - Changed by Anatoly A.
IncHour -
IncMinute -
IncMonth -
IncMSec -
IncSecond -
IncTime - The same as previous but if Date2 < Date1 result = 0
IncYear -
IsLeapYear - -693594
LastDayOfPrevMonth -
MonthFromName -
MonthsBetween -
StrToDateDef -
StrToDateFmt -
StrToDateFmtDef -
ValidDate -

Types

TDateOrder
TDayOfWeekName
TDaysOfWeek

Constants

DefaultDateOrder
NullDate

Variables


Functions


function CurrentYear: Word;


function CutTime(ADate: TDateTime): TDateTime;


procedure DateDiff(Date1, Date2: TDateTime; var Days, Months, Years: Word);


function DaysBetween(Date1, Date2: TDateTime): Longint;

Count days between Date1 and Date2 + 1, so if Date1 = Date2 result = 1

function DaysInPeriod(Date1, Date2: TDateTime): Longint;


function DaysPerMonth(AYear, AMonth: Integer): Integer;


function DefDateFormat(FourDigitYear: Boolean): string;


function DefDateMask(BlanksChar: Char; FourDigitYear: Boolean): string;


function ExtractDay(ADate: TDateTime): Word;


function ExtractMonth(ADate: TDateTime): Word;


function ExtractYear(ADate: TDateTime): Word;


function FirstDayOfNextMonth: TDateTime;

leap-year Feb is special

function FirstDayOfPrevMonth: TDateTime;


function FourDigitYear: Boolean;


function GetDateOrder(const DateFormat: string): TDateOrder;

String to date conversions

function IncDate(ADate: TDateTime; Days, Months, Years: Integer): TDateTime;


function IncDay(ADate: TDateTime; Delta: Integer): TDateTime;

Changed by Anatoly A. Sanko (2:450/73)

function IncHour(ATime: TDateTime; Delta: Integer): TDateTime;


function IncMinute(ATime: TDateTime; Delta: Integer): TDateTime;


function IncMonth(ADate: TDateTime; Delta: Integer): TDateTime;


function IncMSec(ATime: TDateTime; Delta: Integer): TDateTime;


function IncSecond(ATime: TDateTime; Delta: Integer): TDateTime;


function IncTime(ATime: TDateTime; Hours, Minutes, Seconds, MSecs: Integer): TDateTime;

The same as previous but if Date2 < Date1 result = 0

function IncYear(ADate: TDateTime; Delta: Integer): TDateTime;


function IsLeapYear(AYear: Integer): Boolean;

-693594

function LastDayOfPrevMonth: TDateTime;


function MonthFromName(const S: string; MaxLen: Byte): Byte;


function MonthsBetween(Date1, Date2: TDateTime): Double;


function StrToDateDef(const S: string; Default: TDateTime): TDateTime;


function StrToDateFmt(const DateFormat, S: string): TDateTime;


function StrToDateFmtDef(const DateFormat, S: string; Default: TDateTime): TDateTime;


function ValidDate(ADate: TDateTime): Boolean;


Types


TDateOrder = (doMDY, doDMY, doYMD);
Set time to 00:00:00:00
TDayOfWeekName = (Sun, Mon, Tue, Wed, Thu, Fri, Sat);

TDaysOfWeek = set of TDayOfWeekName

Constants

DefaultDateOrder = doDMY

NullDate = {-693594} 0


Variables