Unit DateMan

---------------------------------------------------------------------- Date and Time Manager written by William Yang (Dream Factory) E-mail : yang@btinternet.com URL : http://www.btinternet.com/~yang ---------------------------------------------------------------------- } { --------------------------------------------------------------------------- TDateTime is formed by Date(Whole number) and Time(Float number). Which means a day in DateTime format will be "1", an hour will be "1/24", and so on... This table shows you all. +---------+-------------------+ | PARTS | IN DATETIME VALUE | +---------+-------------------+ | Year | 365 (Day/Year) | | Month | 31 (Day/Month) | | Day | 1 | | Hour | 1/24 | | Minutes | 1/24/60 | | Seconds | 1/24/60/60 | | M. Sec | 1/24/60/60/1000 | +---------+-------------------+ ---------------------------------------------------------------------------

Classes

Functions

BeginOfMonth - Return move the day to the begin of the month
BeginOfYear - Return move the day to the begin of the year
DateToHours - Calculate date by hours
DateToMinutes - Calculate date by minutes
DateToSeconds - Calculate date by seconds
DayInMonth - Return how many days in the given year of month
DecDay - Decrease days in DateTime
DecHour - Decrease hours in DateTime
DecMin - Decrease minutes in DateTime
DecMonth - Decrease months in DateTime
DecSec - Decrease seconds in DateTime
DecYear - Decrease years in DateTime
EndOfMonth - Return move the day to the end of the month
EndOfYear - Return move the day to the end of the year
EStrToDate -
GetDay - Return the day of the date

Date reading functions
GetHour - Get the hour of the time
GetMin - Get the minute of the time
GetMonth - Return the month of the date

These procedures are copied from xProcs by } { Copyright (c) 1995 Stefan Böther } { stefc@fabula.
GetSec - Return the second of the time
GetYear - Return the year of the date
HoursToDate - Convert hours back to Date
IncDay - Increase days in DateTime
IncHour - Increase hours in DateTime
IncMin - Increase minutes in DateTime
IncMonth - Increase months in DateTime
IncSec - Increase seconds in DateTime
IncYear - Increase Years in DateTime
IsLeapYear - Return if given year is Leap Year
MinutesToDate - Convert minutes back to Date
SecondsToDate - Convert seconds back to Date
SetDay - Replace the day with different value

End Copies
SetHour - Set the hour of the time
SetMin - Set the minute of the time
SetMonth - Change the month
SetSec - Set the second of the time
SetYear - Set the year of the date
StrMonth -
StrMonthShort -

Types

Constants

First
HoursPerDay
MinsPerHour
MonthsPerYear
SecondsPerMin
ValidDateChar

Variables


Functions


function BeginOfMonth(D: TDateTime): TDateTime;

Return move the day to the begin of the month

function BeginOfYear(D: TDateTime): TDateTime;

Return move the day to the begin of the year

function DateToHours(Src: TDateTime): Integer;

Calculate date by hours

function DateToMinutes(Src: TDateTime): Integer;

Calculate date by minutes

function DateToSeconds(Src: TDateTime): Integer;

Calculate date by seconds

function DayInMonth(Year, Month: Integer): Integer;

Return how many days in the given year of month

procedure DecDay(var Dest: TDateTime; A: Integer);

Decrease days in DateTime

procedure DecHour(var Dest: TDateTime; A: Integer);

Decrease hours in DateTime

procedure DecMin(var Dest: TDateTime; A: Integer);

Decrease minutes in DateTime

procedure DecMonth(var Dest: TDateTime; A: Integer);

Decrease months in DateTime

procedure DecSec(var Dest: TDateTime; A: Integer);

Decrease seconds in DateTime

procedure DecYear(var Dest: TDateTime; A: Integer);

Decrease years in DateTime

function EndOfMonth(D: TDateTime): TDateTime;

Return move the day to the end of the month

function EndOfYear(D: TDateTime): TDateTime;

Return move the day to the end of the year

function EStrToDate(Str: String): Integer;


function GetDay(Dest: TDateTime): Integer;

Return the day of the date

Date reading functions


function GetHour(Dest: TDateTime):Integer;

Get the hour of the time

function GetMin(Dest:TDateTime): Integer;

Get the minute of the time

function GetMonth(Dest: TDateTime): Integer;

Return the month of the date

These procedures are copied from xProcs by } { Copyright (c) 1995 Stefan Böther } { stefc@fabula.com


function GetSec(Dest: TDateTime): Integer;

Return the second of the time

function GetYear(Dest: TDateTime): Integer;

Return the year of the date

function HoursToDate(A: Integer): TDateTime;

Convert hours back to Date

procedure IncDay(var Dest: TDateTime; A: Integer);

Increase days in DateTime

procedure IncHour(var Dest: TDateTime; A: Integer);

Increase hours in DateTime

procedure IncMin(var Dest: TDateTime; A: Integer);

Increase minutes in DateTime

procedure IncMonth(var Dest: TDateTime; A: Integer);

Increase months in DateTime

procedure IncSec(var Dest: TDateTime; A: Integer);

Increase seconds in DateTime

procedure IncYear(var Dest: TDateTime; A: Integer);

Increase Years in DateTime

function IsLeapYear(Year: Word): Boolean;

Return if given year is Leap Year

function MinutesToDate(A: Integer): TDateTime;

Convert minutes back to Date

function SecondsToDate(A: Integer): TDateTime;

Convert seconds back to Date

function SetDay(Dest: TDateTime; A: Word): TDateTime;

Replace the day with different value

End Copies


function SetHour(Dest:TDateTime; A: Word): TDateTime;

Set the hour of the time

function SetMin(Dest:TDateTime; A: Word): TDateTime;

Set the minute of the time

function SetMonth(Dest: TDateTime; A: Word): TDateTime;

Change the month

function SetSec(Dest: TDateTime; A: Word): TDateTime;

Set the second of the time

function SetYear(Dest: TDateTime; A: Word): TDateTime;

Set the year of the date

function StrMonth(i: Integer): String;


function StrMonthShort(i: Integer): String;


Types


Constants

First = 1

HoursPerDay = 24

MinsPerHour = 60

MonthsPerYear = 12

SecondsPerMin = 60

ValidDateChar = ['/', '0'..'9']


Variables