From:
Martin Liesen <mliesen@netg.se>
Subject:
RE: [delphi] Question regarding Dates
Date: Thu,
13 Jul 1995 00:43:20 +-200
As your
question seams to be a general one, perhaps we should clear things
out once
for all. This is what I have managed to find out about TDateTime
so far.
TDateTime
is actually a floating point number defined like
TYPE TDateTime=float;
The
definition goes something like this;
The real
numer of the floating point matches the days passed since 1st Jan
the year of
0001. The fraction of the floationg point matches the time of
the day,
where .0 would be midnight and .5 would be noon, 0.99999... would
be just
befor midnight,
Using this
representation of time& dates you can easliy calculate several
things,
Days
beetwen dates:
days:=real(date1-date2);
Day of the
week
dow:=date1 div 7;
Add 25
seconds to a date/time:
date:=date+25/(24*60*60);
There are
several routines included in the SysUtils unit, giving you the
possibilty
of converting & formating dates. Checkout the online manual.
A good
startpoint is "TDateTime".
What you
will have problem calculating is WeekNumber of date. If you would
like this
function, I suspect that their is someone out there willing to
suply you
with one, as it's a quite general & usefull code. Myself I use an
old routine
I developed on BP7.0 using a quite simular techniqe as TDateTime.
I'll be
happy to suply anyone with this library if requested.
If I were
into dates below the year of 1700 I would first check out weather
Borland
took in account that there were some ten missing dates, and this leap
was not
introduced simultanious all across the world.
My advice, check this
out if
you're not going to sticking to the latest centuries.