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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Displaying Time (hh:mm) in TMaskEdit

Status
Not open for further replies.

StevenK

Programmer
Jan 5, 2001
1,294
GB
What I'm trying to achieve must be simple and I can only imagine that I am missing the obvious with this.
I am using Delphi 5 and want to display the time (hh:mm) in a standard TMaskEdit component.
I have set the 'EditMask' property to be '!90:00;1;_' (as set through the 'Short Time' selection available).
However when I display a Time in the component I seem to get the format 'hh:ss' with no minutes displayed.
I'm using the (simple) code that follows :

var
tpTime : TTime;
begin
tpTime := StrToTime('09:15:02');
maskedit1.Text := TimeToStr(tpTime);
end;

I would expect to see '09:15' in the MaskEdit but instead see '09:02'.
I'm obviously (maybe ??) missing the obvious with this one.
Any pointers would be appreciated.
Steve
 
Someone helped to resolve this for me.
They suggested making use of setting 'ShortTimeFormat' and 'LongTimeFormat' to be 'hh:mm'.
HOWEVER if I set the TMaskEdit to use 'ShortTime' I would expect to see the appropriate time (i.e. 09:15) if I set 'ShortTimeFormat' = 'hh:mm' but I do not see this. It is only when I set 'LongTimeFormat' = 'hh:mm' that I see the required result - if I specify 'ShortTime' in the TMaskEdit I would have liked to hope that it would make use of this.
Anyone have any thoughts on this ?
Thanks
Steve
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top