зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1426907
- Make OSPreferences::GetPatternForSkeleton public and use in DateTimeFormat; r=zbraniecki
This allows for the removal of duplicated code between DateTimeFormat and OSPreferences. Differential Revision: https://phabricator.services.mozilla.com/D94432
This commit is contained in:
Родитель
df2b7bf080
Коммит
3790450033
|
@ -74,8 +74,6 @@ nsresult DateTimeFormat::FormatDateTime(
|
|||
UErrorCode status = U_ZERO_ERROR;
|
||||
|
||||
nsAutoString skeleton;
|
||||
nsAutoString pattern;
|
||||
|
||||
switch (aSkeleton) {
|
||||
case Skeleton::yyyyMM:
|
||||
skeleton.AssignASCII("yyyyMM");
|
||||
|
@ -87,28 +85,10 @@ nsresult DateTimeFormat::FormatDateTime(
|
|||
MOZ_ASSERT_UNREACHABLE("Unhandled skeleton enum");
|
||||
}
|
||||
|
||||
UDateTimePatternGenerator* patternGenerator =
|
||||
udatpg_open(mLocale->get(), &status);
|
||||
if (U_SUCCESS(status)) {
|
||||
int32_t patternLength;
|
||||
pattern.SetLength(DATETIME_FORMAT_INITIAL_LEN);
|
||||
patternLength = udatpg_getBestPattern(
|
||||
patternGenerator,
|
||||
reinterpret_cast<const UChar*>(skeleton.BeginReading()),
|
||||
skeleton.Length(), reinterpret_cast<UChar*>(pattern.BeginWriting()),
|
||||
DATETIME_FORMAT_INITIAL_LEN, &status);
|
||||
pattern.SetLength(patternLength);
|
||||
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
udatpg_getBestPattern(
|
||||
patternGenerator,
|
||||
reinterpret_cast<const UChar*>(skeleton.BeginReading()),
|
||||
skeleton.Length(), reinterpret_cast<UChar*>(pattern.BeginWriting()),
|
||||
patternLength, &status);
|
||||
}
|
||||
nsAutoString pattern;
|
||||
if (!OSPreferences::GetPatternForSkeleton(skeleton, *mLocale, pattern)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
udatpg_close(patternGenerator);
|
||||
|
||||
nsAutoString timeZoneID;
|
||||
BuildTimeZoneString(aExplodedTime->tm_params, timeZoneID);
|
||||
|
|
|
@ -77,6 +77,10 @@ class OSPreferences : public mozIOSPreferences {
|
|||
return RefPtr<OSPreferences>(GetInstance()).forget();
|
||||
}
|
||||
|
||||
static bool GetPatternForSkeleton(const nsAString& aSkeleton,
|
||||
const nsACString& aLocale,
|
||||
nsAString& aRetVal);
|
||||
|
||||
static bool GetDateTimeConnectorPattern(const nsACString& aLocale,
|
||||
nsAString& aRetVal);
|
||||
|
||||
|
@ -121,9 +125,6 @@ class OSPreferences : public mozIOSPreferences {
|
|||
const nsACString& aLocale,
|
||||
nsAString& aRetVal);
|
||||
|
||||
bool GetPatternForSkeleton(const nsAString& aSkeleton,
|
||||
const nsACString& aLocale, nsAString& aRetVal);
|
||||
|
||||
/**
|
||||
* This is a host environment specific method that will be implemented
|
||||
* separately for each platform.
|
||||
|
|
Загрузка…
Ссылка в новой задаче