зеркало из https://github.com/mozilla/pjs.git
Bug 233631 GetApplicationLocale should not be used with FormatTime methods in order to support user's customisation (OS X is affected)
patch by Constantine A. Murenin <cnst+moz@bugmail.mojo.ru> mailnews part: r=mscott intl part: r=jshin both: sr=roc a=chofmann
This commit is contained in:
Родитель
0cf3bea853
Коммит
3287a5ec20
|
@ -21,6 +21,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Pierre Phaneuf <pp@ludusdesign.com>
|
||||
* Constantine A. Murenin <cnst+moz#bugmail.mojo.ru>
|
||||
*
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
|
@ -103,26 +104,24 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
|||
PRInt32 second,
|
||||
PRUnichar **dateTimeString)
|
||||
{
|
||||
nsresult rv;
|
||||
nsAutoString localeName(aLocale);
|
||||
*dateTimeString = nsnull;
|
||||
|
||||
// get locale service
|
||||
nsCOMPtr<nsILocaleService> localeService = do_GetService(kLocaleServiceCID);
|
||||
if (!localeService)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsCOMPtr<nsILocale> locale;
|
||||
if (localeName.IsEmpty())
|
||||
localeService->GetApplicationLocale(getter_AddRefs(locale));
|
||||
else
|
||||
localeService->NewLocale(localeName, getter_AddRefs(locale));
|
||||
// re-initialise locale pointer only if the locale was given explicitly
|
||||
if (!localeName.IsEmpty()) {
|
||||
// get locale service
|
||||
nsCOMPtr<nsILocaleService> localeService(do_GetService(kLocaleServiceCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
// get locale
|
||||
rv = localeService->NewLocale(localeName, getter_AddRefs(locale));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
if (!locale)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat(do_CreateInstance(kDateTimeFormatCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat = do_CreateInstance(kDateTimeFormatCID);
|
||||
if (!dateTimeFormat)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
tm tmTime;
|
||||
time_t timetTime;
|
||||
|
||||
|
@ -137,8 +136,6 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
|||
tmTime.tm_isdst = -1;
|
||||
timetTime = mktime(&tmTime);
|
||||
|
||||
nsresult rv;
|
||||
|
||||
if ((time_t)-1 != timetTime) {
|
||||
rv = dateTimeFormat->FormatTime(locale, dateFormatSelector, timeFormatSelector,
|
||||
timetTime, mStringOut);
|
||||
|
|
|
@ -1887,8 +1887,6 @@ QuotingOutputStreamListener::QuotingOutputStreamListener(const char * originalMs
|
|||
// Format date using "mailnews.reply_header_locale", if empty then use application default locale.
|
||||
if (!replyHeaderLocale.IsEmpty())
|
||||
rv = localeService->NewLocale(replyHeaderLocale, getter_AddRefs(locale));
|
||||
else
|
||||
rv = localeService->GetApplicationLocale(getter_AddRefs(locale));
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче