зеркало из https://github.com/mozilla/pjs.git
Added scriptable date format.
This commit is contained in:
Родитель
213a34f05a
Коммит
834e41a79b
Двоичные данные
intl/locale/macbuild/locale.mcp
Двоичные данные
intl/locale/macbuild/locale.mcp
Двоичный файл не отображается.
|
@ -28,5 +28,7 @@
|
|||
{ 0x704e7c0, 0xa758, 0x11d2, \
|
||||
{ 0x91, 0x19, 0x0, 0x60, 0x8, 0xa6, 0xed, 0xf6 } }
|
||||
|
||||
nsISupports *NEW_SCRIPTABLE_DATEFORMAT(void);
|
||||
|
||||
#endif // nsDateTimeFormatCID_h__
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ REQUIRES = xpcom unicharutil
|
|||
|
||||
CPPSRCS = \
|
||||
nsCollation.cpp \
|
||||
nsScriptableDateFormat.cpp \
|
||||
nsLocale.cpp \
|
||||
nsLocaleFactory.cpp \
|
||||
$(NULL)
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsCollationMac.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsDateTimeFormatMac.h"
|
||||
#include "nsLocaleFactoryMac.h"
|
||||
|
||||
|
@ -101,6 +102,9 @@ nsresult nsLocaleMacFactory::CreateInstance(nsISupports *aOuter,
|
|||
else if (aIID.Equals(kIDateTimeFormatIID)) {
|
||||
NS_NEWXPCOM(inst, nsDateTimeFormatMac);
|
||||
}
|
||||
else if (aIID.Equals(nsIScriptableDateFormat::GetIID())) {
|
||||
inst = NEW_SCRIPTABLE_DATEFORMAT();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
|
|
@ -31,11 +31,13 @@ LIBRARY_NAME = nslocale_s
|
|||
|
||||
CPPSRCS = nsLocale.cpp \
|
||||
nsLocaleFactory.cpp \
|
||||
nsScriptableDateFormat.cpp \
|
||||
nsCollation.cpp
|
||||
|
||||
|
||||
CPP_OBJS = .\$(OBJDIR)\nsLocale.obj \
|
||||
.\$(OBJDIR)\nsLocaleFactory.obj \
|
||||
.\$(OBJDIR)\nsScriptableDateFormat.obj \
|
||||
.\$(OBJDIR)\nsCollation.obj
|
||||
|
||||
LINCS = -I. \
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsCollationUnix.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsDateTimeFormatUnix.h"
|
||||
#include "nsLocaleFactoryUnix.h"
|
||||
|
||||
|
@ -102,6 +103,9 @@ nsresult nsLocaleUnixFactory::CreateInstance(nsISupports *aOuter,
|
|||
else if (aIID.Equals(kIDateTimeFormatIID)) {
|
||||
NS_NEWXPCOM(inst, nsDateTimeFormatUnix);
|
||||
}
|
||||
else if (aIID.Equals(nsIScriptableDateFormat::GetIID())) {
|
||||
inst = NEW_SCRIPTABLE_DATEFORMAT();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsIFactory.h"
|
||||
#include "nsCollationWin.h"
|
||||
#include "nsDateTimeFormatCID.h"
|
||||
#include "nsDateTimeFormatWin.h"
|
||||
#include "nsLocalefactoryWin.h"
|
||||
|
||||
|
@ -101,6 +102,9 @@ nsresult nsLocaleWinFactory::CreateInstance(nsISupports *aOuter,
|
|||
else if (aIID.Equals(kIDateTimeFormatIID)) {
|
||||
NS_NEWXPCOM(inst, nsDateTimeFormatWin);
|
||||
}
|
||||
else if (aIID.Equals(nsIScriptableDateFormat::GetIID())) {
|
||||
inst = NEW_SCRIPTABLE_DATEFORMAT();
|
||||
}
|
||||
else
|
||||
{
|
||||
return NS_NOINTERFACE;
|
||||
|
|
|
@ -147,7 +147,10 @@ static void DebugDump(nsString& aString, ostream& aStream) {
|
|||
aStream.flush();
|
||||
printf("%s\n", oOutputStr);
|
||||
#else
|
||||
aString.DebugDump(aStream);
|
||||
for (int i = 0; i < aString.Length(); i++) {
|
||||
aStream << (char) aString[i];
|
||||
}
|
||||
aStream << "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -197,7 +200,6 @@ static void TestCollation(nsILocale *locale)
|
|||
PRUint8 *aKey1, *aKey2, *aKey3;
|
||||
PRUint32 i;
|
||||
PRInt32 result;
|
||||
nsresult res;
|
||||
|
||||
cout << "String data used:\n";
|
||||
cout << "string1: ";
|
||||
|
@ -663,12 +665,59 @@ static void TestSort(nsILocale *locale, nsCollationStrength collationStrength, F
|
|||
//
|
||||
static void TestDateTimeFormat(nsILocale *locale)
|
||||
{
|
||||
nsresult res;
|
||||
|
||||
cout << "==============================\n";
|
||||
cout << "Start nsIScriptableDateFormat Test \n";
|
||||
cout << "==============================\n";
|
||||
|
||||
nsIScriptableDateFormat *aScriptableDateFormat;
|
||||
res = nsComponentManager::CreateInstance(kDateTimeFormatCID,
|
||||
NULL,
|
||||
nsIScriptableDateFormat::GetIID(),
|
||||
(void**) &aScriptableDateFormat);
|
||||
if(NS_FAILED(res) || ( aScriptableDateFormat == NULL ) ) {
|
||||
cout << "\tnsIScriptableDateFormat CreateInstance failed\n";
|
||||
}
|
||||
|
||||
const PRUnichar *aUnichar;
|
||||
nsString aString;
|
||||
PRUnichar aLocaleUnichar[1];
|
||||
*aLocaleUnichar = 0;
|
||||
res = aScriptableDateFormat->FormatDateTime(aLocaleUnichar, kDateFormatShort, kTimeFormatSeconds,
|
||||
1999,
|
||||
7,
|
||||
31,
|
||||
8,
|
||||
21,
|
||||
58,
|
||||
&aUnichar);
|
||||
aString.SetString(aUnichar);
|
||||
DebugDump(aString, cout);
|
||||
|
||||
res = aScriptableDateFormat->FormatDate(aLocaleUnichar, kDateFormatLong,
|
||||
1970,
|
||||
4,
|
||||
20,
|
||||
&aUnichar);
|
||||
aString.SetString(aUnichar);
|
||||
DebugDump(aString, cout);
|
||||
|
||||
res = aScriptableDateFormat->FormatTime(aLocaleUnichar, kTimeFormatSecondsForce24Hour,
|
||||
13,
|
||||
59,
|
||||
31,
|
||||
&aUnichar);
|
||||
aString.SetString(aUnichar);
|
||||
DebugDump(aString, cout);
|
||||
|
||||
aScriptableDateFormat->Release();
|
||||
|
||||
cout << "==============================\n";
|
||||
cout << "Start nsIDateTimeFormat Test \n";
|
||||
cout << "==============================\n";
|
||||
|
||||
nsIDateTimeFormat *t = NULL;
|
||||
nsresult res;
|
||||
res = nsComponentManager::CreateInstance(kDateTimeFormatCID,
|
||||
NULL,
|
||||
nsIDateTimeFormat::GetIID(),
|
||||
|
|
Загрузка…
Ссылка в новой задаче