|
5#
楼主 |
发表于 2016-4-20 23:35:15
|
只看该作者
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimedrft.cpp
#include "nsIDateTimeFormat.h"
#include "nsDateTimeFormatCID.h"
char *date = MimeHeaders_get(headers, HEADER_DATE, false, true); // "Tue, 27 May 2014 09:38:27 +0800"
nsresult rv = NS_OK;
nsCOMPtr<nsIDateTimeFormat> mDateFormatter;
if (!mDateFormatter)
{
mDateFormatter = do_CreateInstance(NS_DATETIMEFORMAT_CONTRACTID, &rv);
}
nsCAutoString convertedDateString;
PRExplodedTime explodedMsgTime;
rv = static_cast<nsresult>(PR_ParseTimeStringToExplodedTime(date, false, &explodedMsgTime));
PRExplodedTime explodedCompTime;
PR_ExplodeTime(PR_ImplodeTime(&explodedMsgTime), PR_LocalTimeParameters, &explodedCompTime);
nsAutoString formattedDateString;
if (NS_SUCCEEDED(rv))
{
rv = mDateFormatter->FormatPRExplodedTime(nullptr /* nsILocale* locale */,
kDateFormatShort,
kTimeFormatNoSeconds,
&explodedCompTime,
formattedDateString); //formattedDateString = 2014-5-27 9:38
if (NS_SUCCEEDED(rv))
{
CopyUTF16toUTF8(formattedDateString, convertedDateString);
char *result = 0;
result = (char *) PR_MALLOC(100);
memcpy(result, convertedDateString.get(), convertedDateString.Length());
result[convertedDateString.Length()] = 0;
mime_intl_insert_message_header_1(&newBody, &result, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcharset, htmlEdit);
}
else
{
mime_intl_insert_message_header_1(&newBody, &date, HEADER_DATE,
MimeGetNamedString(MIME_MHTML_DATE),
mailcharset, htmlEdit);
}
}
|
|