From 164a11134a2771ec6bb59858e81b427f0f4ea3f4 Mon Sep 17 00:00:00 2001 From: Brad Lassey Date: Fri, 25 Sep 2009 12:52:09 -0400 Subject: [PATCH] bug 503710 - PR_FormatTime / strftime() doesn't work on Windows CE shunt r=dougt --- build/wince/shunt/Makefile.in | 2 ++ build/wince/shunt/time.cpp | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/build/wince/shunt/Makefile.in b/build/wince/shunt/Makefile.in index aac03ed3a89..17c361028c3 100644 --- a/build/wince/shunt/Makefile.in +++ b/build/wince/shunt/Makefile.in @@ -83,6 +83,8 @@ endif DEFFILE = mozce_shunt.def +OS_LIBS += $(call EXPAND_LIBNAME, libcmt) + CPPSRCS = \ shunt.cpp \ environment.cpp \ diff --git a/build/wince/shunt/time.cpp b/build/wince/shunt/time.cpp index f1423e856d8..e639d13fc8b 100644 --- a/build/wince/shunt/time.cpp +++ b/build/wince/shunt/time.cpp @@ -40,7 +40,7 @@ #include "include/mozce_shunt.h" #include "time_conversions.h" #include -#include "Windows.h" +#include //////////////////////////////////////////////////////// // Time Stuff @@ -75,9 +75,15 @@ static const int sDaysOfYear[12] = { }; static struct tm tmStorage; -size_t strftime(char *, size_t, const char *, const struct tm *) +size_t strftime(char *out, size_t maxsize, const char *pat, const struct tm *time) { - return 0; + WCHAR* tmpBuf = (WCHAR*)malloc(sizeof(WCHAR) * maxsize); + if (!tmpBuf) + return 0; + wcsftime(tmpBuf, maxsize, pat, time); + size_t ret = ::WideCharToMultiByte(CP_ACP, 0, tmpBuf, -1, out, maxsize, 0, 0); + free(tmpBuf); + return ret; } struct tm* gmtime_r(const time_t* inTimeT, struct tm* outRetval)