Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread Trailing space character on 24h time format
Mon, Jun 15 2015 11:12 AMPermanent Link

Doc

function PresentTime: String;
var
T: String;
begin
FormatSettings.TimeSeparator:=':';
FormatSettings.ShortTimeFormat := 'HH:mm';
T := TimetoStr (Now);
//if Length (T) > 5 then T := Copy (T,1,5);
Result := '*' + T + '*';
end;

I would like to have the time String in 24h format, e.g. 16:40.
The function above leads to a result with a trailing space character (*16:40 *), so I have to insert an additional line for cutting this character from the end (commented out above).
Is this a sort of bug? In the 12h format there is a space character before the AM or PM.
Mon, Jun 15 2015 12:21 PMPermanent Link

Raul

Team Elevate Team Elevate

On 6/15/2015 11:12 AM, Doc wrote:
>   T := TimetoStr (Now);
>   //if Length (T) > 5 then T := Copy (T,1,5);

or just  T := '*' + trim(T) + '*';

> The function above leads to a result with a trailing space character (*16:40 *), so I have to insert an additional line for cutting this character from the end (commented out above).
> Is this a sort of bug? In the 12h format there is a space character before the AM or PM.

Yes it's a bug - it's caused by the "if (I < 2) then" section after the
"case" section - it inserts a space if there is no seconds specifier in
the shorttimeformat.

if you used a format with seconds (HH:mm:ss) it would be OK.

Meanwhile just doing a trim should work around the issue

Raul


Mon, Jun 15 2015 4:08 PMPermanent Link

Doc

Raul wrote:

or just  T := '*' + trim(T) + '*';

Meanwhile just doing a trim should work around the issue
_____________________________________________

Thank you very much !
I wasn't aware of a trim function yet, very helpful !
(The * were just to visualize the space charactes)
Tue, Jun 16 2015 7:50 AMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Doc,

<< The function above leads to a result with a trailing space character
(*16:40 *), so I have to insert an additional line for cutting this
character from the end (commented out above).   Is this a sort of bug? In
the 12h format there is a space character before the AM or PM. >>

This is now fixed in both 1.x and the 2 preview.  The fix for 2 will be in
the final release.

Tim Young
Elevate Software
www.elevatesoft.com
Image