Subject Re: Date mask
Author Marco Menardi
Oh, well, as far as I remember, there was a complain about this by
Geoff Worboys a long time ago. Since I always use edit mask I did not
follow the problem, but it was right about asking why there was a
change in code forcing a default mask when it was not set.
mmm, I've found the message, here for your (and Jason) convenience:


Geoff Worboys wrote:
-------
Message# 20610
From: Geoff Worboys <geoff@t...>
Date: Sun Sep 22, 2002 3:09 pm
Subject: Date and Time Formatting

Hi All,

I have not been keeping up to date with all IBO changes for a while
due to other committments. I've only just noticed that there is
a change which forces date and time formatting to system defaults
when no DisplayFormat has been specified.

Previously (and still for other types of data) IBO would use
DisplayFormat if defined, otherwise it would use an EditMask if
defined - and then revert to system defaults. I have been relying
on this situation to have my dates formatted via the editmask,
and never bother defining DisplayFormats.

As things stand with the (recent?) change all my date/time fields
change their display depending on whether they are focused
(formatted with the editmask) or not focused (formatted with the
system defaults). This is rather annoying. I could run around
and try and duplicate all the formatting instructions of my
editmasks inside DisplayFormat but it does seem rather a waste.

Can anyone tell me why the previous method of producing display
text was inadequate?

--
Geoff Worboys
Telesis Computing
-------


--- In IBObjects@yahoogroups.com, Ales Kahanek <akahanek@a...> wrote:
> Hi Marco,
> actually I found a solution to this. The problem does not concern to
> IB_Date only but generally to all DATE and DATETIME fields. I do not
> want to use _any_ date and datetime mask because the entered value is
> appropriatelly changed by my own datetime processing function. I
> commented out a portion of function TIB_Column.GetEditMask: string; in
> the IBA_Column.imp
>
> it looks like this:
>
> if ( FMaskIntf = nil ) and ( Length( FEditMask ) >= 6 ) and
> ( Copy( FEditMask, 1, 2 ) = '::' ) then
> SetEditMask( FEditMask );
> Result := FEditMask;
> if Result = '' then
> begin
> if IsDateTime then
> begin
> // if IsDateOnly then
> // begin
> // tmpS := UpperCase( FDateOnlyFmt );
> // tmpInt := Pos( 'DD' + DateSeparator, tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 3 );
> // tmpInt := Pos( 'D' + DateSeparator, tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 2 );
> // tmpInt := Pos( 'MM' + DateSeparator, tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 3 );
> // tmpInt := Pos( 'M' + DateSeparator, tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 2 );
> // tmpInt := Pos( 'YY', tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 2 );
> // tmpInt := Pos( 'YY', tmpS );
> // if tmpInt > 0 then
> // System.Delete( tmpS, tmpInt, 2 );
> // if tmpS = '' then
> // Result := '!99' + DateSeparator + '99' + DateSeparator +
> '9999;1; ';
> // end
> // else
> // if IsTimeOnly then
> // Result := '!99' + TimeSeparator + '99' + TimeSeparator +
'99;1; ';
> end;
>
> then in the
>
> procedure TIB_ColumnDateTime.SetAsString( const NewValue: string );
>
> I added the following lines:
>
> if Assigned( FProcessDateStringProc ) then
> FProcessDateStringProc( tmpVal, IsTimeOnly or ( SQLType =
> SQL_TYPE_TIME ) or ( SQLType = SQL_TYPE_TIME_ ) );
>
>
> In the IB_Components.pas I added these lines
>
> type
> TProcessDateStringProc = procedure(var AStr: string; const
> IsTimeOnly: boolean);
> var
> FProcessDateStringProc: TProcessDateStringProc;
>
> and in my application I define my own procedure of type
> TProcessDateStringProc and assign it to the FProcessDateStringProc
> variable.
>
> Something similar (I mean the datetime processing function) can be
found
> in the excellent Enhanced components from Geoff Worboys.
>
> Now I am happy with this solution, little bit nasty but users are
satisfied.
>
> Thank you for your help.
> Ales
>
> Marco Menardi wrote:
>
> > --- In IBObjects@yahoogroups.com, Ales Kahanek <akahanek@a...> wrote:
> >
> >>Hi,
> >>when editing DATE column, there is a default mask ' . . ' (it is
> >>the dd.mm.yyyy mask by default). I do not want any edit mask to show
> >>while entering the date value, because I use my own entered value
> >>processing (I want to enter for example +14d - this mean + 14 days
> >>from today and my processing procedure changes this string
> >>appropriately). This scenario has worked perfectly but now users
> >>complain that due to the default mask they are not able to enter the
> >>plus sign etc. I do not know when and what was changed in the
> >>sources. How to achieve IBO not showing default date mask? I must
> >>add, that I do not use any FieldsEditMask or FieldsDisplayFormat
> >>property.
> >>
> >>Using D7, IBO 4.2e, WinXP Pro
> >>
> >>This is second attempt, the previous question 7 weeks ago nobody
> >>answered. I really appreciate your attention.
> >>
> >>Thank you
> >>Ales Kahanek
> >
> >
> >
> > mmm don't know, but just to try a fix (I've not tried this, sorry,
> > hope it will work): edit IBC_Date.imp and try:
> > procedure TIB_CustomDate.UpdateMask( UnboundMask: string );
> > begin
> > if UnboundMask = '' then
> > UnboundMask := '!99' + DateSeparator + '99' + DateSeparator +
> > '9999;1; ';
> > inherited UpdateMask( UnboundMask );
> > end;
> >
> > has to became:
> > procedure TIB_CustomDate.UpdateMask( UnboundMask: string );
> > begin
> > if (not Assigned( Field )) and (UnboundMask = '') then
> > UnboundMask := '!99' + DateSeparator + '99' + DateSeparator +
> > '9999;1; ';
> > inherited UpdateMask( UnboundMask );
> > end;
> >
> > Let me know. If it's Ok, we can sent this patch to Jason for inclusion
> > in the official IBO tree.
> > regards
> > Marco Menardi
> >