RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
SysUtils.TryStrToTime Function

Converts a string to a TDateTime value with an error default.

Pascal
function TryStrToTime(const S: string; out Value: TDateTime): Boolean; overload;
function TryStrToTime(const S: string; out Value: TDateTime; const FormatSettings: TFormatSettings): Boolean; overload;
C++
Boolean TryStrToTime(const AnsiString S, TDateTime Value);
Boolean TryStrToTime(const AnsiString S, TDateTime Value, const TFormatSettings FormatSettings);

SysUtils

Call TryStrToTime to parse a string that specifies a time value. If S does not contain a valid time, TryStrToTime returns false.  

The S parameter must consist of two or three numbers, separated by the character defined by the TimeSeparator global variable or its TFormatSettings equivalent, optionally followed by an AM or PM indicator. The numbers represent hour, minute, and (optionally) second, in that order. If the time is followed by AM or PM, it is assumed to be in 12-hour clock format. If no AM or PM indicator is included, the time is assumed to be in 24-hour clock format.  

The first form of TryStrToTime is not thread-safe, because it uses localization information contained in global variables. The second form of TryStrToTime, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of TryStrToTime, you must populate FormatSettings with localization information. To populate FormatSettings with a set of default locale values, call GetLocaleFormatSettings

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!