Commit fc26407e authored by Alexandre Julliard's avatar Alexandre Julliard

kernelbase: Reimplement GetDateFormatA().

parent 1b127e24
...@@ -640,7 +640,7 @@ ...@@ -640,7 +640,7 @@
@ stdcall -norelay GetCurrentThreadId() KERNEL32_GetCurrentThreadId @ stdcall -norelay GetCurrentThreadId() KERNEL32_GetCurrentThreadId
@ stdcall -import GetCurrentThreadStackLimits(ptr ptr) @ stdcall -import GetCurrentThreadStackLimits(ptr ptr)
@ stdcall -arch=x86_64 GetCurrentUmsThread() @ stdcall -arch=x86_64 GetCurrentUmsThread()
@ stdcall GetDateFormatA(long long ptr str ptr long) @ stdcall -import GetDateFormatA(long long ptr str ptr long)
@ stdcall -import GetDateFormatEx(wstr long ptr wstr ptr long wstr) @ stdcall -import GetDateFormatEx(wstr long ptr wstr ptr long wstr)
@ stdcall -import GetDateFormatW(long long ptr wstr ptr long) @ stdcall -import GetDateFormatW(long long ptr wstr ptr long)
@ stdcall GetDaylightFlag() @ stdcall GetDaylightFlag()
......
...@@ -728,59 +728,6 @@ static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags, ...@@ -728,59 +728,6 @@ static INT NLS_GetDateTimeFormatA(LCID lcid, DWORD dwFlags,
} }
/****************************************************************************** /******************************************************************************
* GetDateFormatA [KERNEL32.@]
*
* Format a date for a given locale.
*
* PARAMS
* lcid [I] Locale to format for
* dwFlags [I] LOCALE_ and DATE_ flags from "winnls.h"
* lpTime [I] Date to format
* lpFormat [I] Format string, or NULL to use the system defaults
* lpDateStr [O] Destination for formatted string
* cchOut [I] Size of lpDateStr, or 0 to calculate the resulting size
*
* NOTES
* - If lpFormat is NULL, lpDateStr will be formatted according to the format
* details returned by GetLocaleInfoA() and modified by dwFlags.
* - lpFormat is a string of characters and formatting tokens. Any characters
* in the string are copied verbatim to lpDateStr, with tokens being replaced
* by the date values they represent.
* - The following tokens have special meanings in a date format string:
*| Token Meaning
*| ----- -------
*| d Single digit day of the month (no leading 0)
*| dd Double digit day of the month
*| ddd Short name for the day of the week
*| dddd Long name for the day of the week
*| M Single digit month of the year (no leading 0)
*| MM Double digit month of the year
*| MMM Short name for the month of the year
*| MMMM Long name for the month of the year
*| y Double digit year number (no leading 0)
*| yy Double digit year number
*| yyyy Four digit year number
*| gg Era string, for example 'AD'.
* - To output any literal character that could be misidentified as a token,
* enclose it in single quotes.
* - The ANSI version of this function fails if lcid is Unicode only.
*
* RETURNS
* Success: The number of character written to lpDateStr, or that would
* have been written, if cchOut is 0.
* Failure: 0. Use GetLastError() to determine the cause.
*/
INT WINAPI GetDateFormatA( LCID lcid, DWORD dwFlags, const SYSTEMTIME* lpTime,
LPCSTR lpFormat, LPSTR lpDateStr, INT cchOut)
{
TRACE("(0x%04lx,0x%08lx,%p,%s,%p,%d)\n",lcid, dwFlags, lpTime,
debugstr_a(lpFormat), lpDateStr, cchOut);
return NLS_GetDateTimeFormatA(lcid, dwFlags | DATE_DATEVARSONLY, lpTime,
lpFormat, lpDateStr, cchOut);
}
/******************************************************************************
* GetTimeFormatA [KERNEL32.@] * GetTimeFormatA [KERNEL32.@]
* *
* Format a time for a given locale. * Format a time for a given locale.
......
...@@ -499,7 +499,7 @@ ...@@ -499,7 +499,7 @@
@ stdcall -norelay GetCurrentThread() kernelbase_GetCurrentThread @ stdcall -norelay GetCurrentThread() kernelbase_GetCurrentThread
@ stdcall -norelay GetCurrentThreadId() kernelbase_GetCurrentThreadId @ stdcall -norelay GetCurrentThreadId() kernelbase_GetCurrentThreadId
@ stdcall GetCurrentThreadStackLimits(ptr ptr) @ stdcall GetCurrentThreadStackLimits(ptr ptr)
@ stdcall GetDateFormatA(long long ptr str ptr long) kernel32.GetDateFormatA @ stdcall GetDateFormatA(long long ptr str ptr long)
@ stdcall GetDateFormatEx(wstr long ptr wstr ptr long wstr) @ stdcall GetDateFormatEx(wstr long ptr wstr ptr long wstr)
@ stdcall GetDateFormatW(long long ptr wstr ptr long) @ stdcall GetDateFormatW(long long ptr wstr ptr long)
@ stdcall GetDeviceDriverBaseNameA(ptr ptr long) @ stdcall GetDeviceDriverBaseNameA(ptr ptr long)
......
...@@ -7158,6 +7158,35 @@ int WINAPI GetCurrencyFormatEx( const WCHAR *name, DWORD flags, const WCHAR *val ...@@ -7158,6 +7158,35 @@ int WINAPI GetCurrencyFormatEx( const WCHAR *name, DWORD flags, const WCHAR *val
} }
/******************************************************************************
* GetDateFormatA (KERNEL32.@)
*/
int WINAPI GetDateFormatA( LCID lcid, DWORD flags, const SYSTEMTIME *time,
const char *format, char *buffer, int len )
{
UINT cp = get_lcid_codepage( lcid, flags );
WCHAR formatW[128], output[128];
int ret;
TRACE( "(0x%04lx,0x%08lx,%p,%s,%p,%d)\n", lcid, flags, time, debugstr_a(format), buffer, len );
if (len < 0 || (len && !buffer))
{
SetLastError( ERROR_INVALID_PARAMETER );
return 0;
}
if (format)
{
MultiByteToWideChar( cp, 0, format, -1, formatW, ARRAY_SIZE(formatW) );
ret = GetDateFormatW( lcid, flags, time, formatW, output, ARRAY_SIZE(output) );
}
else ret = GetDateFormatW( lcid, flags, time, NULL, output, ARRAY_SIZE(output) );
if (ret) ret = WideCharToMultiByte( cp, 0, output, -1, buffer, len, 0, 0 );
return ret;
}
/*********************************************************************** /***********************************************************************
* GetDateFormatW (kernelbase.@) * GetDateFormatW (kernelbase.@)
*/ */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment