Code: Select all
dDat2 := CONV_DTEXT( "Monday, 04 March 2019", 1 ) // 1 = english selected
dDat1 := CONV_DTEXT( "Tuesday, 26 December 2019", 1 )
cResult := "26 December 2019 - 04 March 2019" + CRLF + ;
+ CRLF + STR( dDat1 - dDat2 ) + ;
" days counted" + CRLF + CRLF + ;
"converted to : " + DTOC( dDat1 ) + " - " + DTOC( dDat2 )
MsgAlert( cResult, "Days" )
// -----------------
STATIC FUNCTION CONV_DTEXT( cDate, nLanguage )
LOCAL cText := "", I := 2, cMonthName := ""
FOR I := 2 TO 4
IF I < 4
IF I = 2
cText += LTRIM( StrToken( cDate, I, " " ) ) + "." // Day
ELSEIF I = 3
cMonthName := StrToken( cDate, 3, " " )
// MsgAlert(cMonthName, "month-name from string" )
cText += MONTH_CONV( cMonthName, nLanguage ) + "."
ENDIF
ELSE
cText += LTRIM( StrToken( cDate, I, " " ) ) // Year
ENDIF
NEXT
RETURN( cTOD( cText ) )
// ------------
STATIC FUNCTION MONTH_CONV( cMonthName, nLanguage )
LOCAL aMonth :={}, cMonthConv := " ", I := 1
AADD( aMonth, { "January", "Januar", "Gennaio", "Enero", "01" } )
AADD( aMonth, { "February" , "Februar", "Febbraio", "Febrero", "02" } )
AADD( aMonth, { "March", "März", "Marzo", "Marzo", "03" } )
AADD( aMonth, { "April" , "April", "Aprile", "Abril", "04" } )
AADD( aMonth, { "Mai", "Mai", "Maggio", "Mayo", "05" } )
AADD( aMonth, { "June", "Juni", "Giugno", "Junio", "06" } )
AADD( aMonth, { "July", "Juli", "Luglio", "Julio", "07" } )
AADD( aMonth, { "August", "August", "Agosto", "Agosto", "08" } )
AADD( aMonth, { "September", "September", "Settembre", "Septiembre", "09" } )
AADD( aMonth, { "October", "Oktober", "Ottobre", "Octubre", "10" } )
AADD( aMonth, { "November", "November", "Novembre", "Noviembre", "11" } )
AADD( aMonth, { "December", "Dezember", "Dicembre", "Diciembre", "12" } )
FOR I := 1 TO 12
IF aMonth[I][nLanguage] = cMonthName
cMonthConv := aMonth[I][5]
ENDIF
NEXT
// MsgAlert(cMonthSel, "converted month" )
RETURN( cMonthConv )