Subject About a change in IBC_DATE.IMP
Author fabiobot
Hi,

Using IB_DATE as an bound control i can change DisplayFormat
property to something like "dd/mm/yyyy" to see the century (year
with four digits).

The problem is using IB_DATE as an unbound control, when i don't
have DisplayFormat because it's a field property but i would like to
see the year with four digits.

With a small change this problem is corrected.

I wrote a small change in IBC_DATE.IMP that will auto-complete the
century if ShortDateFormat year is 'yyyy' (year with century).
By example, if the user enter with:

'08/19/' or '08/19/2' or '08/19/02' => will be changed
to '08/19/2002' and the user will see this change.

Always the current year is used in this conversion.

I would like to obtain permission from the list
to send this change to Jason Wharton.
Somebody does not want this change?

Thanks to all,

Fabio R. Bot Silva.
-------------------------------------


The change is only in ValidateEdit procedure from IBC_DATE.IMP,
see the code below (already is tested).

{$IFDEF IBO_VCL40_OR_GREATER}
procedure TIB_CustomDate.ValidateEdit;
var
tmpStr, S: string;
I :Integer;
begin
tmpStr := FormatMaskText( EditMask, '' );
if Text <> tmpStr then
begin
S := AnsiLowerCase(ShortDateFormat);
if (Copy(S, Length(S) -3, 4) = 'yyyy') and
(Length(Text) = Length(S)) then
begin
I := 4 - Length(Trim(Copy(Text, 7, 4)));
if I > 0 then
Text := Copy(Text, 1, 6) + Copy(DateToStr(Date), 7, I) +
Copy(Text, 7, 4 - I);
end;

if not Assigned( Field ) then
try
StrToDate( Text );
except
if CanFocus then
SetFocus;
Raise;
end;
end;

inherited ValidateEdit;
end;
{$ENDIF}