Many thanks,
--
John
(JTSoftware - http://ds.dial.pipex.com/john.topley)
Assuming you're using tDateTime variables, you really don't need to
keep track of the number of seconds:
var
Start, Elapsed : tDatetime;
begin
Start := Now;
{ do something time consuming here }
Elapsed := Now - Start;
end;
However, if you really do need to use seconds, there is a SecsPerDay
constant that you can use:
Elapsed := Seconds / SecsPerDay;
-Mike
TDateTime is a number just like that, so it's fairly easy. SecsPerDay is a Delphi
constant used as below, MyStartDate is a string with the origin of your time
counter in it and SecondsSince is the number of seconds you have.
MyDateTime := StrToDateTime(MyStartDate) + (SecondsSince / SecsPerDay)
The TDateTime help is quite useful on this subject:
"type TDateTime = type Double;
" Delphi stores date and time values in the TDateTime type. The integral part of a
TDateTime value is the number of days that have passed since 12/30/1899. The
fractional part of a TDateTime value is the time of day."
"Example: TDateTime(0) = 12/30/1899 12:00 am"
HTH
Moz
My name is maurice Wasbauer and I read your follow up to a DateTime
question. It seems that you have quite some knowledge about this.
I also have a question related to this subject and maybe you can help
me out.
Is there a way to add or subtract a certain period of hours and/or
minutes of the systemtime and convert the output to a string so I can
display it as a label caption ?
The purpose is to calculate the GMT (Greenwich Mean Time) from the
local (system) time.. Or even more beautiful: make a calculation
between the systemtime and the timezone to automatically calculate the
GMT ???
Hope to hear from you..
Greetings,
Maurice (M.Wasbauer <M.Was...@mcse-nl.demon.nl>
DateTimeToStr() or FormatDateTime will do the string conversion, and
the same technique I suggested before will work for you, although
you will need to convert your days and hours into seconds.
>The purpose is to calculate the GMT (Greenwich Mean Time) from the
>local (system) time..
I believe there are API calls that will tell you this directly. Not
sure what they are, but Delphi Help will probably have them, and if
not try MSDN or the MS web site.
Moz