티스토리 뷰

Delphi

function StrToTimeDef(const S: string; const Default: TDateTime): TDateTime;

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

C++

extern 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.

문자열을 TDateTime 값으로 변환합니다. 이 값은 기본 오류입니다.

StrToTimeDef를 호출하여 시간 값을 지정하는 문자열을 구문 분석합니다.

S 가 유효한 시간을 포함하지 않으면, StrToTimeDefDefault을 반환합니다.

S 매개변수는 TimeSeparator 전역변수 또는 해당 TFormatSettings 에 동등한 문자로 정의된, 구분된 두 개 또는 세 개의 숫자로 구성되어야 하며, 선택적으로 A.M이 뒤에옵니다. 또는 P.M. 지시자.

 

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.

숫자는 시, 분 및 초 (선택 사항) 순으로 나타냅니다.

시간이 A.M. 또는 P.M.의 경우 12 시간 형식으로 가정합니다.

A.M. 또는 P.M. 표시기가 포함되어 있으면, 시간은 24 시간제 형식으로 간주됩니다.

StrToTimeDef의 첫 번째 형식은 전역변수에 포함된 지역화 정보를 사용하므로, 스레드로부터 안전하지 않습니다.

스레드로부터 안전한 StrToTimeDef의 두 번째 형식은 AFormatSettings 매개변수에 포함된 지역화 정보를 참조합니다.

StrToTimeDef의 스레드 안전 형식을 호출하기 전에 AFormatSettings 에 지역화 정보를 채워야 합니다.

AFormatSettings 에 기본 로캘 값을 채우려면 TFormatSettings.Create를 호출합니다.

 

Example

var

  TimeDate: TDateTime;

begin

  // 결과: 2017-04-16 오전 9:00:00

  TimeDate := StrToDateTimeDef('2017-04-16 09:00:00', Now());

  Writeln(DateTimeToStr(TimeDate));

 

  // 결과: 2017-04-16 오후 3:15:34

  TimeDate := StrToDateTimeDef('2017-99-99 99:00:00', Now());

  Writeln(DateTimeToStr(TimeDate));

 

  Readln;

end.

 

parse 미국식 [pɑ:rs]   영국식 [pɑ:z]   

(문장을 문법적으로) 분석하다

consist 미국식   영국식   중요

1. (부분·요소로) 되어 있다(be made up) ((of))
2. (
…에) 있다(lie), (…에) 존재하다 ((in))
3. (
…와) 양립하다 ((with, together))

equivalent 미국·영국 [ɪ|kwɪvələnt]   영국식   중요

1. (가치의미중요도 등이) 동등한
2. (
…에) 상당하는 것, 등가물

 

출처: http://docwiki.embarcadero.com/Libraries/XE2/en/System.SysUtils.StrToTimeDef

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함