FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour error on NToCDOW
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
error on NToCDOW
Posted: Sun Aug 05, 2018 11:18 PM
i make a function to converte date string into italian date string

Code (fw): Select all Collapse
Function cf(dTemp)
   LOCAL f, m, cMese, dFech,dDay,d
   Local i,c
   local aMesi[ 12 ]
   local aWeek[ 7 ]

   AEval( aMesi,  { |c,i| aMesi[ i ]  := NToCMonth( i ) } )
   AEval( aWeek, { |c,i| aWeek[ i ] :=  NToCDOW( i ) } )

 *  xbrowser aWeek
  * xbrowser aMesi

   f:=DTOS (dTemp)
   m:=MONTH(dTemp)
   d:=dow(dtemp)
    *  ? d
   cMese:=IF(m<>0, aMesi[m] ,"" )
   dday :=IF(d<>0, aWeek[d] ,"")

   dFech:=IF(m<>0,dday+", "+ SubStr(f,7,2)+' '+cMese+' '+SubStr(f,1,4),'')
   RETURN (dFech)



sample : "Lunedì, 6 Agosto 2018 "

I set the Language to Italian with
REQUEST HB_LANG_IT
and
SET DATE ITALIAN
HB_LangSelect("IT")

but the NToCDOW and NToCMonth give me the day string and month string in english and bad

for a sample today is Monday but the function show me friday why ?



for a sample I cannot show sunday on Italian language why ?

please try this small test


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

#include "constant.ch"
//----------------------------------------------------------------------------//
REQUEST HB_LANG_IT

function Main()

   local oDlg , aGet := Array(5), oBtnCal
   local dDataNote:=cf(date())

   SET _3DLOOK ON
  SET CENTURY ON
  SET DATE ITALIAN

    HB_LangSelect("IT")


     DEFINE DIALOG oDlg  SIZE 400,200


    @ 12,5 SAY "Note di :" OF  oDlg PIXEL SIZE 100,20 TRANSPARENT
    @ 10,35 GET aGet[1] VAR dDataNote SIZE 80,12 PIXEL OF oDlg ; 
   BITMAP  ".\bitmaps\cal.bmp"  ACTION NIL


    @ 07,170  BTNBMP oBtnCal FILENAME ".\bitmaps\date.bmp" FLAT SIZE 20,14 PIXEL OF oDlg NOBORDER

      oBtnCal:oPopUp:= { |oBtn| BtnPopCalMenu( @dDataNote,aGet) }

   ACTIVATE DIALOG oDlg CENTERED

return nil
//---------------------------------------------------------------------//
Function BtnPopCalMenu( dDataNote,aGet)
  Local oPopupDate

     MENU oPopupDate POPUP 2015
       MENUITEM "Oggi"  ACTION  (dDataNote:=date(),aGet[1]:CTEXT(cf(dDataNote)),aGet[1]:refresh())
       MENUITEM "Domani"  ACTION ( dDataNote:=date()+1 ,aGet[1]:CTEXT(cf(dDataNote)),aGet[1]:refresh())
       MENUITEM "DopoDomani"  ACTION ( dDataNote:=date()+2,aGet[1]:CTEXT(cf(dDataNote)),aGet[1]:refresh())
      SEPARATOR
       MENUITEM "Pulisci"  ACTION ( dDataNote:="",aGet[1]:CTEXT((dDataNote)),aGet[1]:refresh())
      ENDMENU

   return oPopupDate
//-------------------------------------------------------------------//

Function cf(dTemp)
   LOCAL f, m, cMese, dFech,dDay,d
   Local i,c
   local aMesi[ 12 ]
   local aWeek[ 7 ]

   AEval( aMesi,  { |c,i| aMesi[ i ]  := NToCMonth( i ) } )
   AEval( aWeek, { |c,i| aWeek[ i ] :=  NToCDOW( i ) } )

 *  xbrowser aWeek
  * xbrowser aMesi

   f:=DTOS (dTemp)
   m:=MONTH(dTemp)
   d:=dow(dtemp)
    *  ? d
   cMese:=IF(m<>0, aMesi[m] ,"" )
   dday :=IF(d<>0, aWeek[d] ,"")

   dFech:=IF(m<>0,dday+", "+ SubStr(f,7,2)+' '+cMese+' '+SubStr(f,1,4),'')
   RETURN (dFech)

//-------------------------------------------------------------------//
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: error on NToCDOW
Posted: Mon Aug 06, 2018 08:14 AM
Wrong caption.
There is no error with NToCDOW().
The error is with your program.
Please do not use wrong captions.

You need to use

Code (fw): Select all Collapse
REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN

HB_LangSelect("IT")
HB_SetCodePage("ITWIN")


FWDtPick also displays Italian weekdays and months.

If you have FWH 1805, this program:
Code (fw): Select all Collapse
#include "fivewin.ch"

REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN

function Main()

   HB_LangSelect("IT")
   HB_SetCodePage("ITWIN")


   ? cValToStr( Date(), "dddd dd mmmm yyyy" )

return nil


gives this output

Regards



G. N. Rao.

Hyderabad, India
Posts: 7317
Joined: Thu Oct 18, 2012 07:17 PM
Re: error on NToCDOW
Posted: Tue Aug 07, 2018 03:17 PM
Rao,
sorry it give bad here

Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)

I use : FiveWin for Harbour March-April 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
Posts: 8515
Joined: Tue Dec 20, 2005 07:36 PM
Re: error on NToCDOW
Posted: Tue Aug 07, 2018 05:11 PM

Silvio,

FWDtPick also displays Italian weekdays and months.

If you have FWH 1805, this program:

João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341

Continue the discussion