Converts a string to a TDateTime value with error default.
function StrToDateTimeDef(const S: string; const Default: TDateTime): TDateTime; overload; function StrToDateTimeDef(const S: string; const Default: TDateTime; const FormatSettings: TFormatSettings): TDateTime; overload;
TDateTime StrToDateTimeDef(const AnsiString S, const TDateTime Default); TDateTime StrToDateTimeDef(const AnsiString S, const TDateTime Default, const TFormatSettings FormatSettings);
SysUtils
Call StrToDateTimeDef to parse a string that specifies a date and time value. If S does not contain a valid date, StrToDateTimeDef returns Default.
The S parameter must use the current locale's date/time format. In the US, this is commonly MM/DD/YY HH:MM:SS format. Specifying AM or PM as part of the time is optional, as are the seconds. Use 24-hour time (7:45 PM is entered as 19:45, for example) if AM or PM is not specified.
Year values between 0 and 99 are converted using the TwoDigitYearCenturyWindow. This value is stored either in a global variable (first form) or as a field in the FormatSettings parameter (second form) See "Currency and Date-Time Formatting Variables" for more information.
The first form of StrToDateTimeDef is not thread-safe, because it uses localization information contained in global variables. The second form of StrToDateTimeDef, which is thread-safe, refers to localization information contained in the FormatSettings parameter. Before calling the thread-safe form of StrToDateTimeDef, 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!
|