Implement _wstrdate and _wstrtime with tests.
This commit is contained in:
parent
78ea87c580
commit
b8d1544661
|
@ -554,8 +554,8 @@
|
|||
@ cdecl _wsplitpath(wstr wstr wstr wstr wstr)
|
||||
@ cdecl _wstat(wstr ptr) MSVCRT__wstat
|
||||
@ cdecl _wstati64(wstr ptr) MSVCRT__wstati64
|
||||
@ stub _wstrdate #(ptr)
|
||||
@ stub _wstrtime #(ptr)
|
||||
@ cdecl _wstrdate(wstr)
|
||||
@ cdecl _wstrtime(wstr)
|
||||
@ stub _wsystem #(wstr)
|
||||
@ cdecl _wtempnam(wstr wstr)
|
||||
@ stub _wtmpnam #(ptr)
|
||||
|
|
|
@ -179,11 +179,64 @@ static void test_localtime(void)
|
|||
lt->tm_min, lt->tm_sec, lt->tm_isdst);
|
||||
putenv(TZ_env);
|
||||
}
|
||||
static void test_strdate(void)
|
||||
{
|
||||
char date[16], * result;
|
||||
int month, day, year, count, len;
|
||||
|
||||
result = _strdate(date);
|
||||
ok(result == date, "Wrong return value\n");
|
||||
len = strlen(date);
|
||||
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
|
||||
count = sscanf(date, "%02d/%02d/%02d", &month, &day, &year);
|
||||
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
|
||||
}
|
||||
static void test_strtime(void)
|
||||
{
|
||||
char time[16], * result;
|
||||
int hour, minute, second, count, len;
|
||||
|
||||
result = _strtime(time);
|
||||
ok(result == time, "Wrong return value\n");
|
||||
len = strlen(time);
|
||||
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
|
||||
count = sscanf(time, "%02d:%02d:%02d", &hour, &minute, &second);
|
||||
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
|
||||
}
|
||||
static void test_wstrdate(void)
|
||||
{
|
||||
wchar_t date[16], * result;
|
||||
int month, day, year, count, len;
|
||||
wchar_t format[] = { '%','0','2','d','/','%','0','2','d','/','%','0','2','d',0 };
|
||||
|
||||
result = _wstrdate(date);
|
||||
ok(result == date, "Wrong return value\n");
|
||||
len = wcslen(date);
|
||||
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
|
||||
count = swscanf(date, format, &month, &day, &year);
|
||||
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
|
||||
}
|
||||
static void test_wstrtime(void)
|
||||
{
|
||||
wchar_t time[16], * result;
|
||||
int hour, minute, second, count, len;
|
||||
wchar_t format[] = { '%','0','2','d',':','%','0','2','d',':','%','0','2','d',0 };
|
||||
|
||||
result = _wstrtime(time);
|
||||
ok(result == time, "Wrong return value\n");
|
||||
len = wcslen(time);
|
||||
ok(len == 8, "Wrong length: returned %d, should be 8\n", len);
|
||||
count = swscanf(time, format, &hour, &minute, &second);
|
||||
ok(count == 3, "Wrong format: count = %d, should be 3\n", count);
|
||||
}
|
||||
|
||||
START_TEST(time)
|
||||
{
|
||||
test_gmtime();
|
||||
test_mktime();
|
||||
test_localtime();
|
||||
test_strdate();
|
||||
test_strtime();
|
||||
test_wstrdate();
|
||||
test_wstrtime();
|
||||
}
|
||||
|
|
|
@ -221,16 +221,40 @@ char* _strdate(char* date)
|
|||
return date;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* _wstrdate (MSVCRT.@)
|
||||
*/
|
||||
MSVCRT_wchar_t* _wstrdate(MSVCRT_wchar_t* date)
|
||||
{
|
||||
static const WCHAR format[] = { 'M','M','\'','/','\'','d','d','\'','/','\'','y','y',0 };
|
||||
|
||||
GetDateFormatW(LOCALE_NEUTRAL, 0, NULL, format, (LPWSTR)date, 9);
|
||||
|
||||
return date;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _strtime (MSVCRT.@)
|
||||
*/
|
||||
char* _strtime(char* date)
|
||||
char* _strtime(char* time)
|
||||
{
|
||||
LPCSTR format = "HH':'mm':'ss";
|
||||
|
||||
GetTimeFormatA(LOCALE_NEUTRAL, 0, NULL, format, date, 9);
|
||||
GetTimeFormatA(LOCALE_NEUTRAL, 0, NULL, format, time, 9);
|
||||
|
||||
return date;
|
||||
return time;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
* _wstrtime (MSVCRT.@)
|
||||
*/
|
||||
MSVCRT_wchar_t* _wstrtime(MSVCRT_wchar_t* time)
|
||||
{
|
||||
static const WCHAR format[] = { 'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0 };
|
||||
|
||||
GetTimeFormatW(LOCALE_NEUTRAL, 0, NULL, format, (LPWSTR)time, 9);
|
||||
|
||||
return time;
|
||||
}
|
||||
|
||||
/*********************************************************************
|
||||
|
|
Loading…
Reference in New Issue