Page 1 of 1
Wrapper for GetDateFormat() - Antonio ?
Posted: Mon Jan 07, 2008 12:02 am
by Davide
Antonio,
yesterday I posted a wrapper to GetDateFormat (
http://msdn2.microsoft.com/en-us/library/ms776293.aspx) to retrieve a date in the user's locale settings, but can no more find my post.
Has it been removed for some reason or did I forgot to hit Submit after Previewing it ?
Hi,
Davide
Posted: Mon Jan 07, 2008 11:40 am
by Antonio Linares
Davide,
> did I forgot to hit Submit after Previewing it ?
yes, probably
Posted: Mon Jan 07, 2008 12:44 pm
by Davide
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
***********************************
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"
//----------------------------------------------------------------------------//