Hi, how i can get msgdate in portuguese?
Thanks.
MsgDate
Re: MsgDate
Code: Select all
// FiveWin MsgDate() function sample
#include "FiveWin.ch"
REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850
Static oWnd
FUNCTION Main()
SET 3DLOOK ON
SET EPOCH TO 1950
SET CENTURY ON
SET DATE FORMAT TO "DD/MM/YYYY"
HB_LANGSELECT( 'PT' ) // Default language is now Portuguese
HB_SETCODEPAGE( "PT850" )
FWSetLanguage(4) // Portuguese = 4
DEFINE WINDOW oWnd FROM 1, 1 TO 12, 32 TITLE "TEST" MENU MakeMenu()
ACTIVATE WINDOW oWnd
RETURN( NIL )
Function MakeMenu()
Local oMenu
MENU oMenu
MENUITEM '&Menu'
MENU
MENUITEM "&1 MsgDate (Use DATE())" ACTION MsgInfo(MsgDate(DATE()), "Date Returned")
MENUITEM "&2 MsgDate (Use 03/25/97)" ACTION MsgInfo(MsgDate(TToD("03/25/97", "MM/DD/YY")), "Date Returned")
MENUITEM "&3 MsgDate (Use 2002/11/24)" ACTION MsgInfo(MsgDate(TToD("2002/11/24", "YYYY/MM/DD")), "Date Returned")
ENDMENU
ENDMENU
Return (oMenu)
//----------------------------------------------------------------------------//
function MsgDate( dDate, cPrompt, oGet )
local oDlg, oFont, oCursor, dSelect, dWork
local nRow, nCol, nMonth, nYear
local aMonths := {}
local aDays := {"Sun","Mon","Tue","Wed","Thr","Fri","Sat"}
DEFAULT dDate := Date(), cPrompt := "Select a date"
FOR nMonth = 1 to 12
AADD( aMonths, cMonth(TToD( "01/" + padl( nMonth, 2 ) + "/98", "DD/MM/YY" )))
NEXT nMonth
cLongDate := dDateToString( dDate )
cCYear := str(year(dDate), 4)
nYear := Year( dDate )
nMonth := Month( dDate )
dSelect := dDate
dWork := TToD( "01/" + padl( nMonth, 2 ) + "/" + ;
right( cCYear, 2), "DD/MM/YY" )
while DoW( dWork ) > 1
dWork --
enddo
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -14
DEFINE DIALOG oDlg SIZE 250, 235 TITLE cPrompt FONT oFont // -> 6 Semanas
@ 0.2, .75 COMBOBOX nMonth ITEMS aMonths SIZE 50,150 OF oDlg ;
ON CHANGE MoveCalendar(oDlg, 1, nMonth )
@ 3.5, 63 BTNBMP PROMPT "-" SIZE 11, 11 ACTION ( MoveCalendar(oDlg, 3 ))
@ 3.5, 105 BTNBMP PROMPT "+" SIZE 11, 11 ACTION ( MoveCalendar(oDlg, 4 ))
@ 0.2, 9.3 GET nYear SIZE 31, 12 OF oDlg
ATail( oDlg:aControls ):Cargo = "YEAR"
@ 1.1, (35 - LEN( cLongDate )) / 4.8 SAY cLongDate COLOR CLR_HBLUE
ATail( oDlg:aControls ):Cargo = "DATE"
// Veja se a sua versao suporta FWSTRING
@ 2, 1 SAY "Sun Mon Tue Wed Thr Fri Sat" COLOR CLR_HRED
for nRow = 2 to 7
for nCol = 1 to 7
@ (nRow * 10) + 20, ( nCol * 16 ) - 6 BTNBMP ;
PROMPT Str( Day( dWork ), 2 ) SIZE 12, 12 NOBORDER ;
ACTION ( oDlg:Cargo := ::Cargo, oDlg:End( IDOK ) )
ATail( oDlg:aControls ):Cargo = dWork
ATail( oDlg:aControls ):nClrText = If( dWork == Date(), CLR_HRED,;
If( dWork == dDate, CLR_HBLUE, If( Month( dWork ) == nMonth,;
CLR_BLACK, CLR_GRAY ) ) )
if ATail( oDlg:aControls ):Cargo == dDate
ATail( oDlg:aControls ):lPressed = .t.
ATail( oDlg:aControls ):cToolTip = "Selected"
elseif ATail( oDlg:aControls ):Cargo == Date()
ATail( oDlg:aControls ):cToolTip = "Today"
else
ATail( oDlg:aControls ):cToolTip = DToC(ATail( oDlg:aControls ):Cargo)
endif
dWork++
next
next
oDlg:Cargo := dDate
ACTIVATE DIALOG oDlg CENTERED
dSelect := oDlg:Cargo
if oGet != NIL
oGet:VarPut( If( oDlg:nResult == IDOK, dSelect, dDate ) )
oGet:Refresh()
endif
return If( oDlg:nResult == IDOK, dSelect, dDate )
//-----------------------------------------------------------------------//
static function MoveCalendar( oDlg, nMode, nVar)
local dSelect := oDlg:Cargo
local n
local nFirstButton := 0
local nLastButton := 0
local nDate := 0
local nSkip := 0
local nPDate := 0
local nPYear := 0
local nDay, nMonth, nYear
local dWork
local nDays := 0
for n := 1 TO Len( oDlg:aControls )
if oDlg:aControls[ n ]:ClassName() == "TBTNBMP"
nFirstButton := If( nFirstButton == 0, If(nSkip<2, 0, n), nFirstButton )
nLastButton := n
nSkip++
oDlg:aControls[ n ]:lPressed := .F.
endif
if ValType( oDlg:aControls[ n ]:Cargo ) == "C"
if oDlg:aControls[ n ]:Cargo == "DATE"
nPDate := n
endif
if oDlg:aControls[ n ]:Cargo == "YEAR"
nPYear := n
endif
endif
next n
nDay := Day( dSelect )
nMonth := Month( dSelect )
nYear := Year( dSelect )
do case
case nMode == 1
nMonth := nVar
case nMode == 3
nYear --
case nMode == 4
nYear ++
endcase
dSelect := TToD( padl( nDay, 2) + "/" + ;
padl( nMonth, 2 ) + "/" + ;
right(padl( nYear, 4 ), 2), "DD/MM/YY" )
cLongDate := dDateToString( dSelect )
oDlg:aControls[ nPDate ]:cMsg := cLongDate
oDlg:aControls[ nPYear ]:VarPut( nYear)
dWork := TToD( "01/" + padl( nMonth, 2 ) + "/" + right(padl( nYear, 4 ), 2), "DD/MM/YY" )
while DoW( dWork ) > 1
dWork --
enddo
for n := nFirstButton TO nLastButton
oDlg:aControls[ n ]:SetText( Str( Day( dWork ), 2 ) )
oDlg:aControls[ n ]:Cargo = dWork
oDlg:aControls[ n ]:nClrText = If( dWork == Date(), CLR_HRED,;
If( dWork == dSelect, CLR_HBLUE, If( Month( dWork ) == nMonth,;
CLR_BLACK, CLR_GRAY ) ) )
oDlg:aControls[ n ]:cToolTip = DToC(dWork)
if dWork == dSelect
oDlg:aControls[ n ]:lPressed = .T.
oDlg:aControls[ n ]:cToolTip = "Selected"
endif
dWork++
next n
for n := 1 TO Len( oDlg:aControls )
oDlg:aControls[ n ]:Refresh()
next n
oDlg:Cargo := dSelect
return nil
//-----------------------------------------------------------------------//
static function dDateToString( dDate )
return cDow( dDate) + " " + cMonth( dDate ) + " " + Str( Day ( dDate), 2) +;
", " + Str( Year( dDate), 4)
//-----------------------------------------------------------------------//
static function TToD(cDate, cFormat)
LOCAL cDay, cMonth, cYear, cLYear
LOCAL RetDate
LOCAL cClipFormat := UPPER(SET(4))
LOCAL nEPOCH := SET(5)
IF VALTYPE(cFormat) != "C"
cFormat := "MM/DD/YY"
ENDIF
IF EMPTY(cDate)
RetDate := CTOD("")
ELSE
IF ("YYYY" $ cFormat)
cLYear := PADR( VAL( SUBSTR(cDate, AT("YYYY", cFormat), 4 )), 4, "0")
cYear := PADL( VAL( RIGHT(cLYear, 2)), 2, "0")
ELSEIF ("YY" $ cFormat)
cYear := PADL( VAL( SUBSTR(cDate, AT("YY", cFormat), 2 )), 2, "0")
IF VAL("19" + cYear) > nEPOCH
cLYear := "19" + cYear
ELSE
cLYear := "20" + cYear
ENDIF
ENDIF
IF ("MM" $ cFormat)
cMonth := PADL( ALLTRIM( SUBSTR(cDate, AT("MM", cFormat), 2 )), 2, "0")
ENDIF
IF ("DD" $ cFormat)
cDay := PADL( ALLTRIM( SUBSTR(cDate, AT("DD", cFormat), 2 )), 2, "0")
ENDIF
IF ("YYYY" $ cClipFormat)
cClipFormat := LEFT(cClipFormat, AT("YYYY", cClipFormat) - 1 ) + cLYear + SUBSTR(cClipFormat, AT("YYYY", cClipFormat) + 4 )
ELSEIF ("YY" $ cClipFormat)
cClipFormat := LEFT(cClipFormat, AT("YY", cClipFormat) - 1 ) + cYear + SUBSTR(cClipFormat, AT("YY", cClipFormat) + 2 )
ENDIF
IF ("MM" $ cClipFormat)
cClipFormat := LEFT(cClipFormat, AT("MM", cClipFormat) - 1 ) + cMonth + SUBSTR(cClipFormat, AT("MM", cClipFormat) + 2 )
ENDIF
IF ("DD" $ cClipFormat)
cClipFormat := LEFT(cClipFormat, AT("DD", cClipFormat) - 1 ) + cDay + SUBSTR(cClipFormat, AT("DD", cClipFormat) + 2 )
ENDIF
RetDate := CTOD(cClipFormat)
ENDIF
return (RetDate)
João Santos - São Paulo - Brasil