- Reimplement EnumDateFormats, make it work for all available
locales. - Add a test for EnumDateFormats.
This commit is contained in:
parent
e5503f96c1
commit
8873d90f36
|
@ -5,6 +5,7 @@
|
|||
* Copyright 1998 David Lee Lambert
|
||||
* Copyright 2000 Julio César Gázquez
|
||||
* Copyright 2003 Jon Griffiths
|
||||
* Copyright 2005 Dmitry Timoshkov
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
|
@ -1603,276 +1604,83 @@ BOOL WINAPI EnumDateFormatsExW( DATEFMT_ENUMPROCEXW lpDateFmtEnumProc, LCID Loca
|
|||
|
||||
/**************************************************************************
|
||||
* EnumDateFormatsA (KERNEL32.@)
|
||||
*
|
||||
* FIXME: MSDN mentions only LOCALE_USE_CP_ACP, should we handle
|
||||
* LOCALE_NOUSEROVERRIDE here as well?
|
||||
*/
|
||||
BOOL WINAPI EnumDateFormatsA( DATEFMT_ENUMPROCA lpDateFmtEnumProc, LCID Locale, DWORD dwFlags)
|
||||
BOOL WINAPI EnumDateFormatsA(DATEFMT_ENUMPROCA proc, LCID lcid, DWORD flags)
|
||||
{
|
||||
LCID Loc = GetUserDefaultLCID();
|
||||
if(!lpDateFmtEnumProc)
|
||||
char buf[256];
|
||||
|
||||
if (!proc)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch( Loc )
|
||||
{
|
||||
|
||||
case 0x00000407: /* (Loc,"de_DE") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
switch (flags & ~LOCALE_USE_CP_ACP)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.M.yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd,d. MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d. MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d. MMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
case 0:
|
||||
case DATE_SHORTDATE:
|
||||
if (GetLocaleInfoA(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
case 0x0000040c: /* (Loc,"fr_FR") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd.MM.yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd d MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMM yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
case DATE_LONGDATE:
|
||||
if (GetLocaleInfoA(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
case 0x00000c0c: /* (Loc,"fr_CA") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd-MM-yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("yy MM dd")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM, yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
case DATE_YEARMONTH:
|
||||
if (GetLocaleInfoA(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
case 0x00000809: /* (Loc,"en_UK") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", flags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00000c09: /* (Loc,"en_AU") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd,d MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00001009: /* (Loc,"en_CA") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("yy-MM-dd")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("M/dd/yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("d-MMM-yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("MMMM d, yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00001409: /* (Loc,"en_NZ") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("d/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.MM.yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dddd, d MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00001809: /* (Loc,"en_IE") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d/M/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d.M.yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("d MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00001c09: /* (Loc,"en_ZA") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00002009: /* (Loc,"en_JM") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd,MMMM dd,yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("MMMM dd,yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dddd,dd MMMM,yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd MMMM,yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
case 0x00002809: /* (Loc,"en_BZ") */
|
||||
case 0x00002c09: /* (Loc,"en_TT") */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dd/MM/yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd,dd MMMM yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
default: /* default to US English "en_US" */
|
||||
{
|
||||
switch(dwFlags)
|
||||
{
|
||||
case DATE_SHORTDATE:
|
||||
if(!(*lpDateFmtEnumProc)("M/d/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("M/d/yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("MM/dd/yy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("MM/dd/yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("yy/MM/dd")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd-MMM-yy")) return TRUE;
|
||||
return TRUE;
|
||||
case DATE_LONGDATE:
|
||||
if(!(*lpDateFmtEnumProc)("dddd, MMMM dd, yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("MMMM dd, yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dddd, dd MMMM, yyyy")) return TRUE;
|
||||
if(!(*lpDateFmtEnumProc)("dd MMMM, yyyy")) return TRUE;
|
||||
return TRUE;
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", dwFlags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* EnumDateFormatsW (KERNEL32.@)
|
||||
*/
|
||||
BOOL WINAPI EnumDateFormatsW( DATEFMT_ENUMPROCW lpDateFmtEnumProc, LCID Locale, DWORD dwFlags )
|
||||
BOOL WINAPI EnumDateFormatsW(DATEFMT_ENUMPROCW proc, LCID lcid, DWORD flags)
|
||||
{
|
||||
FIXME("(%p, %ld, %ld): stub\n", lpDateFmtEnumProc, Locale, dwFlags);
|
||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
||||
return FALSE;
|
||||
WCHAR buf[256];
|
||||
|
||||
if (!proc)
|
||||
{
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
switch (flags & ~LOCALE_USE_CP_ACP)
|
||||
{
|
||||
case 0:
|
||||
case DATE_SHORTDATE:
|
||||
if (GetLocaleInfoW(lcid, LOCALE_SSHORTDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
case DATE_LONGDATE:
|
||||
if (GetLocaleInfoW(lcid, LOCALE_SLONGDATE | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
case DATE_YEARMONTH:
|
||||
if (GetLocaleInfoW(lcid, LOCALE_SYEARMONTH | (flags & LOCALE_USE_CP_ACP), buf, 256))
|
||||
proc(buf);
|
||||
break;
|
||||
|
||||
default:
|
||||
FIXME("Unknown date format (%ld)\n", flags);
|
||||
SetLastError(ERROR_INVALID_PARAMETER);
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
|
|
|
@ -2094,11 +2094,83 @@ static void test_EnumUILanguageA(void)
|
|||
EXPECT_FALSE; EXPECT_INVALID;
|
||||
}
|
||||
|
||||
static char date_fmt_buf[1024];
|
||||
|
||||
static BOOL CALLBACK enum_datefmt_procA(LPSTR fmt)
|
||||
{
|
||||
lstrcatA(date_fmt_buf, fmt);
|
||||
lstrcatA(date_fmt_buf, "\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void test_EnumDateFormatsA(void)
|
||||
{
|
||||
char *p, buf[256];
|
||||
BOOL ret;
|
||||
LCID lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
|
||||
|
||||
trace("EnumDateFormatsA 0\n");
|
||||
date_fmt_buf[0] = 0;
|
||||
ret = EnumDateFormatsA(enum_datefmt_procA, lcid, 0);
|
||||
ok(ret, "EnumDateFormatsA(0) error %ld\n", GetLastError());
|
||||
trace("%s\n", date_fmt_buf);
|
||||
/* test the 1st enumerated format */
|
||||
if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
|
||||
ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
|
||||
ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
|
||||
ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
|
||||
|
||||
trace("EnumDateFormatsA LOCALE_USE_CP_ACP\n");
|
||||
date_fmt_buf[0] = 0;
|
||||
ret = EnumDateFormatsA(enum_datefmt_procA, lcid, LOCALE_USE_CP_ACP);
|
||||
ok(ret, "EnumDateFormatsA(LOCALE_USE_CP_ACP) error %ld\n", GetLastError());
|
||||
trace("%s\n", date_fmt_buf);
|
||||
/* test the 1st enumerated format */
|
||||
if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
|
||||
ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
|
||||
ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
|
||||
ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
|
||||
|
||||
trace("EnumDateFormatsA DATE_SHORTDATE\n");
|
||||
date_fmt_buf[0] = 0;
|
||||
ret = EnumDateFormatsA(enum_datefmt_procA, lcid, DATE_SHORTDATE);
|
||||
ok(ret, "EnumDateFormatsA(DATE_SHORTDATE) error %ld\n", GetLastError());
|
||||
trace("%s\n", date_fmt_buf);
|
||||
/* test the 1st enumerated format */
|
||||
if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
|
||||
ret = GetLocaleInfoA(lcid, LOCALE_SSHORTDATE, buf, sizeof(buf));
|
||||
ok(ret, "GetLocaleInfoA(LOCALE_SSHORTDATE) error %ld\n", GetLastError());
|
||||
ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
|
||||
|
||||
trace("EnumDateFormatsA DATE_LONGDATE\n");
|
||||
date_fmt_buf[0] = 0;
|
||||
ret = EnumDateFormatsA(enum_datefmt_procA, lcid, DATE_LONGDATE);
|
||||
ok(ret, "EnumDateFormatsA(DATE_LONGDATE) error %ld\n", GetLastError());
|
||||
trace("%s\n", date_fmt_buf);
|
||||
/* test the 1st enumerated format */
|
||||
if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
|
||||
ret = GetLocaleInfoA(lcid, LOCALE_SLONGDATE, buf, sizeof(buf));
|
||||
ok(ret, "GetLocaleInfoA(LOCALE_SLONGDATE) error %ld\n", GetLastError());
|
||||
ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
|
||||
|
||||
trace("EnumDateFormatsA DATE_YEARMONTH\n");
|
||||
date_fmt_buf[0] = 0;
|
||||
ret = EnumDateFormatsA(enum_datefmt_procA, lcid, DATE_YEARMONTH);
|
||||
ok(ret, "EnumDateFormatsA(DATE_YEARMONTH) error %ld\n", GetLastError());
|
||||
trace("%s\n", date_fmt_buf);
|
||||
/* test the 1st enumerated format */
|
||||
if ((p = strchr(date_fmt_buf, '\n'))) *p = 0;
|
||||
ret = GetLocaleInfoA(lcid, LOCALE_SYEARMONTH, buf, sizeof(buf));
|
||||
ok(ret, "GetLocaleInfoA(LOCALE_SYEARMONTH) error %ld\n", GetLastError());
|
||||
ok(!lstrcmpA(date_fmt_buf, buf), "expected \"%s\" got \"%s\"\n", date_fmt_buf, buf);
|
||||
}
|
||||
|
||||
START_TEST(locale)
|
||||
{
|
||||
InitFunctionPointers();
|
||||
|
||||
if (0) test_EnumTimeFormats();
|
||||
test_EnumDateFormatsA();
|
||||
|
||||
test_GetLocaleInfoA();
|
||||
test_GetTimeFormatA();
|
||||
|
|
Loading…
Reference in New Issue