[MSVCRT] implement _wstrdate and _wstrtime
Robert Reif
reif at earthlink.net
Sat Oct 29 20:40:56 CDT 2005
Implement _wstrdate and _wstrtime with tests.
-------------- next part --------------
Index: dlls/msvcrt/msvcrt.spec
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/msvcrt.spec,v
retrieving revision 1.106
diff -p -u -r1.106 msvcrt.spec
--- dlls/msvcrt/msvcrt.spec 27 Sep 2005 10:55:50 -0000 1.106
+++ dlls/msvcrt/msvcrt.spec 30 Oct 2005 01:37:39 -0000
@@ -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)
Index: dlls/msvcrt/time.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/time.c,v
retrieving revision 1.24
diff -p -u -r1.24 time.c
--- dlls/msvcrt/time.c 27 Sep 2005 10:55:50 -0000 1.24
+++ dlls/msvcrt/time.c 30 Oct 2005 01:37:40 -0000
@@ -221,16 +221,40 @@ char* _strdate(char* date)
return date;
}
+/**********************************************************************
+ * _wstrdate (MSVCRT.@)
+ */
+MSVCRT_wchar_t* _wstrdate(MSVCRT_wchar_t* date)
+{
+ MSVCRT_wchar_t format[] = { 'M','M','\'','/','\'','d','d','\'','/','\'','y','y',0 };
+
+ GetDateFormatW(LOCALE_NEUTRAL, 0, NULL, (LPCWSTR)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)
+{
+ MSVCRT_wchar_t format[] = { 'H','H','\'',':','\'','m','m','\'',':','\'','s','s',0 };
+
+ GetTimeFormatW(LOCALE_NEUTRAL, 0, NULL, (LPCWSTR)format, (LPWSTR)time, 9);
+
+ return time;
}
/*********************************************************************
Index: dlls/msvcrt/tests/time.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/tests/time.c,v
retrieving revision 1.6
diff -p -u -r1.6 time.c
--- dlls/msvcrt/tests/time.c 27 Jun 2005 09:57:28 -0000 1.6
+++ dlls/msvcrt/tests/time.c 30 Oct 2005 01:37:40 -0000
@@ -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();
}
More information about the wine-patches
mailing list