Wrapper for GetDateFormat() - Antonio ?

Post Reply
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Wrapper for GetDateFormat() - Antonio ?

Post 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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Davide,

> did I forgot to hit Submit after Previewing it ?

yes, probably
regards, saludos

Antonio Linares
www.fivetechsoft.com
Davide
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

Post 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"

//----------------------------------------------------------------------------//
Post Reply