Wrapper for GetDateFormat() - Antonio ?

Wrapper for GetDateFormat() - Antonio ?

Postby Davide » 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
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy

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

Postby Davide » 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

Code: Select all  Expand view
***********************************
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"

//----------------------------------------------------------------------------//
Davide
 
Posts: 190
Joined: Tue Mar 14, 2006 1:59 am
Location: Italy


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests