Show: Object Pascal C++
Display Preferences

System.SysUtils.StrToDateTimeDef

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

function StrToDateTimeDef(const S: string; const Default: TDateTime): TDateTime;
function StrToDateTimeDef(const S: string; const Default: TDateTime; const AFormatSettings: TFormatSettings): TDateTime;

C++

extern DELPHI_PACKAGE System::TDateTime __fastcall StrToDateTimeDef(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 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 A.M. or P.M. as part of the time is optional, as are the seconds. Use 24-hour time (7:45 P.M. is entered as 19:45, for example) if A.M. or P.M. is not specified.

Year values from 0 through 99 are converted using TwoDigitYearCenturyWindow. This value is stored either in a global variable (first form) or as a field in the AFormatSettings 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 AFormatSettings parameter. Before calling the thread-safe form of StrToDateTimeDef, you must populate AFormatSettings with localization information. To populate AFormatSettings with a set of default locale values, call TFormatSettings.Create.

See Also

Personal tools
Translations