FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to set Date ( SOLVED )
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
How to set Date ( SOLVED )
Posted: Sun May 03, 2009 10:56 AM
Hi ! Friends

How to set date format in DD/MM/YYYY for DTPICKER class ..

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "dtpicker.ch"

FUNCTION Main()

   local oWnd, oSay
   local dDate

   set date british 
   set century on


   dDate := Date()

   DEFINE WINDOW oWnd TITLE "DTPicker from code ...."

   @ 2, 2 DTPICKER dDate OF oWnd ON CHANGE If( oSay != nil, oSay:Refresh(),) // <strong>not work MM/DD/YYYY</strong>

   @ 3, 30 SAY oSay PROMPT "Date: "+ Dtoc( dDate ) OF oWnd SIZE 200, 20 // <strong>work here DD/MM/YYYY</strong>

   @ 6, 2 BUTTON "From resources ..." OF oWnd ACTION FromRes( oWnd ) SIZE 150, 30

   ACTIVATE WINDOW oWnd

return nil

FUNCTION FromRes( oWnd )

   local oDlg, oSay
   local dDate := Date()

   DEFINE DIALOG oDlg RESOURCE "DTPTEST"

   REDEFINE DTPICKER dDate ID 101 OF oDlg ;
      ON CHANGE oSay:Refresh()

   REDEFINE SAY oSay PROMPT "Date: "+ Dtoc(dDate) ID 102 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return nil

procedure AppSys  // Xbase++ requirement

return


Not work..
get DTPICKER always display MM/DD/YYYY

Thanks for help

Regards
Fafi
Posts: 4043
Joined: Wed Dec 19, 2007 06:40 PM
Re: How to set Date
Posted: Sun May 03, 2009 11:27 AM
Hello Fafi,

have a look at the TRANSFORM - Function.

SET DATE BRITISH
dDate := TRANSFORM( DATE(), @D ) // Shows the Date-Format, defined in SET DATE
Result : 03/05/09

Regards
Uwe :-)
Since 1995 ( the first release of FW 1.9 )

i work with FW.

If you have any questions about special functions, maybe i can help.
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: How to set Date
Posted: Sun May 03, 2009 12:13 PM
ukoenig wrote:Hello Fafi,

have a look at the TRANSFORM - Function.

SET DATE BRITISH
dDate := TRANSFORM( DATE(), @D ) // Shows the Date-Format, defined in SET DATE
Result : 03/05/09

Regards
Uwe :-)


Still not work.. please compile my source code above..

Regards
Fafi
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: How to set Date
Posted: Sun May 03, 2009 03:45 PM

Hello fafi,

The object ‘TDatePick’ uses the date format from the system!

Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86
Posts: 3107
Joined: Fri Oct 07, 2005 06:28 PM
Re: How to set Date
Posted: Mon May 04, 2009 12:53 AM

STAT FUNC Set_Date()
LOCAL oDlg, oGet, lChg:=.F.
LOCAL dDate:=Date()
DEFINE DIALOG oDlg RESOURCE "SET_DATE" FONT oApp:oFont
REDEFINE DTPICKER oGet VAR dDate ID 10 OF oDlg ;
ON CHANGE oGet:Refresh()
REDEFINE BUTTON ID 20 OF oDlg ACTION (lChg:=.T.,oDlg:End())
REDEFINE BUTTON ID 30 OF oDlg ACTION (lChg:=.F.,oDlg:End()) CANCEL
ACTIVATE DIALOG oDlg
IF lChg
SetDate(Day(dDate),Month(dDate),Year(dDate))
ENDIF
RETURN (NIL)

Best Regards, Saludos



Falconi Silvio
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to set Date
Posted: Mon May 04, 2009 05:51 PM
In your code, immediately after the line
Code (fw): Select all Collapse
@ 2, 2 DTPICKER dDate OF oWnd ON CHANGE If( oSay != nil, oSay:Refresh(),)

include this code
Code (fw): Select all Collapse
SendMessage( ATail( oWnd:aControls ):hWnd, 4101, 0, StrTran( lower( Set( _SET_DATEFORMAT ) ), 'mm', 'MM' ) )

Now dtpicker will show the date in whatever the DATEFORMAT is Set.
Regards



G. N. Rao.

Hyderabad, India
Posts: 169
Joined: Mon Feb 25, 2008 02:42 AM
Re: How to set Date
Posted: Tue May 05, 2009 12:09 AM
Thanks Mr. Rao..

It's work

Code (fw): Select all Collapse
#include "FiveWin.ch"
#include "dtpicker.ch"

FUNCTION Main()

   local oWnd, oSay
   local dDate

   set date british
   set century on


   dDate := Date()

   DEFINE WINDOW oWnd TITLE "DTPicker from code ...."

   @ 2, 2 DTPICKER dDate OF oWnd ON CHANGE If( oSay != nil, oSay:Refresh(),) // not work MM/DD/YYYY

   SendMessage( ATail( oWnd:aControls ):hWnd, 4101, 0, StrTran( lower( Set( _SET_DATEFORMAT ) ), 'mm', 'MM' ) )


   @ 3, 30 SAY oSay PROMPT "Date: "+ Dtoc( dDate ) OF oWnd SIZE 200, 20 // work here DD/MM/YYYY

   @ 6, 2 BUTTON "From resources ..." OF oWnd ACTION FromRes( oWnd ) SIZE 150, 30

   ACTIVATE WINDOW oWnd

return nil

FUNCTION FromRes( oWnd )

   local oDlg, oSay
   local dDate := Date()

   DEFINE DIALOG oDlg RESOURCE "DTPTEST"

   REDEFINE DTPICKER dDate ID 101 OF oDlg ;
      ON CHANGE oSay:Refresh()

   REDEFINE SAY oSay PROMPT "Date: "+ Dtoc(dDate) ID 102 OF oDlg

   ACTIVATE DIALOG oDlg CENTERED

return nil

procedure AppSys  // Xbase++ requirement

return


Many thanks again..

Regards
Fafi
Posts: 392
Joined: Tue Mar 10, 2009 11:54 AM
Re: How to set Date ( SOLVED )
Posted: Tue May 05, 2009 08:07 AM
Rao,

thank you very much for this piece of code.

For better understanding, I've searched the forum and found this thread: viewtopic.php?f=3&t=8249

Antonio wrotes:
We will wait to get some feedback from users before implementing it in the Class.


So for me it is only logic, to change the behavior of the datepicker control to use the date format of the app!
Windows 11 Pro 22H2 22621.1848

Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384

Harbour 3.2.0dev (r2008190002)

FWH 23.10 x86

Continue the discussion