How to set Date ( SOLVED )

How to set Date ( SOLVED )

Postby fafi » Sun May 03, 2009 10:56 am

Hi ! Friends

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

Code: Select all  Expand view

#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

   @ 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

 


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

Thanks for help

Regards
Fafi
Last edited by fafi on Tue May 05, 2009 12:09 am, edited 1 time in total.
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to set Date

Postby ukoenig » 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 :lol:
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.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: How to set Date

Postby fafi » 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 :lol:


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

Regards
Fafi
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to set Date

Postby frose » Sun May 03, 2009 3: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
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg

Re: How to set Date

Postby Silvio » 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
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Re: How to set Date

Postby nageswaragunupudi » Mon May 04, 2009 5:51 pm

In your code, immediately after the line
Code: Select all  Expand view
@ 2, 2 DTPICKER dDate OF oWnd ON CHANGE If( oSay != nil, oSay:Refresh(),)

include this code
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10624
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to set Date

Postby fafi » Tue May 05, 2009 12:09 am

Thanks Mr. Rao..

It's work

Code: Select all  Expand view

#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
User avatar
fafi
 
Posts: 169
Joined: Mon Feb 25, 2008 2:42 am

Re: How to set Date ( SOLVED )

Postby frose » Tue May 05, 2009 8: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
User avatar
frose
 
Posts: 392
Joined: Tue Mar 10, 2009 11:54 am
Location: Germany, Rietberg


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 36 guests

cron