- Partly based on the public domain codes by:
- Scott Bussinger
- Carley Phillips
which were written for Pascal.
- Routines in this unit utilise certain global system variables and routines
which are specific to Delphi.
DateToDMY - -Convert from day, month, year to a julian date
DayOfWeekFromDateStr -
4/1/98.
DaysInMonth -
DDMMYY2DDMMMYY -
Converts 99/99/99 to 11/XXX/99.
DMYtoDate - -Verify that day, month, year is a valid date
HMStoTime - Go to next day or previous day.
IncDecFromDateStr -
12/11/97.
IsLeapYear -
StrToDMY -
21/12/97.
TimeDiff -
TimeToHMS -
ValidDate -
DayFormat
DDMMYYYY
JulianDate
thisTime
BadDate
BadTime
Date1900
Date1980
Date2000
First2Months
HoursInDay
MaxDate
MaxYear
MinDate
MinutesInHour
MinYear
SecondsInDay
SecondsInHour
SecondsInMinute
Threshold2000
procedure DateToDMY(Julian : JulianDate; var Day, Month, Year : Integer);
-Convert from day, month, year to a julian date
function DayOfWeekFromDateStr(dStr : string; DF : DayFormat) : string;
4/1/98.
- Returns the day name for the date string.
- dStr: the string represents the date; e.g. 12/12/97, 12/12/1997.
- DF: how should the day name be returned: full or abbreviated;
for example: Mon or Monday.
- Assumption: the dStr represents a valid date. No validity checking is
performed on the date string.
function DaysInMonth(Month, Year : Integer) : Integer;
function DDMMYY2DDMMMYY(var S : string) : boolean;
Converts 99/99/99 to 11/XXX/99.
====> 11/12/97 to 11-DEC-97.
Assuming that S represents a valid date.
function DMYtoDate(Day, Month, Year : Integer) : JulianDate;
-Verify that day, month, year is a valid date
function HMStoTime(Hours, Minutes, Seconds : Byte) : thisTime;
Go to next day or previous day.
function IncDecFromDateStr(Dir : integer; var dStr : DDMMYYYY; var Day : string) : boolean;
12/11/97.
Dir: the next day (Up) or the previous day (Down).
dStr: represents the input date string in dd/mm/yy format.
represents the output date string in dd/mm/yy format.
Day: represents date (Mon, Tue etc) of dStr.
Return True if dStr represents a valid date. False otherwise.
When dStr represents a valid date, dStr is changed to the next or
previous day and Day's value is defined.
First revision: 03/1/98.
function IsLeapYear(Year : Integer) : Boolean;
procedure StrToDMY(dStr : string; var D, M, Y : integer);
21/12/97.
Input variable dStr is assumed to contain a valid Australian date string.
dStr should be validated before passed to this function.
Breaks dStr into date, month, year components.
First revision: 4/1/98.
procedure TimeDiff(Time1, Time2 : thisTime; var Hours, Minutes, Seconds : Byte);
procedure TimeToHMS(T : thisTime; var Hours, Minutes, Seconds : Byte);
function ValidDate(Day, Month, Year : Integer) : Boolean;
DayFormat = (LongDay, ShortDay);
DDMMYYYY = string[10]
JulianDate = LongInt
thisTime = LongInt
BadDate = $FFFFFFFF
= 01/01/2000
BadTime = $FFFFFFFF
dd/mm/yyyy as in 30/11/2001.
Date1900 = $0001AC05
= 12/31/3999
Date1980 = $00021E28
= 01/01/1900
Date2000 = $00023AB1
= 01/01/1980
First2Months = 59
HoursInDay = 24
number of seconds in a minute
MaxDate = $000D6025
= 01/01/1600
MaxYear = 3999
MinDate = $00000000
MinutesInHour = 60
number of hours in a day
MinYear = 1600
number of minutes in an hour
SecondsInDay = 86400
SecondsInHour = 3600
number of seconds in a day
SecondsInMinute = 60
number of seconds in an hour
Threshold2000 = 1900
1600 was a leap year