FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Wrapper for GetDateFormat() - Antonio ?
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrapper for GetDateFormat() - Antonio ?
Posted: Mon Jan 07, 2008 12:02 AM
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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Wrapper for GetDateFormat() - Antonio ?
Posted: Mon Jan 07, 2008 11:40 AM

Davide,

> did I forgot to hit Submit after Previewing it ?

yes, probably

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 190
Joined: Tue Mar 14, 2006 01:59 AM
Wrapper for GetDateFormat() - Antonio ?
Posted: Mon Jan 07, 2008 12:44 PM
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

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

//----------------------------------------------------------------------------//

Continue the discussion