System.SysUtils.StrToTimeDef
Delphi
function StrToTimeDef(const S: string; const Default: TDateTime): TDateTime;
function StrToTimeDef(const S: string; const Default: TDateTime;
const AFormatSettings: TFormatSettings): TDateTime;
C++
extern DELPHI_PACKAGE System::TDateTime __fastcall StrToTimeDef(const System::UnicodeString S, const System::TDateTime Default)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.SysUtils.pas System.SysUtils.hpp |
System.SysUtils | System.SysUtils |
Description
Converts a string to a TDateTime value, with a default error.
Call StrToTimeDef to parse a string that specifies a time value. If S
does not contain a valid time, StrToTimeDef returns Default
.
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 A.M. or P.M. indicator. The numbers represent hour, minute, and (optionally) second, in that order. If the time is followed by A.M. or P.M., it is assumed to be in 12-hour clock format. If no A.M. or P.M. indicator is included, the time is assumed to be in 24-hour clock format.
The first form of StrToTimeDef is not thread-safe, because it uses localization information contained in global variables. The second form of StrToTimeDef, which is thread-safe, refers to localization information contained in the AFormatSettings
parameter. Before calling the thread-safe form of StrToTimeDef, you must populate AFormatSettings
with localization information. To populate AFormatSettings
with a set of default locale values, call TFormatSettings.Create.