Conv-Time string converter

From Vectorlab

Jump to: navigation, search


Converts seconds to a time string.

{ convert seconds to a time string }
FUNCTION U_TimeStringConverter(seconds : LONGINT): STRING;
BEGIN
   U_TimeStringConverter := Concat(
                Concat(seconds DIV 3600), ':', 
                Concat((seconds MOD 3600) DIV 60), ':', 
                Concat((seconds MOD 3600) MOD 60)
                );
END;


Example
The following procedure prompts for an integer value. If a valid value is entered a dialog will display a time string:
PROCEDURE Test;
VAR
    secs: INTEGER;
 
    FUNCTION U_TimeStringConverter(seconds : LONGINT): STRING;
    BEGIN
       U_TimeStringConverter := Concat(
                    Concat(seconds DIV 3600), ':', 
                    Concat((seconds MOD 3600) DIV 60), ':', 
                    Concat((seconds MOD 3600) MOD 60)
                    );
    END;
 
BEGIN
    secs := IntDialog('Enter an integer value representing seconds:', '60');
    IF NOT DidCancel THEN
        AlrtDialog(U_TimeStringConverter(secs));
END;
Run(Test);
 
Personal tools