[MSVCRT] Implement wcsftime

Lionel Ulmer lionel.ulmer at free.fr
Sun Feb 20 13:38:11 CST 2005


This is a partial implementation of 'wcsftime'. What I mean by 'partial' is
that if the format string contains any Unicode chars, it won't work. There
is the same problem if any of the %... tokens returns an Unicode string.

Anyway, for the application I am playing with, it's enough :-)

Changelog:
  Start implementing wcsftime

-- 
		 Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
Index: dlls/msvcrt/msvcrt.spec
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/msvcrt.spec,v
retrieving revision 1.96
diff -u -r1.96 msvcrt.spec
--- dlls/msvcrt/msvcrt.spec	14 Feb 2005 20:53:42 -0000	1.96
+++ dlls/msvcrt/msvcrt.spec	20 Feb 2005 19:34:55 -0000
@@ -744,7 +744,7 @@
 @ cdecl wcscoll(wstr wstr) MSVCRT_wcscoll
 @ cdecl wcscpy(ptr wstr) ntdll.wcscpy
 @ cdecl wcscspn(wstr wstr) ntdll.wcscspn
-@ stub wcsftime #(ptr long wstr ptr) MSVCRT_wcsftime
+@ cdecl wcsftime(ptr long wstr ptr) MSVCRT_wcsftime
 @ cdecl wcslen(wstr) ntdll.wcslen
 @ cdecl wcsncat(wstr wstr long) ntdll.wcsncat
 @ cdecl wcsncmp(wstr wstr long) ntdll.wcsncmp
Index: dlls/msvcrt/time.c
===================================================================
RCS file: /home/wine/wine/dlls/msvcrt/time.c,v
retrieving revision 1.20
diff -u -r1.20 time.c
--- dlls/msvcrt/time.c	6 Nov 2004 03:53:53 -0000	1.20
+++ dlls/msvcrt/time.c	20 Feb 2005 19:34:56 -0000
@@ -309,3 +309,35 @@
 {
 	return &MSVCRT___daylight;
 }
+
+/*********************************************************************
+ *		wcsftime (MSVCRT.@)
+ */
+MSVCRT_size_t MSVCRT_wcsftime(WCHAR *destPtr,
+			      size_t maxsize,
+			      const WCHAR *format,
+			      const struct MSVCRT_tm *timeptr)
+{
+    char *ansi_dest, *ansi_format;
+    MSVCRT_size_t ret, len_format;
+
+    /* Note: this is a hack for now... For example, we may loose Unicode strings present in the format */
+    WARN(" not properly handled yet for Unicode formats ('%s')\n", debugstr_w(format));
+    
+    len_format = WideCharToMultiByte(CP_ACP, 0, format, -1, NULL, 0, NULL, NULL) + 1;
+
+    ansi_dest = HeapAlloc(GetProcessHeap(), 0, maxsize);
+    ansi_format = HeapAlloc(GetProcessHeap(), 0, len_format);
+
+    WideCharToMultiByte(CP_ACP, 0, format, len_format, ansi_format, len_format, NULL, NULL);
+    
+    ret = strftime(ansi_dest, maxsize, ansi_format, (const struct tm *) timeptr);
+
+    MultiByteToWideChar(CP_ACP, 0, ansi_dest, -1, destPtr, maxsize);
+    
+    HeapFree(GetProcessHeap(), 0, ansi_format);
+    HeapFree(GetProcessHeap(), 0, ansi_dest);
+
+    return ret;
+}
+


More information about the wine-patches mailing list