From Clomosy Docs

(Created page with " function StrToTime(const Time string):TclDateTime; The StrToTime function attempts to convert a time as a string Date into a TclDateTime value. The time string must adhere to the format of the LongTimeFormat value, and use the TimeSeparator character to separate the hour, minute and second values. The default format is hour:minute:second.milli-seconds, where : :The hour must be 0..23 :The minute must be 0..59 (optional) :The second must be 0..59 (optional) :The mil...")
 
No edit summary
Line 11: Line 11:


'''Example:'''<br>
'''Example:'''<br>
'''var'''
:'''Base Syntax'''
  myTime : TclDateTime;<br>
  var
'''begin'''<br>
    myTime : TclDateTime;
  myTime := StrToTime('3PM');
 
  ShowMessage('3PM      = '+TimeToStr(mytime));
  begin
  myTime := StrToTime('15');
 
  ShowMessage('15      = '+TimeToStr(mytime));
    myTime := StrToTime('3PM');
  myTime := StrToTime('15:03');
    ShowMessage('3PM      = '+TimeToStr(mytime));
  ShowMessage('15:03    = '+TimeToStr(mytime));
    myTime := StrToTime('15');
  myTime := StrToTime('15:03:45');
    ShowMessage('15      = '+TimeToStr(mytime));
  ShowMessage('15:03:45 = '+TimeToStr(mytime));<br>
    myTime := StrToTime('15:03');
'''end;'''
    ShowMessage('15:03    = '+TimeToStr(mytime));
    myTime := StrToTime('15:03:45');
    ShowMessage('15:03:45 = '+TimeToStr(mytime));
 
  end;
 
:'''TRObject Syntax'''
  var
    myTime : TclDateTime;
 
  {
 
    myTime = StrToTime('3PM');
    ShowMessage('3PM      = '+TimeToStr(mytime));
    myTime = StrToTime('15');
    ShowMessage('15      = '+TimeToStr(mytime));
    myTime = StrToTime('15:03');
    ShowMessage('15:03    = '+TimeToStr(mytime));
    myTime = StrToTime('15:03:45');
    ShowMessage('15:03:45 = '+TimeToStr(mytime));
 
  }


'''Output:'''<br>
'''Output:'''<br>

Revision as of 14:19, 7 February 2024

function StrToTime(const Time string):TclDateTime;

The StrToTime function attempts to convert a time as a string Date into a TclDateTime value. The time string must adhere to the format of the LongTimeFormat value, and use the TimeSeparator character to separate the hour, minute and second values. The default format is hour:minute:second.milli-seconds, where :

The hour must be 0..23
The minute must be 0..59 (optional)
The second must be 0..59 (optional)
The milli-secs must be 0..999 (optional)


You may use the current AM and PM value, or the literals 'AM', 'am', 'PM' and 'pm' before or after the time.

Example:

Base Syntax
 var
   myTime : TclDateTime;
 
 begin
 
   myTime := StrToTime('3PM');
   ShowMessage('3PM      = '+TimeToStr(mytime));
   myTime := StrToTime('15');
   ShowMessage('15       = '+TimeToStr(mytime));
   myTime := StrToTime('15:03');
   ShowMessage('15:03    = '+TimeToStr(mytime));
   myTime := StrToTime('15:03:45');
   ShowMessage('15:03:45 = '+TimeToStr(mytime));
 
 end;
TRObject Syntax
 var
   myTime : TclDateTime;
 
 {
 
   myTime = StrToTime('3PM');
   ShowMessage('3PM      = '+TimeToStr(mytime));
   myTime = StrToTime('15');
   ShowMessage('15       = '+TimeToStr(mytime));
   myTime = StrToTime('15:03');
   ShowMessage('15:03    = '+TimeToStr(mytime));
   myTime = StrToTime('15:03:45');
   ShowMessage('15:03:45 = '+TimeToStr(mytime));
 
 }

Output:

3PM      = 15:00:00
15       = 15:00:00
15:03    = 15:03:00
15:03:45 = 15:03:45