mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 441167 – nsIScriptableDateFormat defaults to OS locale but should be application locale. r=smontagu
This commit is contained in:
parent
557bc969d3
commit
caf15f7e6e
@ -46,6 +46,7 @@
|
||||
#include "nsIScriptableDateFormat.h"
|
||||
#include "nsCRT.h"
|
||||
#include "nsReadableUtils.h"
|
||||
#include "nsIPrefService.h"
|
||||
|
||||
static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID);
|
||||
static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID);
|
||||
@ -114,14 +115,19 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime(
|
||||
|
||||
nsCOMPtr<nsILocale> 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));
|
||||
if (localeName.IsEmpty()) {
|
||||
nsCOMPtr<nsIPrefBranch> prefs(do_GetService(NS_PREFSERVICE_CONTRACTID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
nsCString cLocaleName;
|
||||
rv = prefs->GetCharPref("general.useragent.locale", getter_Copies(cLocaleName));
|
||||
CopyUTF8toUTF16(cLocaleName, localeName);
|
||||
}
|
||||
// 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);
|
||||
|
||||
nsCOMPtr<nsIDateTimeFormat> dateTimeFormat(do_CreateInstance(kDateTimeFormatCID, &rv));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
Loading…
Reference in New Issue
Block a user