Closed Bug 233631 (osxtime) Opened 21 years ago Closed 20 years ago

GetApplicationLocale should not be used with FormatTime methods in order to support user's customisation (OS X is affected)

Categories

(Core :: Internationalization, defect)

All
macOS
defect
Not set
major

Tracking

()

RESOLVED FIXED
mozilla1.7beta

People

(Reporter: cnst+bmo, Assigned: cnst+bmo)

References

Details

(Keywords: intl)

Attachments

(4 files, 1 obsolete file)

User-Agent:       
Build Identifier: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-GB; rv:1.6) Gecko/20040113

Mozilla does not honour the long date and time format, defined by the OS X. In
the test case, I tried to set the Date format to the one used in any other
country, and on the screenshot I used French with some modifications. The OS X
itself is en-US and version is 10.2.6. 

Reproducible: Always
Steps to Reproduce:
1. Open System Prefs, choose International, change Date format to French (just
as an example, and assuming that your default locale is not French). Change Time
format to French as well. 
2. One Page Info in Mozilla. 
Actual Results:  
One sees the wrong format of the long date (in Page Info, for example).

Expected Results:  
One sees the right format of the long date (in Page Info, for example).
Sorry for JPEG, the PNG file was too large...
Blocks: dateandtime
Blocks: 103669
Keywords: intl
This is an interesting bug. Modern OS' offer a way to customize date and time
format (among others) regardless of the locale.  Mozilla needs to obtain that
informaion from the OS.  I'm wondering what mozilla has to do in the following case:

  1. the os locale is set to en-US
  2. 'fr-CA' language/region pack is active
  3. the data time format configured in the OS is Japanese 

Which should take the highest priority? 

Assignee: smontagu → jshin
Status: UNCONFIRMED → NEW
Ever confirmed: true
(In reply to comment #2)
> This is an interesting bug. Modern OS' offer a way to customize date and time
> format (among others) regardless of the locale.  Mozilla needs to obtain that

...

> Which should take the highest priority? 

I think the customisation must have the highest priority. For instance, I am
Russian, I live in the US, I use en-GB locale, and I like the ISO time notation.
:-) Weird, huh? 

BTW, not only OS X has problems with long date and time format --- apparently,
UNIX builds do not have any kind of long date and time. Moreover, the short one
is based on the locale, rather than the user settings of the desktop (KDE, as
example). 
Alias: osxtime
Mozilla doesn't have any support for KDE interoperability at the moment although
it has some for Gnome2. Anyway, that has to be a separate bug.
As you can see, Camino still honours the long date and time customisation (I
only found one window with the long date and time in Camino so far), while
Mozilla does not (as far as the windows I have found are concerned). This is
probably related to the previous Comment 5, i.e. we should not pass the locale
pointer to the FormatTime/FormatPRTime on Mac OS X. In my search for the use of
these functions, I found the code that might create problems similar to the
ones described in the previous comment: 
http://lxr.mozilla.org/mozilla/source/intl/locale/src/nsScriptableDateFormat.cpp#94
Depends on: 163665
This clean-up patch should fix the problem. 

In the original code, we were trying to get the application's locale and pass
it to the dateTimeFormat methods. This is incorrect --- we should use the
user's customisation regardless of the locale (i.e. we should pass nsnull as a
locale for FormatTime method). 

One way or the other, Mac-specific code (including nsDateTimeFormatMac.cpp) IS
correct (!), but the use of the dateTimeFormat methods outside of their class
is not. This patch should fix the problem on Mac and leave all other OS'
behaviour as it is of today.
Assignee: jshin → cnst.bmo
Status: NEW → ASSIGNED
Attachment #142657 - Flags: superreview?(roc)
Attachment #142657 - Flags: review?(jshin)
Comment on attachment 142657 [details] [diff] [review]
clean-up patch for /intl/locale/src/nsScriptableDateFormat.cpp


>-  if (localeName.IsEmpty())
>-    localeService->GetApplicationLocale(getter_AddRefs(locale));

You should keep this. Otherwise, locale would be left uninitialized.
Attachment #142657 - Flags: review?(jshin) → review-
(In reply to comment #8)
> (From update of attachment 142657 [details] [diff] [review])
> 
> >-  if (localeName.IsEmpty())
> >-    localeService->GetApplicationLocale(getter_AddRefs(locale));
> 
> You should keep this. Otherwise, locale would be left uninitialized.

No, we should not keep this. This bug is about removing exactly that code! See
my comment #7.

I intended to use nsnull as locale, unless !localeName.IsEmpty(). 

As a reference, take a look at bug #231280, which is resolved with a similar patch. 
I think this is the last misuse of locale for Date and Time formatting. Again,
the idea of the patch is the same as of the ones before --- we leave locale set
to nsnull by default.
Attachment #142690 - Flags: review?(jshin)
Attachment #142657 - Attachment description: clean-up patch → clean-up patch for /intl/locale/src/nsScriptableDateFormat.cpp
Attachment #142657 - Attachment filename: nsdiff → nsScriptableDateFormat.cpp.patch
Attachment #142657 - Flags: review- → review?(jshin)
Summary: Long Date format is incorrect (OS X) → GetApplicationLocale should not be used with FormatTime methods in order to support user
Blocks: 231280
Summary: GetApplicationLocale should not be used with FormatTime methods in order to support user → GetApplicationLocale should not be used with FormatTime methods in order to support user's customisation (OS X is affected)
Target Milestone: --- → mozilla1.7beta
Attachment #142657 - Flags: superreview?(roc) → superreview+
Attachment #142690 - Flags: superreview?(roc)
Attachment #142690 - Flags: superreview?(roc) → superreview+
Comment on attachment 142657 [details] [diff] [review]
clean-up patch for /intl/locale/src/nsScriptableDateFormat.cpp

>-  if (!locale)
>-    return NS_ERROR_NOT_AVAILABLE;
>+    NS_ENSURE_TRUE(locale, NS_ERROR_FAILURE);

Please, use NS_ERROR_NOT_AVAILABLE. It might be better to keep |if (!locale)
return ....| unless you think it's 'assertion-worthy'.


>-  if (!dateTimeFormat)
>-    return NS_ERROR_NOT_AVAILABLE;
>+  NS_ENSURE_TRUE(dateTimeFormat, NS_ERROR_FAILURE);

ditto.

With that, r=jshin
Attachment #142657 - Flags: review?(jshin) → review+
This patch addresses jshin comments. We are now using the real 'rv' value.
Attachment #142657 - Attachment is obsolete: true
Attachment #143768 - Flags: superreview?(roc)
Attachment #143768 - Flags: review?(jshin)
Attachment #143768 - Flags: superreview?(roc) → superreview+
Flags: blocking1.7b?
Comment on attachment 143768 [details] [diff] [review]
clean-up patch v.2 for intl/locale/src/nsScriptableDateFormat.cpp

r=jshin (if you insist...)
Attachment #143768 - Flags: review?(jshin) → review+
Attachment #143768 - Flags: approval1.7b?
Comment on attachment 143768 [details] [diff] [review]
clean-up patch v.2 for intl/locale/src/nsScriptableDateFormat.cpp

a=chofmann for 1.7b
Attachment #143768 - Flags: approval1.7b? → approval1.7b+
Attachment #142690 - Flags: approval1.7b?
Comment on attachment 142690 [details] [diff] [review]
patch for /mailnews/compose/src/nsMsgCompose.cpp

a=chofmann for 1.7b
Attachment #142690 - Flags: approval1.7b? → approval1.7b+
Attachment #142690 - Flags: review?(jshin) → review+
both patches checked in

Checking in intl/locale/src/nsScriptableDateFormat.cpp;
/cvsroot/mozilla/intl/locale/src/nsScriptableDateFormat.cpp,v  <-- 
nsScriptableDateFormat.cpp
new revision: 1.24; previous revision: 1.23
done
Checking in mailnews/compose/src/nsMsgCompose.cpp;
/cvsroot/mozilla/mailnews/compose/src/nsMsgCompose.cpp,v  <--  nsMsgCompose.cpp
new revision: 1.422; previous revision: 1.421
done
Both patches were checked in by biesi on 2004-03-16 13:55 PST. 
Mozilla App Suite 1.7b and later will contain the fix.  
Status: ASSIGNED → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Flags: blocking1.7b?
I think this check-in caused Bug 239535.
(In reply to comment #18)
> I think this check-in caused Bug 239535.

What makes you think this way? Have you tried to reproduce it before and after
the patch was applied? I think the nightlies are still around... The patch is
simple and does not look to contain any errors. If the bug exists, it must be
elsewhere. The code of this patch is platform-independent. 
Sorry, I see the description of your bug now. This patch might have activated
some other bug in FormatTime. 
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: