Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help needed with time 1

Status
Not open for further replies.

fergmj

Programmer
Feb 21, 2001
276
US
I have a mechanism that when it receives a UDP message, it writes to an ini file the current time.

I need to find a way to use a time and check the currenttime against the &quot;last good time&quot; from my ini file. If the currenttime is 70 minutes after the last good time, then <do something>

Theoretically, I send the UDP message every 60 minutes so it would only see 70 minutes if the mechanism sending the UDP failed...and that is what this is suppose to catch.

Mindy
 
Are you looking for time functions or timer functions? There are several time functions in the Sysutils.h which is (by default) included in BCB projects. For example, to get the current time you could use
Code:
TDateTime TheCurrentTime = Time();
. You could also use
Code:
TDateTime MyINITime = StringToTime(TimeString)
to convert the time in the file from a string to a TDateTime.

James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
James,

I like the way you have it above.

How then would I be able to see if TheCurrentTime is 70 minutes later than MyINITime?

Mindy
 
The might be a couple of ways. Play around with subtracting MyINITime from TheCurrentTime. I don't know if subtraction is overloaded for TDateTime or not.

Another way is too use EncodeTime and/or DecodeTime. (See your help files for more info or check back here). This way you could subtract the hours and minutes from the two and get your difference.

Good Luck. James P. Cottingham

I am the Unknown lead by the Unknowing.
I have done so much with so little
for so long that I am now qualified
to do anything with nothing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top