зеркало из https://github.com/mozilla/pjs.git
Let RDF handles dates. Write createDateNode.
This commit is contained in:
Родитель
cc7dd404a7
Коммит
715c97fb84
|
@ -114,24 +114,6 @@ nsresult nsMsgMessageDataSource::Init()
|
|||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
nsILocaleFactory *localeFactory;
|
||||
rv = nsComponentManager::FindFactory(kLocaleFactoryCID, (nsIFactory**)&localeFactory);
|
||||
|
||||
if(NS_SUCCEEDED(rv) && localeFactory)
|
||||
{
|
||||
rv = localeFactory->GetApplicationLocale(getter_AddRefs(mApplicationLocale));
|
||||
NS_IF_RELEASE(localeFactory);
|
||||
}
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
rv = nsComponentManager::CreateInstance(kDateTimeFormatCID, NULL,
|
||||
nsCOMTypeInfo<nsIDateTimeFormat>::GetIID(), getter_AddRefs(mDateTimeFormat));
|
||||
|
||||
if(NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
NS_WITH_SERVICE(nsIMsgMailSession, mailSession, kMsgMailSessionCID, &rv);
|
||||
if(NS_SUCCEEDED(rv))
|
||||
mailSession->AddFolderListener(this);
|
||||
|
@ -590,30 +572,8 @@ nsMsgMessageDataSource::createMessageDateNode(nsIMessage *message,
|
|||
LL_UI2L(intermediateResult, aLong);
|
||||
LL_MUL(aTime, intermediateResult, microSecondsPerSecond);
|
||||
|
||||
PRExplodedTime explode;
|
||||
PR_ExplodeTime(aTime, PR_LocalTimeParameters, &explode);
|
||||
|
||||
nsString dateString;
|
||||
|
||||
|
||||
/* ducarroz: FormatTMTime doesn't seems to work correctly on Mac and doen't work with PRExplodedTime!
|
||||
I will use PR_FormatTime until FormatTMTime is fixed.
|
||||
if(mDateTimeFormat)
|
||||
rv = mDateTimeFormat->FormatTMTime(mApplicationLocale, kDateFormatShort, kTimeFormatNoSeconds,
|
||||
(tm*)&explode, dateString);
|
||||
//Ensure that we always have some string for the date.
|
||||
if(!mDateTimeFormat || NS_FAILED(rv))
|
||||
{
|
||||
dateString ="";
|
||||
rv = NS_OK;
|
||||
}
|
||||
if(NS_SUCCEEDED(rv))
|
||||
*/
|
||||
char buffer[128];
|
||||
PR_FormatTime(buffer, sizeof(buffer), "%m/%d/%Y %I:%M %p", &explode);
|
||||
dateString = buffer;
|
||||
|
||||
rv = createNode(dateString, target);
|
||||
rv = createDateNode(aTime, target);
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ private:
|
|||
|
||||
nsIRDFService* mRDFService;
|
||||
nsIMsgHeaderParser *mHeaderParser;
|
||||
nsCOMPtr<nsILocale> mApplicationLocale;
|
||||
nsCOMPtr<nsIDateTimeFormat> mDateTimeFormat;
|
||||
|
||||
public:
|
||||
|
||||
|
|
|
@ -114,6 +114,21 @@ nsresult createNode(PRUint32 value, nsIRDFNode **node)
|
|||
return rv;
|
||||
}
|
||||
|
||||
nsresult createDateNode(PRTime time, nsIRDFNode **node)
|
||||
{
|
||||
*node = nsnull;
|
||||
nsresult rv;
|
||||
NS_WITH_SERVICE(nsIRDFService, rdf, kRDFServiceCID, &rv);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
nsCOMPtr<nsIRDFDate> date;
|
||||
rv = rdf->GetDateLiteral(time, getter_AddRefs(date));
|
||||
if(NS_SUCCEEDED(rv)) {
|
||||
*node = date;
|
||||
NS_IF_ADDREF(*node);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult GetTargetHasAssertion(nsIRDFDataSource *dataSource, nsIRDFResource* folderResource,
|
||||
nsIRDFResource *property,PRBool tv, nsIRDFNode *target,PRBool* hasAssertion)
|
||||
{
|
||||
|
|
|
@ -75,6 +75,9 @@ nsresult createNode(nsString& str, nsIRDFNode **node);
|
|||
//Given a PRUint32, create an nsiIRDFNode.
|
||||
nsresult createNode(PRUint32 value, nsIRDFNode **node);
|
||||
|
||||
//Given a PRTime create an nsIRDFNode that is really a date literal.
|
||||
nsresult createDateNode(PRTime time, nsIRDFNode **node);
|
||||
|
||||
//Has Assertion for a datasource that will just call GetTarget on property. When all of our
|
||||
//datasource derive from our datasource baseclass, this should be moved there and the first
|
||||
//parameter will no longer be needed.
|
||||
|
|
Загрузка…
Ссылка в новой задаче