Here it is.
It works well if I don't pass dDate (it returns the current date formatted correctly), but the same happens even with a different dDate.
There should be something wrong in the SystemTime structure, but I cannot find the mistake.
Thanks,
Davide
- Code: Select all Expand view RUN
***********************************
Function GetDatePict(dDate,cFormat) // "dd MMM yyyy"
***********************************
Local cBuf:=Space(261),i,oSystemTime
If Empty(dDate)
i:=GetdateFormat(0x0400,,,cFormat,@cBuf,261)
Else
STRUCT oSystemTime
MEMBER wYear AS WORD
MEMBER wMonth AS WORD
MEMBER wDayOfWeek AS WORD
MEMBER wDay AS WORD
MEMBER wHour AS WORD
MEMBER wMinute AS WORD
MEMBER wSecond AS WORD
MEMBER wMilliseconds AS WORD
ENDSTRUCT
oSystemTime:wYear = Year(dDate)
oSystemTime:wMonth = Month(dDate)
oSystemTime:wDay = Day(dDate)
oSystemTime:wDayOfWeek = 0 // The function fixes it
oSystemTime:wHour = 0
oSystemTime:wMinute = 0
oSystemTime:wSecond = 0
oSystemTime:wMilliseconds = 0
i:=GetdateFormat(0x0400,,oSystemTime:cBuffer,cFormat,@cBuf,261)
Endif
Return IF(I=0,"",Left(cBuf,i-1))
//----------------------------------------------------------------------------//
DLL32 Function GetDateFormat( Locale AS DWORD, dwFlags AS DWORD, lpDate AS DWORD, lpFormat AS LPSTR, lpDateStr AS LPSTR, cchDate AS DWORD ) AS DWORD ;
PASCAL FROM "GetDateFormatA" LIB "kernel32.dll"
//----------------------------------------------------------------------------//