Let RDF handles dates. Write createDateNode.

This commit is contained in:
putterman%netscape.com 1999-07-20 04:14:47 +00:00
Родитель b12197d84e
Коммит 4e55891e9f
4 изменённых файлов: 20 добавлений и 44 удалений

Просмотреть файл

@ -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,31 +572,9 @@ 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);
return rv;
rv = createDateNode(aTime, target);
return rv;
}
nsresult

Просмотреть файл

@ -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.