diff --git a/intl/locale/src/nsScriptableDateFormat.cpp b/intl/locale/src/nsScriptableDateFormat.cpp index 4f779d0b9fc..58e165b7e0e 100644 --- a/intl/locale/src/nsScriptableDateFormat.cpp +++ b/intl/locale/src/nsScriptableDateFormat.cpp @@ -21,6 +21,7 @@ * * Contributor(s): * Pierre Phaneuf + * Constantine A. Murenin * * * 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 localeService = do_GetService(kLocaleServiceCID); - if (!localeService) - return NS_ERROR_NOT_AVAILABLE; - nsCOMPtr 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 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 dateTimeFormat(do_CreateInstance(kDateTimeFormatCID, &rv)); + NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr 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); diff --git a/mailnews/compose/src/nsMsgCompose.cpp b/mailnews/compose/src/nsMsgCompose.cpp index 8787b4e5d39..3e748c03372 100644 --- a/mailnews/compose/src/nsMsgCompose.cpp +++ b/mailnews/compose/src/nsMsgCompose.cpp @@ -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)) {