Commit c4d68778 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msvcrt: Added _mkgmtime implementation.

parent 42375518
......@@ -800,8 +800,8 @@
@ cdecl _memicmp(str str long) msvcrt._memicmp
@ stub _memicmp_l
@ cdecl _mkdir(str) msvcrt._mkdir
@ stub _mkgmtime32
@ stub _mkgmtime64
@ cdecl _mkgmtime32(ptr) msvcrt._mkgmtime32
@ cdecl _mkgmtime64(ptr) msvcrt._mkgmtime64
@ cdecl _mktemp(str) msvcrt._mktemp
@ stub _mktemp_s
@ cdecl _mktime32(ptr) msvcrt._mktime32
......
......@@ -788,8 +788,8 @@
@ cdecl _memicmp(str str long) msvcrt._memicmp
@ stub _memicmp_l
@ cdecl _mkdir(str) msvcrt._mkdir
@ stub _mkgmtime32
@ stub _mkgmtime64
@ cdecl _mkgmtime32(ptr) msvcrt._mkgmtime32
@ cdecl _mkgmtime64(ptr) msvcrt._mkgmtime64
@ cdecl _mktemp(str) msvcrt._mktemp
@ stub _mktemp_s
@ cdecl _mktime32(ptr) msvcrt._mktime32
......
......@@ -745,9 +745,9 @@
@ cdecl _memicmp(str str long) ntdll._memicmp
# stub _memicmp_l
@ cdecl _mkdir(str) MSVCRT__mkdir
# stub _mkgmtime
# stub _mkgmtime32
# stub _mkgmtime64
@ cdecl _mkgmtime(ptr) MSVCRT__mkgmtime
@ cdecl _mkgmtime32(ptr) MSVCRT__mkgmtime32
@ cdecl _mkgmtime64(ptr) MSVCRT__mkgmtime64
@ cdecl _mktemp(str)
# stub _mktemp_s
@ cdecl _mktime32(ptr) MSVCRT__mktime32
......
......@@ -54,13 +54,26 @@ static void test_ctime(void)
}
static void test_gmtime(void)
{
time_t gmt = 0;
struct tm* gmt_tm = gmtime(&gmt);
if(gmt_tm == 0)
{
ok(0,"gmtime() error\n");
static __time32_t (__cdecl *p_mkgmtime32)(struct tm*);
static struct tm* (__cdecl *p_gmtime32)(__time32_t*);
HMODULE hmod = GetModuleHandleA("msvcrt.dll");
__time32_t valid, gmt;
struct tm* gmt_tm;
p_gmtime32 = (void*)GetProcAddress(hmod, "_gmtime32");
if(!p_gmtime32) {
win_skip("Skipping _gmtime32 tests\n");
return;
}
gmt = valid = 0;
gmt_tm = p_gmtime32(&gmt);
if(!gmt_tm) {
ok(0, "_gmtime32() failed\n");
return;
}
ok(((gmt_tm->tm_year == 70) && (gmt_tm->tm_mon == 0) && (gmt_tm->tm_yday == 0) &&
(gmt_tm->tm_mday == 1) && (gmt_tm->tm_wday == 4) && (gmt_tm->tm_hour == 0) &&
(gmt_tm->tm_min == 0) && (gmt_tm->tm_sec == 0) && (gmt_tm->tm_isdst == 0)),
......@@ -68,6 +81,48 @@ static void test_gmtime(void)
gmt_tm->tm_year, gmt_tm->tm_mon, gmt_tm->tm_yday, gmt_tm->tm_mday, gmt_tm->tm_wday,
gmt_tm->tm_hour, gmt_tm->tm_min, gmt_tm->tm_sec, gmt_tm->tm_isdst);
p_mkgmtime32 = (void*)GetProcAddress(hmod, "_mkgmtime32");
if(!p_mkgmtime32) {
win_skip("Skipping _mkgmtime32 tests\n");
return;
}
gmt_tm->tm_wday = gmt_tm->tm_yday = 0;
gmt = p_mkgmtime32(gmt_tm);
ok(gmt == valid, "gmt = %u\n", gmt);
ok(gmt_tm->tm_wday == 4, "gmt_tm->tm_wday = %d\n", gmt_tm->tm_wday);
ok(gmt_tm->tm_yday == 0, "gmt_tm->tm_yday = %d\n", gmt_tm->tm_yday);
gmt_tm->tm_wday = gmt_tm->tm_yday = 0;
gmt_tm->tm_isdst = -1;
gmt = p_mkgmtime32(gmt_tm);
ok(gmt == valid, "gmt = %u\n", gmt);
ok(gmt_tm->tm_wday == 4, "gmt_tm->tm_wday = %d\n", gmt_tm->tm_wday);
ok(gmt_tm->tm_yday == 0, "gmt_tm->tm_yday = %d\n", gmt_tm->tm_yday);
gmt_tm->tm_wday = gmt_tm->tm_yday = 0;
gmt_tm->tm_isdst = 1;
gmt = p_mkgmtime32(gmt_tm);
ok(gmt == valid, "gmt = %u\n", gmt);
ok(gmt_tm->tm_wday == 4, "gmt_tm->tm_wday = %d\n", gmt_tm->tm_wday);
ok(gmt_tm->tm_yday == 0, "gmt_tm->tm_yday = %d\n", gmt_tm->tm_yday);
gmt = valid = 173921;
gmt_tm = p_gmtime32(&gmt);
if(!gmt_tm) {
ok(0, "_gmtime32() failed\n");
return;
}
gmt_tm->tm_isdst = -1;
gmt = p_mkgmtime32(gmt_tm);
ok(gmt == valid, "gmt = %u\n", gmt);
ok(gmt_tm->tm_wday == 6, "gmt_tm->tm_wday = %d\n", gmt_tm->tm_wday);
ok(gmt_tm->tm_yday == 2, "gmt_tm->tm_yday = %d\n", gmt_tm->tm_yday);
gmt_tm->tm_isdst = 1;
gmt = p_mkgmtime32(gmt_tm);
ok(gmt == valid, "gmt = %u\n", gmt);
}
static void test_mktime(void)
......
......@@ -123,6 +123,64 @@ MSVCRT___time32_t CDECL MSVCRT_mktime(struct MSVCRT_tm *mstm)
}
#endif
/**********************************************************************
* _mkgmtime64 (MSVCRT.@)
*
* time->tm_isdst value is ignored
*/
MSVCRT___time64_t CDECL MSVCRT__mkgmtime64(struct MSVCRT_tm *time)
{
SYSTEMTIME st;
FILETIME ft;
MSVCRT___time64_t ret;
int i;
st.wMilliseconds = 0;
st.wSecond = time->tm_sec;
st.wMinute = time->tm_min;
st.wHour = time->tm_hour;
st.wDay = time->tm_mday;
st.wMonth = time->tm_mon+1;
st.wYear = time->tm_year+1900;
if(!SystemTimeToFileTime(&st, &ft))
return -1;
FileTimeToSystemTime(&ft, &st);
time->tm_wday = st.wDayOfWeek;
for(i=time->tm_yday=0; i<st.wMonth-1; i++)
time->tm_yday += MonthLengths[IsLeapYear(st.wYear)][i];
time->tm_yday += st.wDay-1;
ret = ((MSVCRT___time64_t)ft.dwHighDateTime<<32)+ft.dwLowDateTime;
ret = (ret-TICKS_1601_TO_1970)/TICKSPERSEC;
return ret;
}
/**********************************************************************
* _mkgmtime32 (MSVCRT.@)
*/
MSVCRT___time32_t CDECL MSVCRT__mkgmtime32(struct MSVCRT_tm *time)
{
return MSVCRT__mkgmtime64(time);
}
/**********************************************************************
* _mkgmtime (MSVCRT.@)
*/
#ifdef _WIN64
MSVCRT___time64_t CDECL MSVCRT__mkgmtime(struct MSVCRT_tm *time)
{
return MSVCRT__mkgmtime64(time);
}
#else
MSVCRT___time32_t CDECL MSVCRT__mkgmtime(struct MSVCRT_tm *time)
{
return MSVCRT__mkgmtime32(time);
}
#endif
/*********************************************************************
* _localtime64 (MSVCRT.@)
*/
......
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