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!

TDateTime method????? 2

Status
Not open for further replies.

XofCDe3rd

Technical User
Nov 9, 2003
120
I want to use a method called DecodeTime() in the TDateTime class, but I am not doing something right.....

I looked up help on it and still cannot work out how to use it

the main reason I want to use this method is that it splits a TDateTime Object into hours, mins, secs,milli secs.

Def of method(from C-Builder)
==============================
void __fastcall DecodeTime(unsigned short* hour, unsigned short* min, unsigned short* sec, unsigned short* msec) const;

my question is how do i get to use hour min sec and msec
I Think I have made a mistake but I as a test I created used TDateTime T and tried to use the Decode Time on T.CurrentTime()(another method to return current system time)and creating temporary variables to store the hours etc.....any help would be most appreciated

TDownAndOut
 
To get current time i use "Now".
But your question:

unsigned short hour, min, sec, msec;

DecodeTime(&hour,&min,&sec,&msec);

This call should now fill in the data in those values.

The thing is that by giving "&hour" (and so forth) as argument it's really a pointer (address) to that variable you are giving, thus enabling the routne to fill in the correct data into the correct location.

Totte
 
To be extra cool you can use also this:

Word hour, min, sec, msec;

Now().DecodeTime(&hour,&min,&sec,&msec);


Now() returns TDateTime object.
DecodeTime is method of this object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top