From dcd6a94ad3a57d63883f785f41a1c6b137815578 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 12 Aug 2007 11:59:49 +0000 Subject: [PATCH] IDEIntf: TDateTimePropertyEditor now tries date+time, date only and time only git-svn-id: trunk@11798 - --- ideintf/propedits.pp | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index aa2be184aa..4d7f954a57 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -4250,9 +4250,35 @@ end; procedure TDateTimePropertyEditor.SetValue(const Value: string); var DT: TDateTime; + ok: Boolean; begin if Value = '' then DT := 0.0 - else DT := StrToDateTime(Value); + else begin + ok:=false; + // first try date+time + try + DT := StrToDateTime(Value); + ok:=true; + except + end; + // then try date without time + if not ok then + try + DT := StrToDate(Value); + ok:=true; + except + end; + // then try time without date + if not ok then + try + DT := StrToTime(Value); + ok:=true; + except + end; + // if all fails then raise exception + if not ok then + StrToDateTime(Value); + end; SetFloatValue(DT); end;