Page 1 of 1

Date GETs with century

Posted: Tue Dec 13, 2005 10:36 pm
by Brian Hays
Has anyone worked it out to have a 4-digit year on a specific date GET independent of SET CENTURY ?

I have particular fields (Birthdays) that should always display full year, but other fields should just be 2-digit years. Using FWH.

Posted: Wed Dec 14, 2005 2:01 am
by DanielPuente
Brian:

You can manage the date as a character variable por the specific get, or you can:

SET CENTURY OFF

REDEFINE GET oFecha VAR vFecha ID 102 FONT oFont2 of oDlg COLOR CLR_BLACK,RGB(255,255,168)
REDEFINE GET oFecha2 VAR vFecha2 ID 34 FONT oFont2 of oDlg COLOR CLR_BLACK,RGB(255,255,168)
oFecha2:bGotFocus:={|| centuryon(oFecha2) }
oFecha2:bLostFocus:={|| centuryoff() }

ACTIVATE DIALOG oDlg CENTERED ON INIT FECHASINIT(oFecha2)

STATIC FUNCTION FECHASINIT(oFecha2)

SET CENTURY ON
oFecha2:Refresh()
SET CENTURY OFF

RETURN NIL

STATIC FUNCTION CENTURYON(oFecha2)

SET CENTURY ON
oFecha2:Refresh()

RETURN NIL

STATIC FUNCTION CENTURYOFF()

SET CENTURY OFF

RETURN NIL


Regards,

Posted: Wed Dec 14, 2005 5:03 am
by Brian Hays
Daniel:
Thanks! Are you using this code for real? It would appear to work for an SDI app, but with lots of modeless windows it might have problems. Even though one GET has focus and SET CENTURY is true, other windows can paint in the background, and would be affected, yes?

Re: Date GETs with century

Posted: Wed Dec 14, 2005 11:10 am
by StefanHaupt
Brian,

I think the simpliest way is to convert the date into a character, put it in the get-field and convert it back later. So you can use any format you want in the get.

Stefan

Posted: Wed Dec 14, 2005 9:17 pm
by Brian Hays
Stefan:

Thanks. Actually I talked this thru with Luis Krause Mantilla and we hacked TClipGet to give us a new feature. I'll be proposing an xHarbour extension to the PICTUREs supported by transform() and GETs to allow @2 to force 2-digit years and @4 to force four digit years at a low level.

But for now our changes to TClipGet work great! All I have to do is give a date GET a picture of "@4" and it always shows the century independently of the global setting :-)