From Clomosy Docs
No edit summary |
No edit summary |
||
| Line 14: | Line 14: | ||
<b>Example</b><br> | <b>Example</b><br> | ||
<pre> | <pre> | ||
var | var | ||
| Line 31: | Line 31: | ||
} | } | ||
</pre> | </pre> | ||
Revision as of 12:59, 13 November 2024
function StrToTime(const S: string):TclDateTime;
Converts a string to a TclDateTime value.
Call StrToTime to parse a string that specifies a time value. If S does not contain a valid time, StrToTime raises an EConvertError exception.
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)
Example
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