mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-30 00:01:50 +00:00
Changed to use progid for nsIScriptableDateFormat.
This commit is contained in:
parent
4b5d7ed45b
commit
a1ac37d470
@ -55,10 +55,23 @@ extern nsISupports *NEW_SCRIPTABLE_DATEFORMAT(void);
|
||||
|
||||
[scriptable, uuid(0c89efb0-1aae-11d3-9141-006008a6edf6)]
|
||||
interface nsIScriptableDateFormat : nsISupports {
|
||||
|
||||
const long dateFormatNone = 0; // do not include the date in the format string
|
||||
const long dateFormatLong =1; // provides the long date format for the given locale
|
||||
const long dateFormatShort =2; // provides the short date format for the given locale
|
||||
const long dateFormatYearMonth =3; // formats using only the year and month
|
||||
const long dateFormatWeekday = 4; // week day (e.g. Mon, Tue)
|
||||
|
||||
const long timeFormatNone = 0; // don't include the time in the format string
|
||||
const long timeFormatSeconds = 1; // provides the time format with seconds in the given locale
|
||||
const long timeFormatNoSeconds = 2; // provides the time format without seconds in the given locale
|
||||
const long timeFormatSecondsForce24Hour = 3; // forces the time format to use the 24 clock, regardless of the locale conventions
|
||||
const long timeFormatNoSecondsForce24Hour = 4; // forces the time format to use the 24 clock, regardless of the locale conventions
|
||||
|
||||
// format date and time, locale is language country pair (e.g. en-US) or empty string for application default
|
||||
wstring FormatDateTime(in wstring locale,
|
||||
in nsDateFormatSelector dateFormatSelector,
|
||||
in nsTimeFormatSelector timeFormatSelector,
|
||||
in long dateFormatSelector,
|
||||
in long timeFormatSelector,
|
||||
in long year,
|
||||
in long month,
|
||||
in long day,
|
||||
@ -67,13 +80,13 @@ interface nsIScriptableDateFormat : nsISupports {
|
||||
in long second);
|
||||
// format date, locale is language country pair (e.g. en-US) or empty string for application default
|
||||
wstring FormatDate(in wstring locale,
|
||||
in nsDateFormatSelector dateFormatSelector,
|
||||
in long dateFormatSelector,
|
||||
in long year,
|
||||
in long month,
|
||||
in long day);
|
||||
// format time, locale is language country pair (e.g. en-US) or empty string for application default
|
||||
wstring FormatTime(in wstring locale,
|
||||
in nsTimeFormatSelector timeFormatSelector,
|
||||
in long timeFormatSelector,
|
||||
in long hour,
|
||||
in long minute,
|
||||
in long second);
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "nsLocaleCID.h"
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsLocaleFactoryWin.h"
|
||||
#include "nsIWin32LocaleImpl.h"
|
||||
#include "nsIWin32LocaleFactory.h"
|
||||
@ -56,6 +57,7 @@ NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
||||
NS_DEFINE_CID(kCollationFactoryCID, NS_COLLATIONFACTORY_CID);
|
||||
NS_DEFINE_CID(kCollationCID, NS_COLLATION_CID);
|
||||
NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
NS_DEFINE_CID(kScriptableDateFormatCID, NS_SCRIPTABLEDATEFORMAT_CID);
|
||||
|
||||
//
|
||||
// private entry points used for debugging
|
||||
@ -199,6 +201,14 @@ extern "C" NS_EXPORT nsresult NSRegisterSelf(nsISupports* aServMgr, const char *
|
||||
NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register DateTimeFormat failed.");
|
||||
if (NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
//
|
||||
// register the scriptable date time formatter
|
||||
//
|
||||
rv = compMgr->RegisterComponent(kScriptableDateFormatCID, "Scriptable Date Format",
|
||||
NS_SCRIPTABLEDATEFORMAT_PROGID, path, PR_TRUE, PR_TRUE);
|
||||
NS_ASSERTION(rv==NS_OK,"nsLocaleTest: Register ScriptableDateFormat failed.");
|
||||
if (NS_FAILED(rv) && (NS_ERROR_FACTORY_EXISTS != rv)) goto done;
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
@ -236,6 +246,9 @@ extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* aServMgr, const char
|
||||
rv = compMgr->UnregisterComponent(kDateTimeFormatCID, path);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
rv = compMgr->UnregisterComponent(kScriptableDateFormatCID, path);
|
||||
if (NS_FAILED(rv)) goto done;
|
||||
|
||||
done:
|
||||
(void)servMgr->ReleaseService(kComponentManagerCID, compMgr);
|
||||
return rv;
|
||||
|
@ -22,6 +22,7 @@
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsLocalefactoryWin.h"
|
||||
|
||||
|
||||
@ -30,6 +31,7 @@ NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
||||
NS_DEFINE_IID(kICollationFactoryIID, NS_ICOLLATIONFACTORY_IID);
|
||||
NS_DEFINE_IID(kICollationIID, NS_ICOLLATION_IID);
|
||||
NS_DEFINE_IID(kIDateTimeFormatIID, NS_IDATETIMEFORMAT_IID);
|
||||
NS_DEFINE_CID(kScriptableDateFormatCID, NS_SCRIPTABLEDATEFORMAT_CID);
|
||||
|
||||
|
||||
nsLocaleWinFactory::nsLocaleWinFactory(const nsCID &aClass)
|
||||
@ -105,6 +107,9 @@ nsresult nsLocaleWinFactory::CreateInstance(nsISupports *aOuter,
|
||||
else if (aIID.Equals(nsIScriptableDateFormat::GetIID())) {
|
||||
inst = NEW_SCRIPTABLE_DATEFORMAT();
|
||||
}
|
||||
else if (mClassID.Equals(kScriptableDateFormatCID)) {
|
||||
inst = NEW_SCRIPTABLE_DATEFORMAT();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
Loading…
Reference in New Issue
Block a user