Date GETs with century

Post Reply
Brian Hays
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Date GETs with century

Post 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.
-BH
DanielPuente
Posts: 108
Joined: Sun Oct 09, 2005 6:12 pm
Location: Mar del Plata - Argentina
Contact:

Post 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,
Daniel Puente
Mar del Plata, Argentina
danielpuente@speedy.com.ar
puenteda@hotmail.com
Brian Hays
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Post 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?
-BH
StefanHaupt
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Date GETs with century

Post 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
Brian Hays
Posts: 20
Joined: Fri Oct 14, 2005 7:56 am

Post 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 :-)
-BH
Post Reply